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/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 ++++++++++ 5 files changed, 535 insertions(+) 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 (limited to 'project/cmake/scripts/common') 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() -- cgit v1.2.3