From ffca21f2743a7b367fa212799c6e2fea6190dd5d Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 3 Mar 2015 16:53:59 +0100 Subject: initial commit for kodi master --- project/cmake/addons/CMakeLists.txt | 249 +++++++++++++++++++++ project/cmake/addons/README | 68 ++++++ .../addons/audioencoder.flac/audioencoder.flac.txt | 1 + .../addons/addons/audioencoder.flac/platforms.txt | 1 + .../addons/audioencoder.lame/audioencoder.lame.txt | 1 + .../addons/addons/audioencoder.lame/platforms.txt | 1 + .../audioencoder.vorbis/audioencoder.vorbis.txt | 1 + .../addons/audioencoder.vorbis/platforms.txt | 1 + .../addons/audioencoder.wav/audioencoder.wav.txt | 1 + .../addons/addons/audioencoder.wav/platforms.txt | 1 + .../cmake/addons/addons/pvr.argustv/platforms.txt | 1 + .../addons/addons/pvr.argustv/pvr.argustv.txt | 1 + project/cmake/addons/addons/pvr.demo/platforms.txt | 1 + project/cmake/addons/addons/pvr.demo/pvr.demo.txt | 1 + .../cmake/addons/addons/pvr.dvblink/platforms.txt | 1 + .../addons/addons/pvr.dvblink/pvr.dvblink.txt | 1 + .../addons/addons/pvr.dvbviewer/platforms.txt | 1 + .../addons/addons/pvr.dvbviewer/pvr.dvbviewer.txt | 1 + project/cmake/addons/addons/pvr.hts/platforms.txt | 1 + project/cmake/addons/addons/pvr.hts/pvr.hts.txt | 1 + .../addons/addons/pvr.iptvsimple/platforms.txt | 1 + .../addons/pvr.iptvsimple/pvr.iptvsimple.txt | 1 + .../addons/pvr.mediaportal.tvserver/platforms.txt | 1 + .../pvr.mediaportal.tvserver.txt | 1 + .../cmake/addons/addons/pvr.mythtv/platforms.txt | 1 + .../cmake/addons/addons/pvr.mythtv/pvr.mythtv.txt | 1 + .../cmake/addons/addons/pvr.nextpvr/platforms.txt | 1 + .../addons/addons/pvr.nextpvr/pvr.nextpvr.txt | 1 + project/cmake/addons/addons/pvr.njoy/platforms.txt | 1 + project/cmake/addons/addons/pvr.njoy/pvr.njoy.txt | 1 + .../cmake/addons/addons/pvr.vdr.vnsi/platforms.txt | 1 + .../addons/addons/pvr.vdr.vnsi/pvr.vdr.vnsi.txt | 1 + .../cmake/addons/addons/pvr.vuplus/platforms.txt | 1 + .../cmake/addons/addons/pvr.vuplus/pvr.vuplus.txt | 1 + project/cmake/addons/addons/pvr.wmc/platforms.txt | 1 + project/cmake/addons/addons/pvr.wmc/pvr.wmc.txt | 1 + project/cmake/addons/depends/CMakeLists.txt | 42 ++++ project/cmake/addons/depends/README | 61 +++++ .../addons/depends/common/kodi-platform/deps.txt | 2 + .../depends/common/kodi-platform/kodi-platform.txt | 1 + .../addons/depends/common/tinyxml/CMakeLists.txt | 23 ++ .../addons/depends/common/tinyxml/tinyxml.txt | 1 + .../cmake/addons/depends/windows/CMakeLists.txt | 55 +++++ .../cmake/addons/depends/windows/Find7Zip.cmake | 7 + project/cmake/addons/depends/windows/README | 19 ++ .../cmake/addons/depends/windows/extract-7z.cmake | 10 + .../addons/depends/windows/extract-direct.cmake | 2 + project/cmake/addons/depends/windows/install.cmake | 24 ++ .../cmake/addons/depends/windows/prebuilt/README | 21 ++ project/cmake/kodi-config.cmake.in | 11 + project/cmake/platform/android/defines.txt | 1 + project/cmake/platform/darwin/defines.txt | 1 + project/cmake/platform/freebsd/defines.txt | 1 + project/cmake/platform/ios/defines.txt | 1 + project/cmake/platform/linux/defines.txt | 1 + project/cmake/platform/rbpi/defines.txt | 1 + project/cmake/platform/windows/defines.txt | 1 + project/cmake/scripts/common/addon-helpers.cmake | 113 ++++++++++ project/cmake/scripts/common/addoptions.cmake | 82 +++++++ .../scripts/common/check_target_platform.cmake | 61 +++++ project/cmake/scripts/common/handle-depends.cmake | 191 ++++++++++++++++ project/cmake/scripts/common/prepare-env.cmake | 88 ++++++++ .../cmake/scripts/windows/c-flag-overrides.cmake | 5 + .../cmake/scripts/windows/cxx-flag-overrides.cmake | 5 + project/cmake/xbmc-config.cmake.in | 4 + 65 files changed, 1186 insertions(+) create mode 100644 project/cmake/addons/CMakeLists.txt create mode 100644 project/cmake/addons/README create mode 100644 project/cmake/addons/addons/audioencoder.flac/audioencoder.flac.txt create mode 100644 project/cmake/addons/addons/audioencoder.flac/platforms.txt create mode 100644 project/cmake/addons/addons/audioencoder.lame/audioencoder.lame.txt create mode 100644 project/cmake/addons/addons/audioencoder.lame/platforms.txt create mode 100644 project/cmake/addons/addons/audioencoder.vorbis/audioencoder.vorbis.txt create mode 100644 project/cmake/addons/addons/audioencoder.vorbis/platforms.txt create mode 100644 project/cmake/addons/addons/audioencoder.wav/audioencoder.wav.txt create mode 100644 project/cmake/addons/addons/audioencoder.wav/platforms.txt create mode 100644 project/cmake/addons/addons/pvr.argustv/platforms.txt create mode 100644 project/cmake/addons/addons/pvr.argustv/pvr.argustv.txt create mode 100644 project/cmake/addons/addons/pvr.demo/platforms.txt create mode 100644 project/cmake/addons/addons/pvr.demo/pvr.demo.txt create mode 100644 project/cmake/addons/addons/pvr.dvblink/platforms.txt create mode 100644 project/cmake/addons/addons/pvr.dvblink/pvr.dvblink.txt create mode 100644 project/cmake/addons/addons/pvr.dvbviewer/platforms.txt create mode 100644 project/cmake/addons/addons/pvr.dvbviewer/pvr.dvbviewer.txt create mode 100644 project/cmake/addons/addons/pvr.hts/platforms.txt create mode 100644 project/cmake/addons/addons/pvr.hts/pvr.hts.txt create mode 100644 project/cmake/addons/addons/pvr.iptvsimple/platforms.txt create mode 100644 project/cmake/addons/addons/pvr.iptvsimple/pvr.iptvsimple.txt create mode 100644 project/cmake/addons/addons/pvr.mediaportal.tvserver/platforms.txt create mode 100644 project/cmake/addons/addons/pvr.mediaportal.tvserver/pvr.mediaportal.tvserver.txt create mode 100644 project/cmake/addons/addons/pvr.mythtv/platforms.txt create mode 100644 project/cmake/addons/addons/pvr.mythtv/pvr.mythtv.txt create mode 100644 project/cmake/addons/addons/pvr.nextpvr/platforms.txt create mode 100644 project/cmake/addons/addons/pvr.nextpvr/pvr.nextpvr.txt create mode 100644 project/cmake/addons/addons/pvr.njoy/platforms.txt create mode 100644 project/cmake/addons/addons/pvr.njoy/pvr.njoy.txt create mode 100644 project/cmake/addons/addons/pvr.vdr.vnsi/platforms.txt create mode 100644 project/cmake/addons/addons/pvr.vdr.vnsi/pvr.vdr.vnsi.txt create mode 100644 project/cmake/addons/addons/pvr.vuplus/platforms.txt create mode 100644 project/cmake/addons/addons/pvr.vuplus/pvr.vuplus.txt create mode 100644 project/cmake/addons/addons/pvr.wmc/platforms.txt create mode 100644 project/cmake/addons/addons/pvr.wmc/pvr.wmc.txt create mode 100644 project/cmake/addons/depends/CMakeLists.txt create mode 100644 project/cmake/addons/depends/README create mode 100644 project/cmake/addons/depends/common/kodi-platform/deps.txt create mode 100644 project/cmake/addons/depends/common/kodi-platform/kodi-platform.txt create mode 100644 project/cmake/addons/depends/common/tinyxml/CMakeLists.txt create mode 100644 project/cmake/addons/depends/common/tinyxml/tinyxml.txt create mode 100644 project/cmake/addons/depends/windows/CMakeLists.txt create mode 100644 project/cmake/addons/depends/windows/Find7Zip.cmake create mode 100644 project/cmake/addons/depends/windows/README create mode 100644 project/cmake/addons/depends/windows/extract-7z.cmake create mode 100644 project/cmake/addons/depends/windows/extract-direct.cmake create mode 100644 project/cmake/addons/depends/windows/install.cmake create mode 100644 project/cmake/addons/depends/windows/prebuilt/README create mode 100644 project/cmake/kodi-config.cmake.in create mode 100644 project/cmake/platform/android/defines.txt create mode 100644 project/cmake/platform/darwin/defines.txt create mode 100644 project/cmake/platform/freebsd/defines.txt create mode 100644 project/cmake/platform/ios/defines.txt create mode 100644 project/cmake/platform/linux/defines.txt create mode 100644 project/cmake/platform/rbpi/defines.txt create mode 100644 project/cmake/platform/windows/defines.txt create mode 100644 project/cmake/scripts/common/addon-helpers.cmake create mode 100644 project/cmake/scripts/common/addoptions.cmake create mode 100644 project/cmake/scripts/common/check_target_platform.cmake create mode 100644 project/cmake/scripts/common/handle-depends.cmake create mode 100644 project/cmake/scripts/common/prepare-env.cmake create mode 100644 project/cmake/scripts/windows/c-flag-overrides.cmake create mode 100644 project/cmake/scripts/windows/cxx-flag-overrides.cmake create mode 100644 project/cmake/xbmc-config.cmake.in (limited to 'project') diff --git a/project/cmake/addons/CMakeLists.txt b/project/cmake/addons/CMakeLists.txt new file mode 100644 index 0000000..0afc622 --- /dev/null +++ b/project/cmake/addons/CMakeLists.txt @@ -0,0 +1,249 @@ +project(kodi-addons) + +cmake_minimum_required(VERSION 2.8) + +list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}) + +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release) +endif() + +if(NOT CORE_SYSTEM_NAME) + string(TOLOWER ${CMAKE_SYSTEM_NAME} CORE_SYSTEM_NAME) +endif() + +include(ExternalProject) + +### setup all the necessary paths +if(NOT APP_ROOT AND NOT XBMCROOT) + set(APP_ROOT ${PROJECT_SOURCE_DIR}/../../..) +elseif(NOT APP_ROOT) + file(TO_CMAKE_PATH "${XBMCROOT}" APP_ROOT) +else() + file(TO_CMAKE_PATH "${APP_ROOT}" APP_ROOT) +endif() +get_filename_component(APP_ROOT "${APP_ROOT}" ABSOLUTE) + +if(NOT BUILD_DIR) + set(BUILD_DIR "${CMAKE_BINARY_DIR}/build") +else() + file(TO_CMAKE_PATH "${BUILD_DIR}" BUILD_DIR) +endif() +get_filename_component(BUILD_DIR "${BUILD_DIR}" ABSOLUTE) + +if(NOT DEPENDS_PATH) + set(DEPENDS_PATH "${BUILD_DIR}/depends") +else() + file(TO_CMAKE_PATH "${DEPENDS_PATH}" DEPENDS_PATH) +endif() +get_filename_component(DEPENDS_PATH "${DEPENDS_PATH}" ABSOLUTE) + +if(NOT PLATFORM_DIR) + set(PLATFORM_DIR ${APP_ROOT}/project/cmake/platform/${CORE_SYSTEM_NAME}) + file(TO_CMAKE_PATH "${PLATFORM_DIR}" PLATFORM_DIR) +endif() + +# make sure CMAKE_PREFIX_PATH is set +if(NOT CMAKE_PREFIX_PATH) + set(CMAKE_PREFIX_PATH "${DEPENDS_PATH}") +else() + file(TO_CMAKE_PATH "${CMAKE_PREFIX_PATH}" CMAKE_PREFIX_PATH) + list(APPEND CMAKE_PREFIX_PATH "${DEPENDS_PATH}") +endif() + +# check for autoconf stuff to pass on +if(AUTOCONF_FILES) + separate_arguments(AUTOCONF_FILES) + set(CROSS_AUTOCONF "yes") +endif() + +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR NOT CMAKE_INSTALL_PREFIX) + set(CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/output/addons") +endif() +list(APPEND CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}) + +set(BUILD_ARGS -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} + -DCMAKE_INSTALL_PREFIX:PATH= + -DPACKAGE_CONFIG_PATH=${DEPENDS_PATH}/lib/pkgconfig + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_USER_MAKE_RULES_OVERRIDE=${CMAKE_USER_MAKE_RULES_OVERRIDE} + -DCMAKE_USER_MAKE_RULES_OVERRIDE_CXX=${CMAKE_USER_MAKE_RULES_OVERRIDE_CXX} + -DCORE_SYSTEM_NAME=${CORE_SYSTEM_NAME} + -DBUILD_SHARED_LIBS=1 + -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} + -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}) + +if(PACKAGE_ZIP) + # needed for project installing + list(APPEND BUILD_ARGS -DPACKAGE_ZIP=1) + MESSAGE("package zip specified") +endif() + +if(CMAKE_TOOLCHAIN_FILE) + list(APPEND BUILD_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) + MESSAGE("toolchain specified") + MESSAGE(${BUILD_ARGS}) +endif() + +if(NOT ADDONS_TO_BUILD) + set(ADDONS_TO_BUILD "all") +else() + message(STATUS "Building following addons: ${ADDONS_TO_BUILD}") + separate_arguments(ADDONS_TO_BUILD) +endif() + +if(NOT KODI_LIB_DIR) + set(KODI_LIB_DIR "${DEPENDS_PATH}/lib/kodi") +else() + file(TO_CMAKE_PATH "${KODI_LIB_DIR}" KODI_LIB_DIR) +endif() + +# check for platform specific stuff +if(EXISTS ${PLATFORM_DIR}/defines.txt) + file(STRINGS ${PLATFORM_DIR}/defines.txt platformdefines) + + if(NOT ARCH_DEFINES AND platformdefines) + set(ARCH_DEFINES ${platformdefines}) + endif() +endif() + +# include check_target_platform() function +include(${APP_ROOT}/project/cmake/scripts/common/check_target_platform.cmake) + +# check install permissions +set(ADDON_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}) +check_install_permissions(${CMAKE_INSTALL_PREFIX} can_write) +if(NOT ${can_write} AND NOT WIN32) + set(NEED_SUDO TRUE) + set(ADDON_INSTALL_DIR ${CMAKE_BINARY_DIR}/.install) + message(STATUS "NEED_SUDO: ${NEED_SUDO}") +endif() + +### prepare the build environment for the binary addons +# copy the prepare-env.cmake script to the depends path so that we can include it +file(COPY ${APP_ROOT}/project/cmake/scripts/common/prepare-env.cmake DESTINATION ${KODI_LIB_DIR}) + +# add the location of prepare-env.cmake to CMAKE_MODULE_PATH so that it is found +list(APPEND CMAKE_MODULE_PATH ${KODI_LIB_DIR}) + +# include prepare-env.cmake which contains the logic to install the addon header bindings etc +include(prepare-env) + +### add the depends subdirectory for any general dependencies +add_subdirectory(depends) + +### get and build all the binary addons +# look for all the addons to be built +file(GLOB_RECURSE addons ${PROJECT_SOURCE_DIR}/addons/*.txt) +foreach(addon ${addons}) + if(NOT (addon MATCHES platforms.txt)) + file(STRINGS ${addon} def) + separate_arguments(def) + list(GET def 0 id) + + list(FIND ADDONS_TO_BUILD ${id} idx) + if(idx GREATER -1 OR ADDONS_TO_BUILD STREQUAL "all") + get_filename_component(dir ${addon} PATH) + + # check if the addon has a platforms.txt + set(platform_found FALSE) + check_target_platform(${dir} ${CORE_SYSTEM_NAME} platform_found) + + if (${platform_found}) + # make sure the output directory is clean + if(EXISTS "${CMAKE_INSTALL_PREFIX}/${id}") + file(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}/${id}/") + endif() + + # get the URL and revision of the addon + list(LENGTH def deflength) + list(GET def 1 url) + + set(archive_name ${id}) + + # if there is a 3rd parameter in the file, we consider it a git revision + if(deflength GREATER 2) + list(GET def 2 revision) + + # Note: downloading specific revisions via http in the format below is probably github specific + # if we ever use other repositories, this might need adapting + set(url ${url}/archive/${revision}.tar.gz) + set(archive_name ${archive_name}-${revision}) + endif() + + # download and extract the addon + if(NOT EXISTS ${BUILD_DIR}/download/${archive_name}.tar.gz) + # cleanup any of the previously downloaded archives of this addon + file(GLOB archives "${BUILD_DIR}/download/${id}*.tar.gz") + if(archives) + message(STATUS "Removing old archives of ${id}: ${archives}") + file(REMOVE ${archives}) + endif() + + # download the addon + file(DOWNLOAD "${url}" "${BUILD_DIR}/download/${archive_name}.tar.gz" STATUS dlstatus LOG dllog SHOW_PROGRESS) + list(GET dlstatus 0 retcode) + if(NOT ${retcode} EQUAL 0) + message(FATAL_ERROR "ERROR downloading ${url} - status: ${dlstatus} log: ${dllog}") + endif() + endif() + + # remove any previously extracted version of the addon + if(EXISTS "${BUILD_DIR}/${id}") + file(REMOVE_RECURSE "${BUILD_DIR}/${id}") + endif() + + # extract the addon from the archive + execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzvf ${BUILD_DIR}/download/${archive_name}.tar.gz + WORKING_DIRECTORY ${BUILD_DIR}) + file(GLOB extract_dir "${BUILD_DIR}/${archive_name}*") + if(extract_dir STREQUAL "") + message(FATAL_ERROR "Error extracting ${BUILD_DIR}/download/${archive_name}.tar.gz") + else() + file(RENAME "${extract_dir}" "${BUILD_DIR}/${id}") + endif() + + list(APPEND downloaded_addons ${id}) + + endif() + endif() + endif() +endforeach() + +foreach(id ${downloaded_addons}) + externalproject_add(${id} + SOURCE_DIR ${BUILD_DIR}/${id} + INSTALL_DIR ${ADDON_INSTALL_DIR} + CMAKE_ARGS ${BUILD_ARGS}) + + # add a custom step to the external project between the configure and the build step which will always + # be executed and therefore forces a re-build of all changed files + externalproject_add_step(${id} forcebuild + COMMAND ${CMAKE_COMMAND} -E echo "Force build of ${id}" + DEPENDEES configure + DEPENDERS build + ALWAYS 1) + + # add "kodi-platform" as a dependency to every addon + add_dependencies(${id} kodi-platform) + + set(${id}_DEPENDS_DIR ${BUILD_DIR}/${id}/depends) + + if(EXISTS ${${id}_DEPENDS_DIR}) + include(${APP_ROOT}/project/cmake/scripts/common/handle-depends.cmake) + add_addon_depends(${id} ${${id}_DEPENDS_DIR}) + if (${id}_DEPS AND NOT "${${id}_DEPS}" STREQUAL "") + message(STATUS "${id} DEPENDENCIES: ${${id}_DEPS}") + add_dependencies(${id} ${${id}_DEPS}) + endif() + endif() +endforeach() + +if(NEED_SUDO) + add_custom_target(install + COMMAND ${CMAKE_COMMAND} -E echo "\n\n" + COMMAND ${CMAKE_COMMAND} -E echo "WARNING: sudo rights needed to install to ${CMAKE_INSTALL_PREFIX}\n" + COMMAND sudo ${CMAKE_COMMAND} -E copy_directory ${ADDON_INSTALL_DIR}/ ${CMAKE_INSTALL_PREFIX}/ + COMMAND sudo ${CMAKE_COMMAND} -E remove_directory ${ADDON_INSTALL_DIR}/ + COMMAND sudo -k) +endif() diff --git a/project/cmake/addons/README b/project/cmake/addons/README new file mode 100644 index 0000000..c66e668 --- /dev/null +++ b/project/cmake/addons/README @@ -0,0 +1,68 @@ +KODI ADDONS +=========== +This directory contains the cmake-based buildsystem for addons. It looks into +the "addons" sub-directory and parses all *.txt files recursively. Each addon +must have its own .txt file in a separate sub-directory which must +follow the defined format: + +where + * must be identical to the addon's ID as defined in the addon's + addon.xml + * must be the URL of the git repository containing the addon. + * must be a valid git tag/branch/commit in the addon's git + repository which will be used for the build. + +Reserved filenames (for additional information on how to build an addon) +are: + * platforms.txt: List of platforms to build an addon for (or "all"). It is + also supported to specify negated platforms with a leading exclamation mark + (i), e.g. "!windows". + Available platforms are: linux, windows, darwin, ios, android, rbpi + +The buildsystem uses the following variables (which can be passed into it when +executing cmake with the -D= option) to e.g. access +specific paths: + * ADDONS_TO_BUILD is a quoted, space delimited list of s that + you want to build (default is "all"). + * CMAKE_BUILD_TYPE specifies the type of the build. This can be either "Debug" + or "Release" (default is "Release"). + * CMAKE_INSTALL_PREFIX points to the directory where the built addons and their + additional files (addon.xml, resources ...) will be installed to (defaults + to ). + * CMAKE_TOOLCHAIN_FILE can be used to pass a toolchain file into the add-on + builds. + * DEPENDS_PATH points to the directory containing the "include" and "lib" + directories of the addons' dependencies. + * APP_ROOT points to the root directory of the project (default is the + absolute representation of ../../.. starting from this directory). + * BUILD_DIR points to the directory where the addons and their dependencies + will be downloaded and built. + * PACKAGE_ZIP=1 will mean the add-ons will be 'packaged' into a common folder, + rather than being placed in /lib/kodi/addons and + /share/kodi/addons. + * ARCH_DEFINES specifies the platform-specific C/C++ preprocessor defines + (defaults to empty). + +The buildsystem makes some assumptions about the environment which must be met +by whoever uses it: + * Any dependencies of the addons must already be built and their include and + library files must be present in the path pointed to by (in + "include" and "lib" sub-directories). + +To trigger the cmake-based buildsystem the following command must be executed +with being the path to this directory (absolute or relative, allowing for +in-source and out-of-source builds). + + cmake -G + +cmake supports multiple generators, see +http://www.cmake.org/cmake/help/v2.8.8/cmake.html#section_Generators for a list. + +In case of additional options the call might look like this + + cmake [-G ] \ + -DCMAKE_BUILD_TYPE=Release \ + -DAPP_ROOT="" \ + -DARCH_DEFINES="-DTARGET_LINUX" \ + -DDEPENDS_PATH="" \ + -DCMAKE_INSTALL_PREFIX="/cmake" sub-directories and parses +all *.txt files recursively. Each dependency must have its own .txt +file (either in the main sub-directory or in a separate subdirectory of the main +subdirectory) which must follow one of the defined formats: + * an empty file means that no extra downloads are necessary + * + * + * +where + * must be identical to the filename + * must be the URL to an archive that is downloaded and extracted. + * must be the URL of the git repository containing the + dependency. + * must be a valid git tag/branch/commit in the dependency's git + repository which will be used for the build. + +Reserved filenames (for additional information on how to build a dependency) +are: + * CMakeLists.txt: build instructions for the dependency + * install.txt: instructions on how to install the dependency's built files + * noinstall.txt: no installation step required (content is ignored) + * flags.txt: additional build flags + * deps.txt: whitespace separated list of dependencies of this dependency + +The buildsystem uses the following variables (which can be passed into it when +executing cmake with the -D= option) to e.g. access +specific paths: + * CMAKE_BUILD_TYPE specifies the type of the build. This can be either "Debug" + or "Release" (default is "Release"). + * CMAKE_TOOLCHAIN_FILE can be used to pass a toolchain file into the add-on + builds. + * CORE_SYSTEM_NAME is the name of the platform (e.g. "linux" or "android") in + lower-case (defaults to lowercase(CMAKE_SYSTEM_NAME)). + * APP_ROOT points to the root directory of the project (default is the + absolute representation of ../../.. starting from this directory). + * DEPENDS_PATH points to the directory where the built dependencies + (their include and library file) will be installed to. + * ARCH_DEFINES specifies the platform-specific C/C++ preprocessor defines + (defaults to empty). + * DEPENDS_TO_BUILD is a quoted, space delimited list of s that + you want to build (default is "all"). + +To trigger the cmake-based buildsystem the following command must be executed +with being the path to this directory (absolute or relative, allowing for +in-source and out-of-source builds). + + cmake -G + +cmake supports multiple generators, see +http://www.cmake.org/cmake/help/v2.8.8/cmake.html#section_Generators for a list. + +In case of additional options the call might look like this + + cmake [-G ] \ + -DCMAKE_BUILD_TYPE=Release \ + -DAPP_ROOT="" \ + -DARCH_DEFINES="-DTARGET_LINUX" \ + -DCMAKE_INSTALL_PREFIX=" being the path to this directory (absolute or relative, allowing for +in-source and out-of-source builds). + + cmake [-G ] + +cmake supports multiple generators, see +http://www.cmake.org/cmake/help/v2.8.8/cmake.html#section_Generators for a list. +For win32 builds one of the "Visual Studio XX" or the "NMake Makefiles" +generators is preferred. For the "NMake Makefiles" generator to work the above +command must be called from an environment prepared for VC++ builds (see +http://msdn.microsoft.com/en-us/library/f2ccy3wt.aspx). diff --git a/project/cmake/addons/depends/windows/extract-7z.cmake b/project/cmake/addons/depends/windows/extract-7z.cmake new file mode 100644 index 0000000..95a2672 --- /dev/null +++ b/project/cmake/addons/depends/windows/extract-7z.cmake @@ -0,0 +1,10 @@ +get_filename_component(file ${URL} NAME) +file(DOWNLOAD ${URL} ${DEST}/${file}) +execute_process(COMMAND ${7ZIP_EXECUTABLE} -y x ${DEST}/${file} + WORKING_DIRECTORY ${DESTDIR}) +if(${file} MATCHES .tar) + string(REPLACE ".7z" "" tarball ${file}) + string(REPLACE ".lzma" "" tarball ${file}) + execute_process(COMMAND ${7ZIP_EXECUTABLE} -y x ${DESTDIR}/${tarball} + WORKING_DIRECTORY ${DESTDIR}) +endif() diff --git a/project/cmake/addons/depends/windows/extract-direct.cmake b/project/cmake/addons/depends/windows/extract-direct.cmake new file mode 100644 index 0000000..13cb74f --- /dev/null +++ b/project/cmake/addons/depends/windows/extract-direct.cmake @@ -0,0 +1,2 @@ +get_filename_component(file ${URL} NAME) +file(DOWNLOAD ${URL} ${DEST}/${file}) diff --git a/project/cmake/addons/depends/windows/install.cmake b/project/cmake/addons/depends/windows/install.cmake new file mode 100644 index 0000000..9a3adbb --- /dev/null +++ b/project/cmake/addons/depends/windows/install.cmake @@ -0,0 +1,24 @@ +if(EXISTS "${INPUTFILE}") + # if there's an input file we use it to determine which files to copy where + file(STRINGS ${INPUTFILE} FILES) + string(REPLACE "\n" ";" FILES "${FILES}") + foreach(file ${FILES}) + string(REPLACE " " ";" file "${file}") + list(GET file 0 dir) + list(GET file 1 dest) + list(LENGTH file deflength) + if(deflength GREATER 2) + list(GET file 2 copy) + endif() + file(GLOB files ${INPUTDIR}/${dir}) + foreach(instfile ${files}) + file(COPY ${instfile} DESTINATION ${DESTDIR}/${dest}) + if(copy) + file(COPY ${instfile} DESTINATION ${DESTDIR}/${copy}) + endif() + endforeach() + endforeach() +else() + # otherwise we assume that the content of the extracted archive is already well-formed and can just be copied + file(COPY ${INPUTDIR}/${dir} DESTINATION ${DESTDIR}) +endif() \ No newline at end of file diff --git a/project/cmake/addons/depends/windows/prebuilt/README b/project/cmake/addons/depends/windows/prebuilt/README new file mode 100644 index 0000000..a0c70d6 --- /dev/null +++ b/project/cmake/addons/depends/windows/prebuilt/README @@ -0,0 +1,21 @@ +KODI WIN32 PREBUILT ADDON DEPENDENCIES +====================================== +This directory contains a file or sub-directory for every prebuilt dependency +used by one of the addons being built. There are two different modes supported. +Both include a file named .txt which must follow the defined format + + +If the archive, which the points at, contains + * only the necessary files and in the proper directory structure (i.e. an + "include" and a "lib" directory) then the file must be put into this + directory and nothing else is needed. + * unnecessary files and/or does not follow the defined directory structure + (i.e. an "include" and a "lib" directory) then the file must be put into a + sub-directory named . Furthermore an additional file called + "install.txt" must be placed in that sub-directory. install.txt contains a + line for every path/directory/file with a destination where it must be copied + to. It must follow the defined format + [] + where must be an existing file, directory or a path containing + wildcards, and the optional must be existing + directories. diff --git a/project/cmake/kodi-config.cmake.in b/project/cmake/kodi-config.cmake.in new file mode 100644 index 0000000..0e3b158 --- /dev/null +++ b/project/cmake/kodi-config.cmake.in @@ -0,0 +1,11 @@ +SET(KODI_INCLUDE_DIR @prefix@/include) +SET(APP_NAME @APP_NAME@) +SET(APP_VERSION_MAJOR @APP_VERSION_MAJOR@) +SET(APP_VERSION_MINOR @APP_VERSION_MINOR@) +IF(NOT WIN32) + SET(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} @CXX11_SWITCH@") +ENDIF() +LIST(APPEND CMAKE_MODULE_PATH @prefix@/lib/kodi) +ADD_DEFINITIONS(@ARCH_DEFINES@) + +include(addon-helpers) diff --git a/project/cmake/platform/android/defines.txt b/project/cmake/platform/android/defines.txt new file mode 100644 index 0000000..fa103d0 --- /dev/null +++ b/project/cmake/platform/android/defines.txt @@ -0,0 +1 @@ +-DTARGET_POSIX -DTARGET_LINUX -D_LINUX -DTARGET_ANDROID diff --git a/project/cmake/platform/darwin/defines.txt b/project/cmake/platform/darwin/defines.txt new file mode 100644 index 0000000..33b009e --- /dev/null +++ b/project/cmake/platform/darwin/defines.txt @@ -0,0 +1 @@ +-DTARGET_POSIX -DTARGET_DARWIN -DTARGET_DARWIN_OSX -D_LINUX diff --git a/project/cmake/platform/freebsd/defines.txt b/project/cmake/platform/freebsd/defines.txt new file mode 100644 index 0000000..9483597 --- /dev/null +++ b/project/cmake/platform/freebsd/defines.txt @@ -0,0 +1 @@ +-DTARGET_POSIX -DTARGET_FREEBSD -D_LINUX diff --git a/project/cmake/platform/ios/defines.txt b/project/cmake/platform/ios/defines.txt new file mode 100644 index 0000000..d0989ea --- /dev/null +++ b/project/cmake/platform/ios/defines.txt @@ -0,0 +1 @@ +-DTARGET_POSIX -DTARGET_DARWIN -DTARGET_DARWIN_IOS -D_LINUX diff --git a/project/cmake/platform/linux/defines.txt b/project/cmake/platform/linux/defines.txt new file mode 100644 index 0000000..3fe9c5c --- /dev/null +++ b/project/cmake/platform/linux/defines.txt @@ -0,0 +1 @@ +-DTARGET_POSIX -DTARGET_LINUX -D_LINUX -fPIC diff --git a/project/cmake/platform/rbpi/defines.txt b/project/cmake/platform/rbpi/defines.txt new file mode 100644 index 0000000..08fe4cb --- /dev/null +++ b/project/cmake/platform/rbpi/defines.txt @@ -0,0 +1 @@ +-DTARGET_POSIX -DTARGET_LINUX -D_LINUX -D_ARMEL -DTARGET_RASPBERRY_PI diff --git a/project/cmake/platform/windows/defines.txt b/project/cmake/platform/windows/defines.txt new file mode 100644 index 0000000..5ccd98a --- /dev/null +++ b/project/cmake/platform/windows/defines.txt @@ -0,0 +1 @@ +-DTARGET_WINDOWS -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS -D_USE_32BIT_TIME_T -D_WINSOCKAPI_ \ No newline at end of file diff --git a/project/cmake/scripts/common/addon-helpers.cmake b/project/cmake/scripts/common/addon-helpers.cmake new file mode 100644 index 0000000..b94df2a --- /dev/null +++ b/project/cmake/scripts/common/addon-helpers.cmake @@ -0,0 +1,113 @@ +# Workaround for the fact that cpack's filenames are not customizable. +# Each add-on is added as a separate component to facilitate zip/tgz packaging. +# The filenames are always of the form basename-component, which is +# incompatible with the addonid-version scheme we want. This hack renames +# the files from the file names generated by the 'package' target. +# Sadly we cannot extend the 'package' target, as it is a builtin target, see +# http://public.kitware.com/Bug/view.php?id=8438 +# Thus, we have to add an 'addon-package' target. +add_custom_target(addon-package + COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target package) + +macro(add_cpack_workaround target version ext) + add_custom_command(TARGET addon-package PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E rename addon-${target}-${version}.${ext} ${target}-${version}.${ext}) +endmacro() + +# Grab the version from a given add-on's addon.xml +macro (addon_version dir prefix) + FILE(READ ${dir}/addon.xml ADDONXML) + STRING(REGEX MATCH "]*version.?=.?.[0-9\\.]+" VERSION_STRING ${ADDONXML}) + STRING(REGEX REPLACE ".*version=.([0-9\\.]+).*" "\\1" ${prefix}_VERSION ${VERSION_STRING}) + message(STATUS ${prefix}_VERSION=${${prefix}_VERSION}) +endmacro() + +# Build, link and optionally package an add-on +macro (build_addon target prefix libs) + ADD_LIBRARY(${target} ${${prefix}_SOURCES}) + TARGET_LINK_LIBRARIES(${target} ${${libs}}) + addon_version(${target} ${prefix}) + SET_TARGET_PROPERTIES(${target} PROPERTIES VERSION ${${prefix}_VERSION} + SOVERSION ${APP_VERSION_MAJOR}.${APP_VERSION_MINOR} + PREFIX "") + IF(OS STREQUAL "android") + SET_TARGET_PROPERTIES(${target} PROPERTIES PREFIX "lib") + ENDIF(OS STREQUAL "android") + + # set zip as default if addon-package is called without PACKAGE_XXX + SET(CPACK_GENERATOR "ZIP") + SET(ext "zip") + IF(PACKAGE_ZIP OR PACKAGE_TGZ) + IF(PACKAGE_TGZ) + SET(CPACK_GENERATOR "TGZ") + SET(ext "tar.gz") + ENDIF(PACKAGE_TGZ) + SET(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF) + set(CPACK_PACKAGE_FILE_NAME addon) + IF(CMAKE_BUILD_TYPE STREQUAL "Release") + SET(CPACK_STRIP_FILES TRUE) + ENDIF(CMAKE_BUILD_TYPE STREQUAL "Release") + set(CPACK_ARCHIVE_COMPONENT_INSTALL ON) + set(CPACK_COMPONENTS_IGNORE_GROUPS 1) + list(APPEND CPACK_COMPONENTS_ALL ${target}-${${prefix}_VERSION}) + # Pack files together to create an archive + INSTALL(DIRECTORY ${target} DESTINATION ./ COMPONENT ${target}-${${prefix}_VERSION}) + IF(WIN32) + # get the installation location for the addon's target + get_property(dll_location TARGET ${target} PROPERTY LOCATION) + # in case of a VC++ project the installation location contains a $(Configuration) VS variable + # we replace it with ${CMAKE_BUILD_TYPE} (which doesn't cover the case when the build configuration + # is changed within Visual Studio) + string(REPLACE "$(Configuration)" "${CMAKE_BUILD_TYPE}" dll_location "${dll_location}") + + # install the generated DLL file + INSTALL(PROGRAMS ${dll_location} DESTINATION ${target} + COMPONENT ${target}-${${prefix}_VERSION}) + + IF(CMAKE_BUILD_TYPE MATCHES Debug) + # for debug builds also install the PDB file + get_filename_component(dll_directory ${dll_location} DIRECTORY) + INSTALL(FILES ${dll_directory}/${target}.pdb DESTINATION ${target} + COMPONENT ${target}-${${prefix}_VERSION}) + ENDIF() + ELSE(WIN32) + INSTALL(TARGETS ${target} DESTINATION ${target} + COMPONENT ${target}-${${prefix}_VERSION}) + ENDIF(WIN32) + add_cpack_workaround(${target} ${${prefix}_VERSION} ${ext}) + ELSE(PACKAGE_ZIP OR PACKAGE_TGZ) + INSTALL(TARGETS ${target} DESTINATION lib/kodi/addons/${target}) + INSTALL(DIRECTORY ${target} DESTINATION share/kodi/addons) + ENDIF(PACKAGE_ZIP OR PACKAGE_TGZ) +endmacro() + +# finds a path to a given file (recursive) +function (kodi_find_path var_name filename search_path strip_file) + file(GLOB_RECURSE PATH_TO_FILE ${search_path} ${filename}) + if(strip_file) + string(REPLACE ${filename} "" PATH_TO_FILE ${PATH_TO_FILE}) + endif(strip_file) + set (${var_name} ${PATH_TO_FILE} PARENT_SCOPE) +endfunction() + +# Cmake build options +include(addoptions) +include(TestCXXAcceptsFlag) +OPTION(PACKAGE_ZIP "Package Zip file?" OFF) +OPTION(PACKAGE_TGZ "Package TGZ file?" OFF) +OPTION(BUILD_SHARED_LIBS "Build shared libs?" ON) + +# LTO support? +CHECK_CXX_ACCEPTS_FLAG("-flto" HAVE_LTO) +IF(HAVE_LTO) + OPTION(USE_LTO "use link time optimization" OFF) + IF(USE_LTO) + add_options(ALL_LANGUAGES ALL_BUILDS "-flto") + ENDIF(USE_LTO) +ENDIF(HAVE_LTO) + +# set this to try linking dependencies as static as possible +IF(ADDONS_PREFER_STATIC_LIBS) + SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) +ENDIF(ADDONS_PREFER_STATIC_LIBS) + diff --git a/project/cmake/scripts/common/addoptions.cmake b/project/cmake/scripts/common/addoptions.cmake new file mode 100644 index 0000000..0ebb823 --- /dev/null +++ b/project/cmake/scripts/common/addoptions.cmake @@ -0,0 +1,82 @@ +# - Add options without repeating them on the command line +# +# Synopsis: +# +# add_options (lang build opts) +# +# where: +# +# lang Name of the language whose compiler should receive the +# options, e.g. CXX. If a comma-separated list is received +# then the option is added for all those languages. Use the +# special value ALL_LANGUAGES for these languages: CXX, C +# and Fortran +# +# build Kind of build to which this options should apply, +# such as DEBUG and RELEASE. This can also be a comma- +# separated list. Use the special value ALL_BUILDS to apply +# to all builds. +# +# opts List of options to add. Each should be quoted. +# +# Example: +# +# add_options (CXX RELEASE "-O3" "-DNDEBUG" "-Wall") + +function (add_options langs builds) + # special handling of empty language specification + if ("${langs}" STREQUAL "ALL_LANGUAGES") + set (langs CXX C Fortran) + endif ("${langs}" STREQUAL "ALL_LANGUAGES") + foreach (lang IN LISTS langs) + # prepend underscore if necessary + foreach (build IN LISTS builds) + if (NOT ("${build}" STREQUAL "ALL_BUILDS")) + set (_bld "_${build}") + string (TOUPPER "${_bld}" _bld) + else (NOT ("${build}" STREQUAL "ALL_BUILDS")) + set (_bld "") + endif (NOT ("${build}" STREQUAL "ALL_BUILDS")) + foreach (_opt IN LISTS ARGN) + set (_var "CMAKE_${lang}_FLAGS${_bld}") + #message (STATUS "Adding \"${_opt}\" to \${${_var}}") + # remove it first + string (REPLACE "${_opt}" "" _without "${${_var}}") + string (STRIP "${_without}" _without) + # we need to strip this one as well, so they are comparable + string (STRIP "${${_var}}" _stripped) + # if it wasn't there, then add it at the end + if ("${_without}" STREQUAL "${_stripped}") + # don't add any extra spaces if no options yet are set + if (NOT ${_stripped} STREQUAL "") + set (${_var} "${_stripped} ${_opt}") + else (NOT ${_stripped} STREQUAL "") + set (${_var} "${_opt}") + endif (NOT ${_stripped} STREQUAL "") + set (${_var} "${${_var}}" PARENT_SCOPE) + endif ("${_without}" STREQUAL "${_stripped}") + endforeach (_opt) + endforeach (build) + endforeach (lang) +endfunction (add_options lang build) + +# set varname to flag unless user has specified something that matches regex +function (set_default_option varname flag regex) + if (NOT "$ENV{CXXFLAGS}" MATCHES "${regex}" + AND NOT "${CMAKE_CXX_FLAGS}" MATCHES "${regex}" + AND NOT "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}" MATCHES "${regex}") + set (${varname} ${flag} PARENT_SCOPE) + else (NOT "$ENV{CXXFLAGS}" MATCHES "${regex}" + AND NOT "${CMAKE_CXX_FLAGS}" MATCHES "${regex}" + AND NOT "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}" MATCHES "${regex}") + set (${varname} PARENT_SCOPE) + endif (NOT "$ENV{CXXFLAGS}" MATCHES "${regex}" + AND NOT "${CMAKE_CXX_FLAGS}" MATCHES "${regex}" + AND NOT "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}" MATCHES "${regex}") +endfunction (set_default_option) + +# note: this must be called before project() +macro (no_default_options) + # prevent the platform probe to set options + set (CMAKE_NOT_USING_CONFIG_FLAGS TRUE) +endmacro (no_default_options) diff --git a/project/cmake/scripts/common/check_target_platform.cmake b/project/cmake/scripts/common/check_target_platform.cmake new file mode 100644 index 0000000..fc8b403 --- /dev/null +++ b/project/cmake/scripts/common/check_target_platform.cmake @@ -0,0 +1,61 @@ +# handle target platforms +function(check_target_platform dir target_platform build) + # param[in] dir path/directory of the addon/dependency + # param[in] target_platform target platform of the build + # param[out] build Result whether the addon/dependency should be built for the specified target platform + + set(${build} FALSE) + # check if the given directory exists and contains a platforms.txt + if(EXISTS ${dir} AND EXISTS ${dir}/platforms.txt) + # get all the specified platforms + file(STRINGS ${dir}/platforms.txt platforms) + separate_arguments(platforms) + + # check if the addon/dependency should be built for the current platform + foreach(platform ${platforms}) + if(${platform} STREQUAL "all" OR ${platform} STREQUAL ${target_platform}) + set(${build} TRUE) + else() + # check if the platform is defined as "!" + string(SUBSTRING ${platform} 0 1 platform_first) + if(${platform_first} STREQUAL "!") + # extract the platform + string(LENGTH ${platform} platform_length) + MATH(EXPR platform_length "${platform_length} - 1") + string(SUBSTRING ${platform} 1 ${platform_length} platform) + + # check if the current platform does not match the extracted platform + if (NOT ${platform} STREQUAL ${target_platform}) + set(${build} TRUE) + endif() + endif() + endif() + endforeach() + else() + set(${build} TRUE) + endif() + + # make the ${build} variable available to the calling script + set(${build} "${${build}}" PARENT_SCOPE) +endfunction() + +function(check_install_permissions install_dir have_perms) + # param[in] install_dir directory to check for write permissions + # param[out] have_perms wether we have permissions to install to install_dir + + set(${have_perms} TRUE) + execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${install_dir}/lib/kodi + COMMAND ${CMAKE_COMMAND} -E make_directory ${install_dir}/share/kodi + COMMAND ${CMAKE_COMMAND} -E touch ${install_dir}/lib/kodi/.cmake-inst-test ${install_dir}/share/kodi/.cmake-inst-test + RESULT_VARIABLE permtest) + + if(${permtest} GREATER 0) + message(STATUS "check_install_permissions: ${permtest}") + set(${have_perms} FALSE) + endif() + set(${have_perms} "${${have_perms}}" PARENT_SCOPE) + + if(EXISTS ${install_dir}/lib/kodi/.cmake-inst-test OR EXISTS ${install_dir}/share/kodi/.cmake-inst-test) + file(REMOVE ${install_dir}/lib/kodi/.cmake-inst-test ${install_dir}/share/kodi/.cmake-inst-test) + endif() +endfunction() diff --git a/project/cmake/scripts/common/handle-depends.cmake b/project/cmake/scripts/common/handle-depends.cmake new file mode 100644 index 0000000..b3bf3cd --- /dev/null +++ b/project/cmake/scripts/common/handle-depends.cmake @@ -0,0 +1,191 @@ +include(${APP_ROOT}/project/cmake/scripts/common/check_target_platform.cmake) + +# handle addon depends +function(add_addon_depends addon searchpath) + # input: string addon string searchpath + + set(OUTPUT_DIR ${DEPENDS_PATH}) + file(GLOB_RECURSE cmake_input_files ${searchpath}/${CORE_SYSTEM_NAME}/*.txt) + file(GLOB_RECURSE cmake_input_files2 ${searchpath}/common/*.txt) + list(APPEND cmake_input_files ${cmake_input_files2}) + + foreach(file ${cmake_input_files}) + if(NOT (file MATCHES CMakeLists.txt OR + file MATCHES install.txt OR + file MATCHES noinstall.txt OR + file MATCHES flags.txt OR + file MATCHES deps.txt OR + file MATCHES platforms.txt)) + message(STATUS "Processing ${file}") + file(STRINGS ${file} def) + separate_arguments(def) + list(LENGTH def deflength) + get_filename_component(dir ${file} PATH) + + # get the id of the dependency + if(NOT "${def}" STREQUAL "") + # read the id from the file + list(GET def 0 id) + else() + # read the id from the filename + get_filename_component(id ${file} NAME_WE) + endif() + + # check if the dependency has a platforms.txt + set(platform_found FALSE) + check_target_platform(${dir} ${CORE_SYSTEM_NAME} platform_found) + + if(${platform_found} AND NOT TARGET ${id}) + # determine the download URL of the dependency + set(url "") + if(deflength GREATER 1) + list(GET def 1 url) + message(STATUS "${id} url: ${url}") + endif() + + # check if there are any library specific flags that need to be passed on + if(EXISTS ${dir}/flags.txt) + file(STRINGS ${dir}/flags.txt extraflags) + separate_arguments(extraflags) + message(STATUS "${id} extraflags: ${extraflags}") + endif() + + set(BUILD_ARGS -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} + -DOUTPUT_DIR=${OUTPUT_DIR} + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_USER_MAKE_RULES_OVERRIDE=${CMAKE_USER_MAKE_RULES_OVERRIDE} + -DCMAKE_USER_MAKE_RULES_OVERRIDE_CXX=${CMAKE_USER_MAKE_RULES_OVERRIDE_CXX} + -DCMAKE_INSTALL_PREFIX=${OUTPUT_DIR} + -DCORE_SYSTEM_NAME=${CORE_SYSTEM_NAME} + -DENABLE_STATIC=1 + -DBUILD_SHARED_LIBS=0) + # if there are no make rules override files available take care of manually passing on ARCH_DEFINES + if(NOT CMAKE_USER_MAKE_RULES_OVERRIDE AND NOT CMAKE_USER_MAKE_RULES_OVERRIDE_CXX) + # make sure we create strings, not lists + set(TMP_C_FLAGS "${CMAKE_C_FLAGS} ${ARCH_DEFINES}") + set(TMP_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARCH_DEFINES}") + list(APPEND BUILD_ARGS -DCMAKE_C_FLAGS=${TMP_C_FLAGS} + -DCMAKE_CXX_FLAGS=${TMP_CXX_FLAGS}) + endif() + + if(CMAKE_TOOLCHAIN_FILE) + list(APPEND BUILD_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) + MESSAGE("toolchain specified") + MESSAGE(${BUILD_ARGS}) + endif() + + # if there's a CMakeLists.txt use it to prepare the build + set(PATCH_FILE ${BUILD_DIR}/${id}/tmp/patch.cmake) + if(EXISTS ${dir}/CMakeLists.txt) + file(APPEND ${PATCH_FILE} + "file(COPY ${dir}/CMakeLists.txt + DESTINATION ${BUILD_DIR}/${id}/src/${id})\n") + endif() + + # check if we have patches to apply + file(GLOB patches ${dir}/*.patch) + list(SORT patches) + foreach(patch ${patches}) + file(APPEND ${PATCH_FILE} + "execute_process(COMMAND patch -p1 -i ${patch})\n") + endforeach() + + + # if there's an install.txt use it to properly install the built files + set(INSTALL_COMMAND "") + if(EXISTS ${dir}/install.txt) + set(INSTALL_COMMAND INSTALL_COMMAND ${CMAKE_COMMAND} + -DINPUTDIR=${BUILD_DIR}/${id}/src/${id}-build/ + -DINPUTFILE=${dir}/install.txt + -DDESTDIR=${OUTPUT_DIR} + -DENABLE_STATIC=1 + "${extraflags}" + -P ${PROJECT_SOURCE_DIR}/install.cmake) + elseif(EXISTS ${dir}/noinstall.txt) + set(INSTALL_COMMAND INSTALL_COMMAND "") + endif() + + # check if there's a deps.txt containing dependencies on other libraries + if(EXISTS ${dir}/deps.txt) + file(STRINGS ${dir}/deps.txt deps) + message(STATUS "${id} depends: ${deps}") + else() + set(deps) + endif() + + if(CROSS_AUTOCONF AND AUTOCONF_FILES) + foreach(afile ${AUTOCONF_FILES}) + file(APPEND ${PATCH_FILE} + "message(STATUS \"AUTOCONF: copying ${afile} to ${BUILD_DIR}/${id}/src/${id}\")\n + file(COPY ${afile} DESTINATION ${BUILD_DIR}/${id}/src/${id})\n") + endforeach() + endif() + + # if the patch file exists we need to set the PATCH_COMMAND + set(PATCH_COMMAND "") + if (EXISTS ${PATCH_FILE}) + set(PATCH_COMMAND ${CMAKE_COMMAND} -P ${PATCH_FILE}) + endif() + + # prepare the setup of the call to externalproject_add() + set(EXTERNALPROJECT_SETUP PREFIX ${BUILD_DIR}/${id} + CMAKE_ARGS ${extraflags} ${BUILD_ARGS} + PATCH_COMMAND ${PATCH_COMMAND} + "${INSTALL_COMMAND}") + + # if there's an url defined we need to pass that to externalproject_add() + if(DEFINED url AND NOT "${url}" STREQUAL "") + # check if there's a third parameter in the file + if(deflength GREATER 2) + # the third parameter is considered as a revision of a git repository + list(GET def 2 revision) + + externalproject_add(${id} + GIT_REPOSITORY ${url} + GIT_TAG ${revision} + "${EXTERNALPROJECT_SETUP}") + else() + set(CONFIGURE_COMMAND "") + if(NOT WIN32) + # manually specify the configure command to be able to pass in the custom PKG_CONFIG_PATH + set(CONFIGURE_COMMAND PKG_CONFIG_PATH=${OUTPUT_DIR}/lib/pkgconfig + ${CMAKE_COMMAND} -DCMAKE_LIBRARY_PATH=${OUTPUT_DIR}/lib ${extraflags} ${BUILD_ARGS} + ${BUILD_DIR}/${id}/src/${id} + -DPACKAGE_CONFIG_PATH=${OUTPUT_DIR}/lib/pkgconfig + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DOUTPUT_DIR=${OUTPUT_DIR} + -DCMAKE_PREFIX_PATH=${OUTPUT_DIR} + -DCMAKE_INSTALL_PREFIX=${OUTPUT_DIR} + -DCMAKE_EXE_LINKER_FLAGS=-L${OUTPUT_DIR}/lib + -DCMAKE_INCLUDE_PATH=${OUTPUT_DIR}/include) + endif() + + externalproject_add(${id} + URL ${url} + DOWNLOAD_DIR ${BUILD_DIR}/download + CONFIGURE_COMMAND ${CONFIGURE_COMMAND} + "${EXTERNALPROJECT_SETUP}") + endif() + else() + externalproject_add(${id} + SOURCE_DIR ${dir} + "${EXTERNALPROJECT_SETUP}") + endif() + + if(deps) + add_dependencies(${id} ${deps}) + endif() + endif() + + # if the dependency is available for the target platform add it to the list of the addon's dependencies + # (even if the target already exists as it still has to be built before the addon) + if(${platform_found}) + list(APPEND ${addon}_DEPS ${id}) + endif() + endif() + endforeach() + + # make the ${addon}_DEPS variable available to the calling script + set(${addon}_DEPS "${${addon}_DEPS}" PARENT_SCOPE) +endfunction() + diff --git a/project/cmake/scripts/common/prepare-env.cmake b/project/cmake/scripts/common/prepare-env.cmake new file mode 100644 index 0000000..7df421c --- /dev/null +++ b/project/cmake/scripts/common/prepare-env.cmake @@ -0,0 +1,88 @@ +# parse version.txt to get the version info +if(EXISTS "${APP_ROOT}/version.txt") + file(STRINGS "${APP_ROOT}/version.txt" versions) + foreach (version ${versions}) + if(version MATCHES "^VERSION_.*") + string(REGEX MATCH "^[^ ]+" version_name ${version}) + string(REPLACE "${version_name} " "" version_value ${version}) + set(APP_${version_name} "${version_value}") + else() + string(REGEX MATCH "^[^ ]+" name ${version}) + string(REPLACE "${name} " "" value ${version}) + set(${name} "${value}") + endif() + endforeach() +endif() + +# bail if we can't parse versions +if(NOT DEFINED APP_VERSION_MAJOR OR NOT DEFINED APP_VERSION_MINOR) + message(FATAL_ERROR "Could not determine app version! make sure that ${APP_ROOT}/version.txt exists") +endif() + +### copy all the addon binding header files to include/kodi +# make sure include/kodi exists and is empty +set(KODI_LIB_DIR ${DEPENDS_PATH}/lib/kodi) +if(NOT EXISTS "${KODI_LIB_DIR}/") + file(MAKE_DIRECTORY ${KODI_LIB_DIR}) +endif() + +set(KODI_INCLUDE_DIR ${DEPENDS_PATH}/include/kodi) +if(NOT EXISTS "${KODI_INCLUDE_DIR}/") + file(MAKE_DIRECTORY ${KODI_INCLUDE_DIR}) +endif() + +# we still need XBMC_INCLUDE_DIR and XBMC_LIB_DIR for backwards compatibility to xbmc +set(XBMC_LIB_DIR ${DEPENDS_PATH}/lib/xbmc) +if(NOT EXISTS "${XBMC_LIB_DIR}/") + file(MAKE_DIRECTORY ${XBMC_LIB_DIR}) +endif() +set(XBMC_INCLUDE_DIR ${DEPENDS_PATH}/include/xbmc) +if(NOT EXISTS "${XBMC_INCLUDE_DIR}/") + file(MAKE_DIRECTORY ${XBMC_INCLUDE_DIR}) +endif() + +# make sure C++11 is always set +if(NOT WIN32) + string(REGEX MATCH "-std=(gnu|c)\\+\\+11" cxx11flag "${CMAKE_CXX_FLAGS}") + if(NOT cxx11flag) + set(CXX11_SWITCH "-std=c++11") + endif() +endif() + +# kodi-config.cmake.in (further down) expects a "prefix" variable +get_filename_component(prefix "${DEPENDS_PATH}" ABSOLUTE) + +# generate the proper kodi-config.cmake file +configure_file(${APP_ROOT}/project/cmake/kodi-config.cmake.in ${KODI_LIB_DIR}/kodi-config.cmake @ONLY) +# copy cmake helpers to lib/kodi +file(COPY ${APP_ROOT}/project/cmake/scripts/common/addon-helpers.cmake ${APP_ROOT}/project/cmake/scripts/common/addoptions.cmake DESTINATION ${KODI_LIB_DIR}) + +# generate xbmc-config.cmake for backwards compatibility to xbmc +configure_file(${APP_ROOT}/project/cmake/xbmc-config.cmake.in ${XBMC_LIB_DIR}/xbmc-config.cmake @ONLY) + +### copy all the addon binding header files to include/kodi +# parse addon-bindings.mk to get the list of header files to copy +file(STRINGS ${APP_ROOT}/xbmc/addons/addon-bindings.mk bindings) +string(REPLACE "\n" ";" bindings "${bindings}") +foreach(binding ${bindings}) + string(REPLACE " =" ";" binding "${binding}") + string(REPLACE "+=" ";" binding "${binding}") + list(GET binding 1 header) + # copy the header file to include/kodi + file(COPY ${APP_ROOT}/${header} DESTINATION ${KODI_INCLUDE_DIR}) + + # auto-generate header files for backwards compatibility to xbmc with deprecation warning + # but only do it if the file doesn't already exist + get_filename_component(headerfile ${header} NAME) + if (NOT EXISTS "${XBMC_INCLUDE_DIR}/${headerfile}") + file(WRITE ${XBMC_INCLUDE_DIR}/${headerfile} +"#pragma once +#define DEPRECATION_WARNING \"Including xbmc/${headerfile} has been deprecated, please use kodi/${headerfile}\" +#ifdef _MSC_VER + #pragma message(\"WARNING: \" DEPRECATION_WARNING) +#else + #warning DEPRECATION_WARNING +#endif +#include \"kodi/${headerfile}\"") + endif() +endforeach() diff --git a/project/cmake/scripts/windows/c-flag-overrides.cmake b/project/cmake/scripts/windows/c-flag-overrides.cmake new file mode 100644 index 0000000..ab19701 --- /dev/null +++ b/project/cmake/scripts/windows/c-flag-overrides.cmake @@ -0,0 +1,5 @@ +if(MSVC) + set(CMAKE_C_FLAGS "/MP /DWIN32 /D_WINDOWS /W3 /Zi /arch:SSE2") + set(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /MDd /Ob0 /Od /RTC1 /D_HAS_ITERATOR_DEBUGGING=0 /D_SECURE_SCL=0") + set(CMAKE_C_FLAGS_RELEASE "/MD /Ox /Ob2 /Oi /Ot /Oy /GL /DNDEBUG") +endif(MSVC) \ No newline at end of file diff --git a/project/cmake/scripts/windows/cxx-flag-overrides.cmake b/project/cmake/scripts/windows/cxx-flag-overrides.cmake new file mode 100644 index 0000000..ad3a090 --- /dev/null +++ b/project/cmake/scripts/windows/cxx-flag-overrides.cmake @@ -0,0 +1,5 @@ +if(MSVC) + set(CMAKE_CXX_FLAGS "/MP /DWIN32 /D_WINDOWS /W3 /GR /Zi /EHsc /arch:SSE2") + set(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /MDd /Ob0 /Od /RTC1 /D_HAS_ITERATOR_DEBUGGING=0 /D_SECURE_SCL=0") + set(CMAKE_CXX_FLAGS_RELEASE "/MD /Ox /Ob2 /Oi /Ot /Oy /GL /DNDEBUG") +endif(MSVC) \ No newline at end of file diff --git a/project/cmake/xbmc-config.cmake.in b/project/cmake/xbmc-config.cmake.in new file mode 100644 index 0000000..73d1c9c --- /dev/null +++ b/project/cmake/xbmc-config.cmake.in @@ -0,0 +1,4 @@ +message(WARNING "find_package(xbmc) has been deprecated, please use find_package(kodi)") + +find_package(kodi REQUIRED) +set(XBMC_INCLUDE_DIR ${KODI_INCLUDE_DIR}) \ No newline at end of file -- cgit v1.2.3