diff options
Diffstat (limited to 'project/cmake/scripts')
38 files changed, 1851 insertions, 24 deletions
diff --git a/project/cmake/scripts/android/archsetup.cmake b/project/cmake/scripts/android/archsetup.cmake new file mode 100644 index 0000000..86c0f6a --- /dev/null +++ b/project/cmake/scripts/android/archsetup.cmake | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | if(NOT CMAKE_TOOLCHAIN_FILE) | ||
| 2 | message(FATAL_ERROR "CMAKE_TOOLCHAIN_FILE required for android. See ${PROJECT_SOURCE_DIR}/README.md") | ||
| 3 | endif() | ||
| 4 | |||
| 5 | set(ARCH_DEFINES -DTARGET_POSIX -DTARGET_LINUX -D_LINUX -DTARGET_ANDROID) | ||
| 6 | set(SYSTEM_DEFINES -D__STDC_CONSTANT_MACROS -D_FILE_DEFINED | ||
| 7 | -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64) | ||
| 8 | set(PLATFORM_DIR linux) | ||
| 9 | if(WITH_ARCH) | ||
| 10 | set(ARCH ${WITH_ARCH}) | ||
| 11 | else() | ||
| 12 | if(CPU STREQUAL armeabi-v7a) | ||
| 13 | set(ARCH arm-linux-androideabi) | ||
| 14 | elseif(CPU STREQUAL i686) | ||
| 15 | set(ARCH i686-linux-android) | ||
| 16 | else() | ||
| 17 | message(SEND_ERROR "Unknown CPU: ${CPU}") | ||
| 18 | endif() | ||
| 19 | endif() | ||
| 20 | |||
| 21 | set(FFMPEG_OPTS --enable-cross-compile --cpu=cortex-a9 --arch=arm --target-os=linux --enable-neon | ||
| 22 | --disable-vdpau --cc=${CMAKE_C_COMPILER} --host-cc=${CMAKE_C_COMPILER} | ||
| 23 | --strip=${CMAKE_STRIP}) | ||
| 24 | set(ENABLE_SDL OFF) | ||
| 25 | set(ENABLE_X11 OFF) | ||
| 26 | set(ENABLE_EGL ON) | ||
| 27 | set(ENABLE_AML ON) | ||
| 28 | set(ENABLE_OPTICAL OFF) | ||
| 29 | |||
| 30 | list(APPEND DEPLIBS android log jnigraphics) | ||
diff --git a/project/cmake/scripts/android/install.cmake b/project/cmake/scripts/android/install.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/project/cmake/scripts/android/install.cmake | |||
diff --git a/project/cmake/scripts/android/macros.cmake b/project/cmake/scripts/android/macros.cmake new file mode 120000 index 0000000..28c77ca --- /dev/null +++ b/project/cmake/scripts/android/macros.cmake | |||
| @@ -0,0 +1 @@ | |||
| ../linux/macros.cmake \ No newline at end of file | |||
diff --git a/project/cmake/scripts/android/pathsetup.cmake b/project/cmake/scripts/android/pathsetup.cmake new file mode 120000 index 0000000..26d7f17 --- /dev/null +++ b/project/cmake/scripts/android/pathsetup.cmake | |||
| @@ -0,0 +1 @@ | |||
| ../linux/pathsetup.cmake \ No newline at end of file | |||
diff --git a/project/cmake/scripts/common/addon-helpers.cmake b/project/cmake/scripts/common/addon-helpers.cmake index b94df2a..9541df4 100644 --- a/project/cmake/scripts/common/addon-helpers.cmake +++ b/project/cmake/scripts/common/addon-helpers.cmake | |||
| @@ -10,13 +10,23 @@ add_custom_target(addon-package | |||
| 10 | COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target package) | 10 | COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target package) |
| 11 | 11 | ||
| 12 | macro(add_cpack_workaround target version ext) | 12 | macro(add_cpack_workaround target version ext) |
| 13 | if(NOT PACKAGE_DIR) | ||
| 14 | set(PACKAGE_DIR "${CMAKE_INSTALL_PREFIX}/zips") | ||
| 15 | endif() | ||
| 16 | |||
| 13 | add_custom_command(TARGET addon-package PRE_BUILD | 17 | add_custom_command(TARGET addon-package PRE_BUILD |
| 14 | COMMAND ${CMAKE_COMMAND} -E rename addon-${target}-${version}.${ext} ${target}-${version}.${ext}) | 18 | COMMAND ${CMAKE_COMMAND} -E make_directory ${PACKAGE_DIR} |
| 19 | COMMAND ${CMAKE_COMMAND} -E copy ${CPACK_PACKAGE_DIRECTORY}/addon-${target}-${version}.${ext} ${PACKAGE_DIR}/${target}-${version}.${ext}) | ||
| 15 | endmacro() | 20 | endmacro() |
| 16 | 21 | ||
| 17 | # Grab the version from a given add-on's addon.xml | 22 | # Grab the version from a given add-on's addon.xml |
| 18 | macro (addon_version dir prefix) | 23 | macro (addon_version dir prefix) |
| 19 | FILE(READ ${dir}/addon.xml ADDONXML) | 24 | IF(EXISTS ${PROJECT_SOURCE_DIR}/${dir}/addon.xml.in) |
| 25 | FILE(READ ${PROJECT_SOURCE_DIR}/${dir}/addon.xml.in ADDONXML) | ||
| 26 | ELSE() | ||
| 27 | FILE(READ ${dir}/addon.xml ADDONXML) | ||
| 28 | ENDIF() | ||
| 29 | |||
| 20 | STRING(REGEX MATCH "<addon[^>]*version.?=.?.[0-9\\.]+" VERSION_STRING ${ADDONXML}) | 30 | STRING(REGEX MATCH "<addon[^>]*version.?=.?.[0-9\\.]+" VERSION_STRING ${ADDONXML}) |
| 21 | STRING(REGEX REPLACE ".*version=.([0-9\\.]+).*" "\\1" ${prefix}_VERSION ${VERSION_STRING}) | 31 | STRING(REGEX REPLACE ".*version=.([0-9\\.]+).*" "\\1" ${prefix}_VERSION ${VERSION_STRING}) |
| 22 | message(STATUS ${prefix}_VERSION=${${prefix}_VERSION}) | 32 | message(STATUS ${prefix}_VERSION=${${prefix}_VERSION}) |
| @@ -34,6 +44,25 @@ macro (build_addon target prefix libs) | |||
| 34 | SET_TARGET_PROPERTIES(${target} PROPERTIES PREFIX "lib") | 44 | SET_TARGET_PROPERTIES(${target} PROPERTIES PREFIX "lib") |
| 35 | ENDIF(OS STREQUAL "android") | 45 | ENDIF(OS STREQUAL "android") |
| 36 | 46 | ||
| 47 | # get the library's location | ||
| 48 | SET(LIBRARY_LOCATION $<TARGET_FILE:${target}>) | ||
| 49 | # get the library's filename | ||
| 50 | if("${CORE_SYSTEM_NAME}" STREQUAL "android") | ||
| 51 | # for android we need the filename without any version numbers | ||
| 52 | set(LIBRARY_FILENAME $<TARGET_LINKER_FILE_NAME:${target}>) | ||
| 53 | else() | ||
| 54 | SET(LIBRARY_FILENAME $<TARGET_FILE_NAME:${target}>) | ||
| 55 | endif() | ||
| 56 | |||
| 57 | # if there's an addon.xml.in we need to generate the addon.xml | ||
| 58 | IF(EXISTS ${PROJECT_SOURCE_DIR}/${target}/addon.xml.in) | ||
| 59 | SET(PLATFORM ${CORE_SYSTEM_NAME}) | ||
| 60 | |||
| 61 | FILE(READ ${PROJECT_SOURCE_DIR}/${target}/addon.xml.in addon_file) | ||
| 62 | STRING(CONFIGURE "${addon_file}" addon_file_conf @ONLY) | ||
| 63 | FILE(GENERATE OUTPUT ${PROJECT_SOURCE_DIR}/${target}/addon.xml CONTENT "${addon_file_conf}") | ||
| 64 | ENDIF() | ||
| 65 | |||
| 37 | # set zip as default if addon-package is called without PACKAGE_XXX | 66 | # set zip as default if addon-package is called without PACKAGE_XXX |
| 38 | SET(CPACK_GENERATOR "ZIP") | 67 | SET(CPACK_GENERATOR "ZIP") |
| 39 | SET(ext "zip") | 68 | SET(ext "zip") |
| @@ -51,33 +80,62 @@ macro (build_addon target prefix libs) | |||
| 51 | set(CPACK_COMPONENTS_IGNORE_GROUPS 1) | 80 | set(CPACK_COMPONENTS_IGNORE_GROUPS 1) |
| 52 | list(APPEND CPACK_COMPONENTS_ALL ${target}-${${prefix}_VERSION}) | 81 | list(APPEND CPACK_COMPONENTS_ALL ${target}-${${prefix}_VERSION}) |
| 53 | # Pack files together to create an archive | 82 | # Pack files together to create an archive |
| 54 | INSTALL(DIRECTORY ${target} DESTINATION ./ COMPONENT ${target}-${${prefix}_VERSION}) | 83 | INSTALL(DIRECTORY ${target} DESTINATION ./ COMPONENT ${target}-${${prefix}_VERSION} PATTERN "addon.xml.in" EXCLUDE) |
| 55 | IF(WIN32) | 84 | IF(WIN32) |
| 56 | # get the installation location for the addon's target | 85 | if(NOT CPACK_PACKAGE_DIRECTORY) |
| 57 | get_property(dll_location TARGET ${target} PROPERTY LOCATION) | 86 | # determine the temporary path |
| 87 | file(TO_CMAKE_PATH "$ENV{TEMP}" WIN32_TEMP_PATH) | ||
| 88 | string(LENGTH "${WIN32_TEMP_PATH}" WIN32_TEMP_PATH_LENGTH) | ||
| 89 | string(LENGTH "${PROJECT_BINARY_DIR}" PROJECT_BINARY_DIR_LENGTH) | ||
| 90 | |||
| 91 | # check if the temporary path is shorter than the default packaging directory path | ||
| 92 | if(WIN32_TEMP_PATH_LENGTH GREATER 0 AND WIN32_TEMP_PATH_LENGTH LESS PROJECT_BINARY_DIR_LENGTH) | ||
| 93 | # set the directory used by CPack for packaging to the temp directory | ||
| 94 | set(CPACK_PACKAGE_DIRECTORY ${WIN32_TEMP_PATH}) | ||
| 95 | endif() | ||
| 96 | endif() | ||
| 97 | |||
| 58 | # in case of a VC++ project the installation location contains a $(Configuration) VS variable | 98 | # in case of a VC++ project the installation location contains a $(Configuration) VS variable |
| 59 | # we replace it with ${CMAKE_BUILD_TYPE} (which doesn't cover the case when the build configuration | 99 | # we replace it with ${CMAKE_BUILD_TYPE} (which doesn't cover the case when the build configuration |
| 60 | # is changed within Visual Studio) | 100 | # is changed within Visual Studio) |
| 61 | string(REPLACE "$(Configuration)" "${CMAKE_BUILD_TYPE}" dll_location "${dll_location}") | 101 | string(REPLACE "$(Configuration)" "${CMAKE_BUILD_TYPE}" LIBRARY_LOCATION "${LIBRARY_LOCATION}") |
| 62 | 102 | ||
| 63 | # install the generated DLL file | 103 | # install the generated DLL file |
| 64 | INSTALL(PROGRAMS ${dll_location} DESTINATION ${target} | 104 | INSTALL(PROGRAMS ${LIBRARY_LOCATION} DESTINATION ${target} |
| 65 | COMPONENT ${target}-${${prefix}_VERSION}) | 105 | COMPONENT ${target}-${${prefix}_VERSION}) |
| 66 | 106 | ||
| 67 | IF(CMAKE_BUILD_TYPE MATCHES Debug) | 107 | IF(CMAKE_BUILD_TYPE MATCHES Debug) |
| 68 | # for debug builds also install the PDB file | 108 | # for debug builds also install the PDB file |
| 69 | get_filename_component(dll_directory ${dll_location} DIRECTORY) | 109 | get_filename_component(LIBRARY_DIR ${LIBRARY_LOCATION} DIRECTORY) |
| 70 | INSTALL(FILES ${dll_directory}/${target}.pdb DESTINATION ${target} | 110 | INSTALL(FILES ${LIBRARY_DIR}/${target}.pdb DESTINATION ${target} |
| 71 | COMPONENT ${target}-${${prefix}_VERSION}) | 111 | COMPONENT ${target}-${${prefix}_VERSION}) |
| 72 | ENDIF() | 112 | ENDIF() |
| 73 | ELSE(WIN32) | 113 | ELSE(WIN32) |
| 114 | if(NOT CPACK_PACKAGE_DIRECTORY) | ||
| 115 | set(CPACK_PACKAGE_DIRECTORY ${CMAKE_BINARY_DIR}) | ||
| 116 | endif() | ||
| 74 | INSTALL(TARGETS ${target} DESTINATION ${target} | 117 | INSTALL(TARGETS ${target} DESTINATION ${target} |
| 75 | COMPONENT ${target}-${${prefix}_VERSION}) | 118 | COMPONENT ${target}-${${prefix}_VERSION}) |
| 76 | ENDIF(WIN32) | 119 | ENDIF(WIN32) |
| 77 | add_cpack_workaround(${target} ${${prefix}_VERSION} ${ext}) | 120 | add_cpack_workaround(${target} ${${prefix}_VERSION} ${ext}) |
| 78 | ELSE(PACKAGE_ZIP OR PACKAGE_TGZ) | 121 | ELSE(PACKAGE_ZIP OR PACKAGE_TGZ) |
| 79 | INSTALL(TARGETS ${target} DESTINATION lib/kodi/addons/${target}) | 122 | if(CMAKE_SYSTEM_NAME STREQUAL "Linux") |
| 80 | INSTALL(DIRECTORY ${target} DESTINATION share/kodi/addons) | 123 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR NOT CMAKE_INSTALL_PREFIX) |
| 124 | message(STATUS "setting install paths to match ${APP_NAME}: CMAKE_INSTALL_PREFIX: ${${APP_NAME_UC}_PREFIX}") | ||
| 125 | set(CMAKE_INSTALL_PREFIX "${${APP_NAME_UC}_PREFIX}" CACHE PATH "${APP_NAME} install prefix" FORCE) | ||
| 126 | set(CMAKE_INSTALL_LIBDIR "${${APP_NAME_UC}_LIB_DIR}" CACHE PATH "${APP_NAME} install libdir" FORCE) | ||
| 127 | elseif(NOT CMAKE_INSTALL_PREFIX STREQUAL "${${APP_NAME_UC}_PREFIX}" AND NOT OVERRIDE_PATHS) | ||
| 128 | message(FATAL_ERROR "CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} differs from ${APP_NAME} prefix ${${APP_NAME_UC}_PREFIX}. Please pass -DOVERRIDE_PATHS=1 to skip this check") | ||
| 129 | else() | ||
| 130 | if(NOT CMAKE_INSTALL_LIBDIR) | ||
| 131 | set(CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_PREFIX}/lib/${APP_NAME_LC}") | ||
| 132 | endif() | ||
| 133 | endif() | ||
| 134 | else() | ||
| 135 | set(CMAKE_INSTALL_LIBDIR "lib/${APP_NAME_LC}") | ||
| 136 | endif() | ||
| 137 | INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/addons/${target}) | ||
| 138 | INSTALL(DIRECTORY ${target} DESTINATION share/${APP_NAME_LC}/addons PATTERN "addon.xml.in" EXCLUDE) | ||
| 81 | ENDIF(PACKAGE_ZIP OR PACKAGE_TGZ) | 139 | ENDIF(PACKAGE_ZIP OR PACKAGE_TGZ) |
| 82 | endmacro() | 140 | endmacro() |
| 83 | 141 | ||
diff --git a/project/cmake/scripts/common/archsetup.cmake b/project/cmake/scripts/common/archsetup.cmake new file mode 100644 index 0000000..dff5558 --- /dev/null +++ b/project/cmake/scripts/common/archsetup.cmake | |||
| @@ -0,0 +1,99 @@ | |||
| 1 | # This script configures the build for a given architecture. | ||
| 2 | # Flags and stringified arch is set up. | ||
| 3 | # General compiler tests belongs here. | ||
| 4 | # | ||
| 5 | # On return, the following variables are set: | ||
| 6 | # CMAKE_SYSTEM_NAME - a lowercased system name | ||
| 7 | # CPU - the CPU on the target | ||
| 8 | # ARCH - the system architecture | ||
| 9 | # ARCH_DEFINES - list of compiler definitions for this architecture | ||
| 10 | # SYSTEM_DEFINES - list of compiler definitions for this system | ||
| 11 | # DEP_DEFINES - compiler definitions for system dependencies (e.g. LIRC) | ||
| 12 | # + the results of compiler tests etc. | ||
| 13 | |||
| 14 | include(CheckCXXSourceCompiles) | ||
| 15 | include(CheckSymbolExists) | ||
| 16 | include(CheckFunctionExists) | ||
| 17 | |||
| 18 | # Macro to check if a given type exists in a given header | ||
| 19 | # Arguments: | ||
| 20 | # header the header to check | ||
| 21 | # type the type to check for existence | ||
| 22 | # var the compiler definition to set if type exists | ||
| 23 | # On return: | ||
| 24 | # If type was found, the definition is added to SYSTEM_DEFINES | ||
| 25 | macro(check_type header type var) | ||
| 26 | check_cxx_source_compiles("#include <${header}> | ||
| 27 | int main() | ||
| 28 | { | ||
| 29 | ${type} s; | ||
| 30 | }" ${var}) | ||
| 31 | if(${var}) | ||
| 32 | list(APPEND SYSTEM_DEFINES -D${var}=1) | ||
| 33 | endif() | ||
| 34 | endmacro() | ||
| 35 | |||
| 36 | # Macro to check if a given builtin function exists | ||
| 37 | # Arguments: | ||
| 38 | # func the function to check | ||
| 39 | # var the compiler definition to set if type exists | ||
| 40 | # On return: | ||
| 41 | # If type was found, the definition is added to SYSTEM_DEFINES | ||
| 42 | macro(check_builtin func var) | ||
| 43 | check_cxx_source_compiles(" | ||
| 44 | int main() | ||
| 45 | { | ||
| 46 | ${func}; | ||
| 47 | }" ${var}) | ||
| 48 | if(${var}) | ||
| 49 | list(APPEND SYSTEM_DEFINES -D${var}=1) | ||
| 50 | endif() | ||
| 51 | endmacro() | ||
| 52 | |||
| 53 | |||
| 54 | # -------- Main script --------- | ||
| 55 | message(STATUS "System type: ${CMAKE_SYSTEM_NAME}") | ||
| 56 | if(NOT CORE_SYSTEM_NAME) | ||
| 57 | string(TOLOWER ${CMAKE_SYSTEM_NAME} CORE_SYSTEM_NAME) | ||
| 58 | endif() | ||
| 59 | |||
| 60 | if(WITH_CPU) | ||
| 61 | set(CPU ${WITH_CPU}) | ||
| 62 | elseif(NOT CMAKE_TOOLCHAIN_FILE) | ||
| 63 | set(CPU ${CMAKE_SYSTEM_PROCESSOR}) | ||
| 64 | endif() | ||
| 65 | |||
| 66 | if(CMAKE_TOOLCHAIN_FILE) | ||
| 67 | if(NOT EXISTS "${CMAKE_TOOLCHAIN_FILE}") | ||
| 68 | message(FATAL_ERROR "Toolchain file ${CMAKE_TOOLCHAIN_FILE} does not exist.") | ||
| 69 | elseif(NOT DEPENDS_PATH OR NOT NATIVEPREFIX) | ||
| 70 | message(FATAL_ERROR "Toolchain did not define DEPENDS_PATH or NATIVEPREFIX. Possibly outdated depends.") | ||
| 71 | endif() | ||
| 72 | endif() | ||
| 73 | |||
| 74 | # Main cpp | ||
| 75 | set(CORE_MAIN_SOURCE ${CORE_SOURCE_DIR}/xbmc/platform/posix/main.cpp) | ||
| 76 | |||
| 77 | # system specific arch setup | ||
| 78 | include(${PROJECT_SOURCE_DIR}/scripts/${CORE_SYSTEM_NAME}/archsetup.cmake) | ||
| 79 | |||
| 80 | message(STATUS "Core system type: ${CORE_SYSTEM_NAME}") | ||
| 81 | message(STATUS "Platform: ${PLATFORM}") | ||
| 82 | message(STATUS "CPU: ${CPU}, ARCH: ${ARCH}") | ||
| 83 | |||
| 84 | check_type(string std::u16string HAVE_STD__U16_STRING) | ||
| 85 | check_type(string std::u32string HAVE_STD__U32_STRING) | ||
| 86 | check_type(string char16_t HAVE_CHAR16_T) | ||
| 87 | check_type(string char32_t HAVE_CHAR32_T) | ||
| 88 | check_type(stdint.h uint_least16_t HAVE_STDINT_H) | ||
| 89 | check_symbol_exists(posix_fadvise fcntl.h HAVE_POSIX_FADVISE) | ||
| 90 | check_builtin("long* temp=0; long ret=__sync_add_and_fetch(temp, 1)" HAS_BUILTIN_SYNC_ADD_AND_FETCH) | ||
| 91 | check_builtin("long* temp=0; long ret=__sync_sub_and_fetch(temp, 1)" HAS_BUILTIN_SYNC_SUB_AND_FETCH) | ||
| 92 | check_builtin("long* temp=0; long ret=__sync_val_compare_and_swap(temp, 1, 1)" HAS_BUILTIN_SYNC_VAL_COMPARE_AND_SWAP) | ||
| 93 | if(HAVE_POSIX_FADVISE) | ||
| 94 | list(APPEND SYSTEM_DEFINES -DHAVE_POSIX_FADVISE=1) | ||
| 95 | endif() | ||
| 96 | check_function_exists(localtime_r HAVE_LOCALTIME_R) | ||
| 97 | if(HAVE_LOCALTIME_R) | ||
| 98 | list(APPEND SYSTEM_DEFINES -DHAVE_LOCALTIME_R=1) | ||
| 99 | endif() | ||
diff --git a/project/cmake/scripts/common/checkcommits.cmake b/project/cmake/scripts/common/checkcommits.cmake new file mode 100644 index 0000000..304e623 --- /dev/null +++ b/project/cmake/scripts/common/checkcommits.cmake | |||
| @@ -0,0 +1,75 @@ | |||
| 1 | find_package(Git REQUIRED) | ||
| 2 | |||
| 3 | macro(sanity_check message) | ||
| 4 | if(status_code) | ||
| 5 | message(FATAL_ERROR "${message}") | ||
| 6 | endif() | ||
| 7 | endmacro() | ||
| 8 | |||
| 9 | # Check that there are no changes in working-tree | ||
| 10 | execute_process(COMMAND ${GIT_EXECUTABLE} diff --quiet | ||
| 11 | RESULT_VARIABLE status_code) | ||
| 12 | sanity_check("Cannot run with working tree changes. Commit, stash or drop them.") | ||
| 13 | |||
| 14 | # Setup base of tests | ||
| 15 | set(check_base $ENV{CHECK_BASE}) | ||
| 16 | if(NOT check_base) | ||
| 17 | set(check_base origin/master) | ||
| 18 | endif() | ||
| 19 | |||
| 20 | # Setup end of tests | ||
| 21 | set(check_head $ENV{CHECK_HEAD}) | ||
| 22 | if(NOT check_head) | ||
| 23 | set(check_head HEAD) | ||
| 24 | endif() | ||
| 25 | |||
| 26 | # Setup target to build | ||
| 27 | set(check_target $ENV{CHECK_TARGET}) | ||
| 28 | if(NOT check_target) | ||
| 29 | set(check_target check) | ||
| 30 | endif() | ||
| 31 | |||
| 32 | # Build threads | ||
| 33 | set(build_threads $ENV{CHECK_THREADS}) | ||
| 34 | if(NOT build_threads) | ||
| 35 | if(UNIX) | ||
| 36 | execute_process(COMMAND nproc | ||
| 37 | OUTPUT_VARIABLE build_threads) | ||
| 38 | string(REGEX REPLACE "(\r?\n)+$" "" build_threads "${build_threads}") | ||
| 39 | endif() | ||
| 40 | endif() | ||
| 41 | |||
| 42 | # Record current HEAD | ||
| 43 | execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD | ||
| 44 | OUTPUT_VARIABLE current_branch) | ||
| 45 | |||
| 46 | string(REGEX REPLACE "(\r?\n)+$" "" current_branch "${current_branch}") | ||
| 47 | |||
| 48 | # Grab revision list | ||
| 49 | execute_process(COMMAND ${GIT_EXECUTABLE} rev-list ${check_base}..${check_head} --reverse | ||
| 50 | OUTPUT_VARIABLE rev_list) | ||
| 51 | |||
| 52 | string(REPLACE "\n" ";" rev_list ${rev_list}) | ||
| 53 | foreach(rev ${rev_list}) | ||
| 54 | # Checkout | ||
| 55 | message("Testing revision ${rev}") | ||
| 56 | execute_process(COMMAND ${GIT_EXECUTABLE} checkout ${rev} | ||
| 57 | RESULT_VARIABLE status_code) | ||
| 58 | sanity_check("Failed to checkout ${rev}") | ||
| 59 | |||
| 60 | # Build | ||
| 61 | if(build_threads GREATER 2) | ||
| 62 | execute_process(COMMAND ${CMAKE_COMMAND} "--build" "${CMAKE_BINARY_DIR}" "--target" "${check_target}" "--use-stderr" "--" "-j${build_threads}" | ||
| 63 | RESULT_VARIABLE status_code) | ||
| 64 | else() | ||
| 65 | execute_process(COMMAND ${CMAKE_COMMAND} "--build" "${CMAKE_BINARY_DIR}" "--target" "${check_target}" "--use-stderr" | ||
| 66 | RESULT_VARIABLE status_code) | ||
| 67 | endif() | ||
| 68 | if(status_code) | ||
| 69 | execute_process(COMMAND ${GIT_EXECUTABLE} checkout ${current_branch}) | ||
| 70 | endif() | ||
| 71 | sanity_check("Failed to build target for revision ${rev}") | ||
| 72 | endforeach() | ||
| 73 | |||
| 74 | message("Everything checks out fine") | ||
| 75 | execute_process(COMMAND ${GIT_EXECUTABLE} checkout ${current_branch}) | ||
diff --git a/project/cmake/scripts/common/generateversionedfiles.cmake b/project/cmake/scripts/common/generateversionedfiles.cmake new file mode 100644 index 0000000..9a4080a --- /dev/null +++ b/project/cmake/scripts/common/generateversionedfiles.cmake | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | include(${CORE_SOURCE_DIR}/project/cmake/scripts/common/macros.cmake) | ||
| 2 | |||
| 3 | core_find_versions() | ||
| 4 | file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/addons/xbmc.addon) | ||
| 5 | file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/addons/kodi.guilib) | ||
| 6 | configure_file(${CORE_SOURCE_DIR}/addons/xbmc.addon/addon.xml.in | ||
| 7 | ${CMAKE_BINARY_DIR}/addons/xbmc.addon/addon.xml @ONLY) | ||
| 8 | configure_file(${CORE_SOURCE_DIR}/addons/kodi.guilib/addon.xml.in | ||
| 9 | ${CMAKE_BINARY_DIR}/addons/kodi.guilib/addon.xml @ONLY) | ||
| 10 | configure_file(${CORE_SOURCE_DIR}/xbmc/CompileInfo.cpp.in | ||
| 11 | ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/xbmc/CompileInfo.cpp @ONLY) | ||
| 12 | set(prefix ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}) | ||
| 13 | set(APP_LIBDIR ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/lib/kodi) | ||
diff --git a/project/cmake/scripts/common/generatorsetup.cmake b/project/cmake/scripts/common/generatorsetup.cmake new file mode 100644 index 0000000..75083ca --- /dev/null +++ b/project/cmake/scripts/common/generatorsetup.cmake | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | # Configure single-/multiconfiguration generators and variables | ||
| 2 | # | ||
| 3 | # CORE_BUILD_CONFIG that is set to | ||
| 4 | # - CMAKE_BUILD_TYPE for single configuration generators such as make, nmake | ||
| 5 | # - a variable that expands on build time to the current configuration for | ||
| 6 | # multi configuration generators such as VS or Xcode | ||
| 7 | if(CMAKE_CONFIGURATION_TYPES) | ||
| 8 | if(CMAKE_BUILD_TYPE) | ||
| 9 | message(FATAL_ERROR "CMAKE_BUILD_TYPE must not be defined for multi-configuration generators") | ||
| 10 | endif() | ||
| 11 | set(CORE_BUILD_CONFIG ${CMAKE_CFG_INTDIR}) | ||
| 12 | message(STATUS "Generator: Multi-configuration (${CMAKE_GENERATOR})") | ||
| 13 | else() | ||
| 14 | if(CMAKE_BUILD_TYPE) | ||
| 15 | set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} | ||
| 16 | CACHE STRING "Choose build type (${CMAKE_BUILD_TYPES})" FORCE) | ||
| 17 | else() | ||
| 18 | # Set default | ||
| 19 | set(CMAKE_BUILD_TYPE Release | ||
| 20 | CACHE STRING "Choose build type (${CMAKE_BUILD_TYPES})" FORCE) | ||
| 21 | endif() | ||
| 22 | set(CORE_BUILD_CONFIG ${CMAKE_BUILD_TYPE}) | ||
| 23 | message(STATUS "Generator: Single-configuration: ${CMAKE_BUILD_TYPE} (${CMAKE_GENERATOR})") | ||
| 24 | endif() | ||
diff --git a/project/cmake/scripts/common/macros.cmake b/project/cmake/scripts/common/macros.cmake new file mode 100644 index 0000000..dd2233b --- /dev/null +++ b/project/cmake/scripts/common/macros.cmake | |||
| @@ -0,0 +1,373 @@ | |||
| 1 | # This script holds the main functions used to construct the build system | ||
| 2 | |||
| 3 | # include system specific macros | ||
| 4 | include(${CORE_SOURCE_DIR}/project/cmake/scripts/${CORE_SYSTEM_NAME}/macros.cmake) | ||
| 5 | |||
| 6 | # Add a library, optionally as a dependency of the main application | ||
| 7 | # Arguments: | ||
| 8 | # name name of the library to add | ||
| 9 | # Optional Arguments: | ||
| 10 | # NO_MAIN_DEPENDS if specified, the library is not added to main depends | ||
| 11 | # Implicit arguments: | ||
| 12 | # SOURCES the sources of the library | ||
| 13 | # HEADERS the headers of the library (only for IDE support) | ||
| 14 | # OTHERS other library related files (only for IDE support) | ||
| 15 | # On return: | ||
| 16 | # Library will be built, optionally added to ${core_DEPENDS} | ||
| 17 | function(core_add_library name) | ||
| 18 | cmake_parse_arguments(arg "NO_MAIN_DEPENDS" "" "" ${ARGN}) | ||
| 19 | add_library(${name} STATIC ${SOURCES} ${HEADERS} ${OTHERS}) | ||
| 20 | set_target_properties(${name} PROPERTIES PREFIX "") | ||
| 21 | if(NOT arg_NO_MAIN_DEPENDS) | ||
| 22 | set(core_DEPENDS ${name} ${core_DEPENDS} CACHE STRING "" FORCE) | ||
| 23 | endif() | ||
| 24 | |||
| 25 | # Add precompiled headers to Kodi main libraries | ||
| 26 | if(WIN32 AND "${CMAKE_CURRENT_LIST_DIR}" MATCHES "^${CORE_SOURCE_DIR}/xbmc") | ||
| 27 | add_precompiled_header(${name} pch.h ${CORE_SOURCE_DIR}/xbmc/win32/pch.cpp | ||
| 28 | PCH_TARGET kodi) | ||
| 29 | endif() | ||
| 30 | |||
| 31 | # IDE support | ||
| 32 | if(CMAKE_GENERATOR MATCHES "Xcode") | ||
| 33 | file(RELATIVE_PATH parentfolder ${CORE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/..) | ||
| 34 | set_target_properties(${name} PROPERTIES FOLDER "${parentfolder}") | ||
| 35 | elseif(CMAKE_GENERATOR MATCHES "Visual Studio") | ||
| 36 | file(RELATIVE_PATH foldername ${CORE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) | ||
| 37 | set_target_properties(${name} PROPERTIES FOLDER "${foldername}") | ||
| 38 | source_group(" " REGULAR_EXPRESSION ".*") | ||
| 39 | endif() | ||
| 40 | endfunction() | ||
| 41 | |||
| 42 | # Add a test library, and add sources to list for gtest integration macros | ||
| 43 | function(core_add_test_library name) | ||
| 44 | core_add_library(${name} NO_MAIN_DEPENDS) | ||
| 45 | set_target_properties(${name} PROPERTIES EXCLUDE_FROM_ALL 1) | ||
| 46 | foreach(src ${SOURCES}) | ||
| 47 | set(test_sources ${CMAKE_CURRENT_SOURCE_DIR}/${src} ${test_sources} CACHE STRING "" FORCE) | ||
| 48 | endforeach() | ||
| 49 | set(test_archives ${test_archives} ${name} CACHE STRING "" FORCE) | ||
| 50 | endfunction() | ||
| 51 | |||
| 52 | # Add a data file to installation list with a mirror in build tree | ||
| 53 | # Arguments: | ||
| 54 | # file full path to file to mirror | ||
| 55 | # relative the relative base of file path in the build/install tree | ||
| 56 | # give another parameter to exclude from install target | ||
| 57 | # Implicit arguments: | ||
| 58 | # CORE_SOURCE_DIR - root of source tree | ||
| 59 | # On return: | ||
| 60 | # file is added to ${install_data} and mirrored in build tree | ||
| 61 | function(copy_file_to_buildtree file relative) | ||
| 62 | if(NOT WIN32) | ||
| 63 | string(REPLACE "\(" "\\(" file ${file}) | ||
| 64 | string(REPLACE "\)" "\\)" file ${file}) | ||
| 65 | endif() | ||
| 66 | string(REPLACE "${relative}/" "" outfile ${file}) | ||
| 67 | |||
| 68 | if(NOT TARGET export-files) | ||
| 69 | add_custom_target(export-files ALL COMMENT "Copying files into build tree") | ||
| 70 | endif() | ||
| 71 | if(NOT ${CORE_SOURCE_DIR} MATCHES ${CMAKE_BINARY_DIR}) | ||
| 72 | if(VERBOSE) | ||
| 73 | message(STATUS "copy_file_to_buildtree - copying file: ${file} -> ${CMAKE_CURRENT_BINARY_DIR}/${outfile}") | ||
| 74 | endif() | ||
| 75 | add_custom_command(TARGET export-files COMMAND ${CMAKE_COMMAND} -E copy_if_different "${file}" "${CMAKE_CURRENT_BINARY_DIR}/${outfile}") | ||
| 76 | endif() | ||
| 77 | if(NOT ARGN) | ||
| 78 | list(APPEND install_data ${outfile}) | ||
| 79 | set(install_data ${install_data} PARENT_SCOPE) | ||
| 80 | endif() | ||
| 81 | endfunction() | ||
| 82 | |||
| 83 | # add data files to installation list with a mirror in build tree. | ||
| 84 | # reads list of files to install from a given list of text files. | ||
| 85 | # Arguments: | ||
| 86 | # pattern globbing pattern for text files to read | ||
| 87 | # give another parameter to exclude from installation target | ||
| 88 | # Implicit arguments: | ||
| 89 | # CORE_SOURCE_DIR - root of source tree | ||
| 90 | # On return: | ||
| 91 | # files are added to ${install_data} and mirrored in build tree | ||
| 92 | function(copy_files_from_filelist_to_buildtree pattern) | ||
| 93 | foreach(arg ${ARGN}) | ||
| 94 | list(APPEND pattern ${arg}) | ||
| 95 | endforeach() | ||
| 96 | # copies files listed in text files to the buildtree | ||
| 97 | # Input: [glob pattern: filepattern] | ||
| 98 | list(SORT pattern) | ||
| 99 | if(VERBOSE) | ||
| 100 | message(STATUS "copy_files_from_filelist_to_buildtree - got pattern: ${pattern}") | ||
| 101 | endif() | ||
| 102 | foreach(pat ${pattern}) | ||
| 103 | file(GLOB filenames ${pat}) | ||
| 104 | foreach(filename ${filenames}) | ||
| 105 | string(STRIP ${filename} filename) | ||
| 106 | core_file_read_filtered(fstrings ${filename}) | ||
| 107 | foreach(dir ${fstrings}) | ||
| 108 | file(GLOB_RECURSE files RELATIVE ${CORE_SOURCE_DIR} ${CORE_SOURCE_DIR}/${dir}) | ||
| 109 | foreach(file ${files}) | ||
| 110 | if(ARGN) | ||
| 111 | copy_file_to_buildtree(${CORE_SOURCE_DIR}/${file} ${CORE_SOURCE_DIR} 1) | ||
| 112 | else() | ||
| 113 | copy_file_to_buildtree(${CORE_SOURCE_DIR}/${file} ${CORE_SOURCE_DIR}) | ||
| 114 | endif() | ||
| 115 | endforeach() | ||
| 116 | endforeach() | ||
| 117 | endforeach() | ||
| 118 | endforeach() | ||
| 119 | set(install_data ${install_data} PARENT_SCOPE) | ||
| 120 | endfunction() | ||
| 121 | |||
| 122 | # helper macro to set modified variables in parent scope | ||
| 123 | macro(export_dep) | ||
| 124 | set(SYSTEM_INCLUDES ${SYSTEM_INCLUDES} PARENT_SCOPE) | ||
| 125 | set(DEPLIBS ${DEPLIBS} PARENT_SCOPE) | ||
| 126 | set(DEP_DEFINES ${DEP_DEFINES} PARENT_SCOPE) | ||
| 127 | set(${depup}_FOUND ${${depup}_FOUND} PARENT_SCOPE) | ||
| 128 | mark_as_advanced(${depup}_LIBRARIES) | ||
| 129 | endmacro() | ||
| 130 | |||
| 131 | # add a required dependency of main application | ||
| 132 | # Arguments: | ||
| 133 | # dep name of find rule for dependency, used uppercased for variable prefix | ||
| 134 | # On return: | ||
| 135 | # dependency added to ${SYSTEM_INCLUDES}, ${DEPLIBS} and ${DEP_DEFINES} | ||
| 136 | function(core_require_dep dep) | ||
| 137 | find_package(${dep} REQUIRED) | ||
| 138 | string(TOUPPER ${dep} depup) | ||
| 139 | list(APPEND SYSTEM_INCLUDES ${${depup}_INCLUDE_DIRS}) | ||
| 140 | list(APPEND DEPLIBS ${${depup}_LIBRARIES}) | ||
| 141 | list(APPEND DEP_DEFINES ${${depup}_DEFINITIONS}) | ||
| 142 | export_dep() | ||
| 143 | endfunction() | ||
| 144 | |||
| 145 | # add a required dyloaded dependency of main application | ||
| 146 | # Arguments: | ||
| 147 | # dep name of find rule for dependency, used uppercased for variable prefix | ||
| 148 | # On return: | ||
| 149 | # dependency added to ${SYSTEM_INCLUDES}, ${dep}_SONAME is set up | ||
| 150 | function(core_require_dyload_dep dep) | ||
| 151 | find_package(${dep} REQUIRED) | ||
| 152 | string(TOUPPER ${dep} depup) | ||
| 153 | list(APPEND SYSTEM_INCLUDES ${${depup}_INCLUDE_DIRS}) | ||
| 154 | list(APPEND DEP_DEFINES ${${depup}_DEFINITIONS}) | ||
| 155 | find_soname(${depup} REQUIRED) | ||
| 156 | export_dep() | ||
| 157 | set(${depup}_SONAME ${${depup}_SONAME} PARENT_SCOPE) | ||
| 158 | endfunction() | ||
| 159 | |||
| 160 | # helper macro for optional deps | ||
| 161 | macro(setup_enable_switch) | ||
| 162 | string(TOUPPER ${dep} depup) | ||
| 163 | if (ARGV1) | ||
| 164 | set(enable_switch ${ARGV1}) | ||
| 165 | else() | ||
| 166 | set(enable_switch ENABLE_${depup}) | ||
| 167 | endif() | ||
| 168 | endmacro() | ||
| 169 | |||
| 170 | # add an optional dependency of main application | ||
| 171 | # Arguments: | ||
| 172 | # dep name of find rule for dependency, used uppercased for variable prefix | ||
| 173 | # On return: | ||
| 174 | # dependency optionally added to ${SYSTEM_INCLUDES}, ${DEPLIBS} and ${DEP_DEFINES} | ||
| 175 | function(core_optional_dep dep) | ||
| 176 | setup_enable_switch() | ||
| 177 | if(${enable_switch}) | ||
| 178 | find_package(${dep}) | ||
| 179 | if(${depup}_FOUND) | ||
| 180 | list(APPEND SYSTEM_INCLUDES ${${depup}_INCLUDE_DIRS}) | ||
| 181 | list(APPEND DEPLIBS ${${depup}_LIBRARIES}) | ||
| 182 | list(APPEND DEP_DEFINES ${${depup}_DEFINITIONS}) | ||
| 183 | set(final_message ${final_message} "${depup} enabled: Yes" PARENT_SCOPE) | ||
| 184 | export_dep() | ||
| 185 | else() | ||
| 186 | set(final_message ${final_message} "${depup} enabled: No" PARENT_SCOPE) | ||
| 187 | endif() | ||
| 188 | endif() | ||
| 189 | endfunction() | ||
| 190 | |||
| 191 | # add an optional dyloaded dependency of main application | ||
| 192 | # Arguments: | ||
| 193 | # dep name of find rule for dependency, used uppercased for variable prefix | ||
| 194 | # On return: | ||
| 195 | # dependency optionally added to ${SYSTEM_INCLUDES}, ${DEP_DEFINES}, ${dep}_SONAME is set up | ||
| 196 | function(core_optional_dyload_dep dep) | ||
| 197 | setup_enable_switch() | ||
| 198 | if(${enable_switch}) | ||
| 199 | find_package(${dep}) | ||
| 200 | if(${depup}_FOUND) | ||
| 201 | list(APPEND SYSTEM_INCLUDES ${${depup}_INCLUDE_DIRS}) | ||
| 202 | find_soname(${depup} REQUIRED) | ||
| 203 | list(APPEND DEP_DEFINES ${${depup}_DEFINITIONS}) | ||
| 204 | set(final_message ${final_message} "${depup} enabled: Yes" PARENT_SCOPE) | ||
| 205 | export_dep() | ||
| 206 | set(${depup}_SONAME ${${depup}_SONAME} PARENT_SCOPE) | ||
| 207 | endif() | ||
| 208 | endif() | ||
| 209 | endfunction() | ||
| 210 | |||
| 211 | function(core_file_read_filtered result filepattern) | ||
| 212 | # Reads STRINGS from text files | ||
| 213 | # with comments filtered out | ||
| 214 | # Result: [list: result] | ||
| 215 | # Input: [glob pattern: filepattern] | ||
| 216 | file(GLOB filenames ${filepattern}) | ||
| 217 | list(SORT filenames) | ||
| 218 | foreach(filename ${filenames}) | ||
| 219 | if(VERBOSE) | ||
| 220 | message(STATUS "core_file_read_filtered - filename: ${filename}") | ||
| 221 | endif() | ||
| 222 | file(STRINGS ${filename} fstrings REGEX "^[^#//]") | ||
| 223 | foreach(fstring ${fstrings}) | ||
| 224 | string(REGEX REPLACE "^(.*)#(.*)" "\\1" fstring ${fstring}) | ||
| 225 | string(REGEX REPLACE "//.*" "" fstring ${fstring}) | ||
| 226 | string(STRIP ${fstring} fstring) | ||
| 227 | list(APPEND filename_strings ${fstring}) | ||
| 228 | endforeach() | ||
| 229 | endforeach() | ||
| 230 | set(${result} ${filename_strings} PARENT_SCOPE) | ||
| 231 | endfunction() | ||
| 232 | |||
| 233 | function(core_add_subdirs_from_filelist files) | ||
| 234 | # Adds subdirectories from a sorted list of files | ||
| 235 | # Input: [list: filenames] [bool: sort] | ||
| 236 | foreach(arg ${ARGN}) | ||
| 237 | list(APPEND files ${arg}) | ||
| 238 | endforeach() | ||
| 239 | list(SORT files) | ||
| 240 | if(VERBOSE) | ||
| 241 | message(STATUS "core_add_subdirs_from_filelist - got pattern: ${files}") | ||
| 242 | endif() | ||
| 243 | foreach(filename ${files}) | ||
| 244 | string(STRIP ${filename} filename) | ||
| 245 | core_file_read_filtered(fstrings ${filename}) | ||
| 246 | foreach(subdir ${fstrings}) | ||
| 247 | STRING_SPLIT(subdir " " ${subdir}) | ||
| 248 | list(GET subdir 0 subdir_src) | ||
| 249 | list(GET subdir -1 subdir_dest) | ||
| 250 | if(VERBOSE) | ||
| 251 | message(STATUS " core_add_subdirs_from_filelist - adding subdir: ${CORE_SOURCE_DIR}${subdir_src} -> ${CORE_BUILD_DIR}/${subdir_dest}") | ||
| 252 | endif() | ||
| 253 | add_subdirectory(${CORE_SOURCE_DIR}/${subdir_src} ${CORE_BUILD_DIR}/${subdir_dest}) | ||
| 254 | endforeach() | ||
| 255 | endforeach() | ||
| 256 | endfunction() | ||
| 257 | |||
| 258 | macro(core_add_optional_subdirs_from_filelist pattern) | ||
| 259 | # Adds subdirectories from text files | ||
| 260 | # if the option(s) in the 3rd field are enabled | ||
| 261 | # Input: [glob pattern: filepattern] | ||
| 262 | foreach(arg ${ARGN}) | ||
| 263 | list(APPEND pattern ${arg}) | ||
| 264 | endforeach() | ||
| 265 | foreach(elem ${pattern}) | ||
| 266 | string(STRIP ${elem} elem) | ||
| 267 | list(APPEND filepattern ${elem}) | ||
| 268 | endforeach() | ||
| 269 | |||
| 270 | file(GLOB filenames ${filepattern}) | ||
| 271 | list(SORT filenames) | ||
| 272 | if(VERBOSE) | ||
| 273 | message(STATUS "core_add_optional_subdirs_from_filelist - got pattern: ${filenames}") | ||
| 274 | endif() | ||
| 275 | |||
| 276 | foreach(filename ${filenames}) | ||
| 277 | if(VERBOSE) | ||
| 278 | message(STATUS "core_add_optional_subdirs_from_filelist - reading file: ${filename}") | ||
| 279 | endif() | ||
| 280 | file(STRINGS ${filename} fstrings REGEX "^[^#//]") | ||
| 281 | foreach(line ${fstrings}) | ||
| 282 | string(REPLACE " " ";" line "${line}") | ||
| 283 | list(GET line 0 subdir_src) | ||
| 284 | list(GET line 1 subdir_dest) | ||
| 285 | list(GET line 3 opts) | ||
| 286 | foreach(opt ${opts}) | ||
| 287 | if(ENABLE_${opt}) | ||
| 288 | if(VERBOSE) | ||
| 289 | message(STATUS " core_add_optional_subdirs_from_filelist - adding subdir: ${CORE_SOURCE_DIR}${subdir_src} -> ${CORE_BUILD_DIR}/${subdir_dest}") | ||
| 290 | endif() | ||
| 291 | add_subdirectory(${CORE_SOURCE_DIR}/${subdir_src} ${CORE_BUILD_DIR}/${subdir_dest}) | ||
| 292 | else() | ||
| 293 | if(VERBOSE) | ||
| 294 | message(STATUS " core_add_optional_subdirs_from_filelist: OPTION ${opt} not enabled for ${subdir_src}, skipping subdir") | ||
| 295 | endif() | ||
| 296 | endif() | ||
| 297 | endforeach() | ||
| 298 | endforeach() | ||
| 299 | endforeach() | ||
| 300 | endmacro() | ||
| 301 | |||
| 302 | macro(today RESULT) | ||
| 303 | if (WIN32) | ||
| 304 | execute_process(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE ${RESULT}) | ||
| 305 | string(REGEX REPLACE "(..)/(..)/..(..).*" "\\1/\\2/\\3" ${RESULT} ${${RESULT}}) | ||
| 306 | elseif(UNIX) | ||
| 307 | execute_process(COMMAND date -u +%F | ||
| 308 | OUTPUT_VARIABLE ${RESULT}) | ||
| 309 | string(REGEX REPLACE "(..)/(..)/..(..).*" "\\1/\\2/\\3" ${RESULT} ${${RESULT}}) | ||
| 310 | else() | ||
| 311 | message(SEND_ERROR "date not implemented") | ||
| 312 | set(${RESULT} 000000) | ||
| 313 | endif() | ||
| 314 | string(REGEX REPLACE "(\r?\n)+$" "" ${RESULT} "${${RESULT}}") | ||
| 315 | endmacro() | ||
| 316 | |||
| 317 | function(core_find_git_rev) | ||
| 318 | if(EXISTS ${CORE_SOURCE_DIR}/VERSION) | ||
| 319 | file(STRINGS ${CORE_SOURCE_DIR}/VERSION VERSION_FILE) | ||
| 320 | string(SUBSTRING "${VERSION_FILE}" 1 16 GIT_REV) | ||
| 321 | else() | ||
| 322 | find_package(Git) | ||
| 323 | if(GIT_FOUND AND EXISTS ${CORE_SOURCE_DIR}/.git) | ||
| 324 | execute_process(COMMAND ${GIT_EXECUTABLE} diff-files --ignore-submodules --quiet -- | ||
| 325 | RESULT_VARIABLE status_code | ||
| 326 | WORKING_DIRECTORY ${CORE_SOURCE_DIR}) | ||
| 327 | if (NOT status_code) | ||
| 328 | execute_process(COMMAND ${GIT_EXECUTABLE} diff-index --cached --ignore-submodules --quiet HEAD -- | ||
| 329 | RESULT_VARIABLE status_code | ||
| 330 | WORKING_DIRECTORY ${CORE_SOURCE_DIR}) | ||
| 331 | endif() | ||
| 332 | today(DATE) | ||
| 333 | execute_process(COMMAND ${GIT_EXECUTABLE} --no-pager log --abbrev=7 -n 1 | ||
| 334 | --pretty=format:"%h-dirty" HEAD | ||
| 335 | OUTPUT_VARIABLE LOG_UNFORMATTED | ||
| 336 | WORKING_DIRECTORY ${CORE_SOURCE_DIR}) | ||
| 337 | string(SUBSTRING ${LOG_UNFORMATTED} 1 7 HASH) | ||
| 338 | else() | ||
| 339 | execute_process(COMMAND ${GIT_EXECUTABLE} --no-pager log --abbrev=7 -n 1 | ||
| 340 | --pretty=format:"%h %cd" HEAD | ||
| 341 | OUTPUT_VARIABLE LOG_UNFORMATTED | ||
| 342 | WORKING_DIRECTORY ${CORE_SOURCE_DIR}) | ||
| 343 | string(SUBSTRING ${LOG_UNFORMATTED} 1 7 HASH) | ||
| 344 | string(SUBSTRING ${LOG_UNFORMATTED} 9 10 DATE) | ||
| 345 | string(REPLACE "-" "" DATE ${DATE}) | ||
| 346 | endif() | ||
| 347 | set(GIT_REV "${DATE}-${HASH}") | ||
| 348 | endif() | ||
| 349 | if(GIT_REV) | ||
| 350 | set(APP_SCMID ${GIT_REV} PARENT_SCOPE) | ||
| 351 | endif() | ||
| 352 | endfunction() | ||
| 353 | |||
| 354 | macro(core_find_versions) | ||
| 355 | include(CMakeParseArguments) | ||
| 356 | core_file_read_filtered(version_list ${CORE_SOURCE_DIR}/version.txt) | ||
| 357 | string(REPLACE " " ";" version_list "${version_list}") | ||
| 358 | cmake_parse_arguments(APP "" "VERSION_MAJOR;VERSION_MINOR;VERSION_TAG;VERSION_CODE;ADDON_API;APP_NAME;COMPANY_NAME" "" ${version_list}) | ||
| 359 | |||
| 360 | set(APP_NAME ${APP_APP_NAME}) # inconsistency in upstream | ||
| 361 | string(TOLOWER ${APP_APP_NAME} APP_NAME_LC) | ||
| 362 | set(COMPANY_NAME ${APP_COMPANY_NAME}) | ||
| 363 | set(APP_VERSION ${APP_VERSION_MAJOR}.${APP_VERSION_MINOR}) | ||
| 364 | if(APP_VERSION_TAG) | ||
| 365 | set(APP_VERSION ${APP_VERSION}-${APP_VERSION_TAG}) | ||
| 366 | endif() | ||
| 367 | string(REPLACE "." "," FILE_VERSION ${APP_ADDON_API}.0) | ||
| 368 | string(TOLOWER ${APP_VERSION_TAG} APP_VERSION_TAG_LC) | ||
| 369 | file(STRINGS ${CORE_SOURCE_DIR}/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h guilib_version REGEX "^.*GUILIB_API_VERSION (.*)$") | ||
| 370 | string(REGEX REPLACE ".*\"(.*)\"" "\\1" guilib_version ${guilib_version}) | ||
| 371 | file(STRINGS ${CORE_SOURCE_DIR}/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h guilib_version_min REGEX "^.*GUILIB_MIN_API_VERSION (.*)$") | ||
| 372 | string(REGEX REPLACE ".*\"(.*)\"" "\\1" guilib_version_min ${guilib_version_min}) | ||
| 373 | endmacro() | ||
diff --git a/project/cmake/scripts/common/managestring.cmake b/project/cmake/scripts/common/managestring.cmake new file mode 100644 index 0000000..7321f4c --- /dev/null +++ b/project/cmake/scripts/common/managestring.cmake | |||
| @@ -0,0 +1,235 @@ | |||
| 1 | # - Collection of String utility macros. | ||
| 2 | # Defines the following macros: | ||
| 3 | # STRING_TRIM(var str [NOUNQUOTE]) | ||
| 4 | # - Trim a string by removing the leading and trailing spaces, | ||
| 5 | # just like STRING(STRIP ...) in CMake 2.6 and later. | ||
| 6 | # This macro is needed as CMake 2.4 does not support STRING(STRIP ..) | ||
| 7 | # This macro also remove quote and double quote marks around the string, | ||
| 8 | # unless NOUNQUOTE is defined. | ||
| 9 | # * Parameters: | ||
| 10 | # + var: A variable that stores the result. | ||
| 11 | # + str: A string. | ||
| 12 | # + NOUNQUOTE: (Optional) do not remove the double quote mark around the string. | ||
| 13 | # | ||
| 14 | # STRING_UNQUOTE(var str) | ||
| 15 | # - Remove double quote marks and quote marks around a string. | ||
| 16 | # If the string is not quoted, then it returns an empty string. | ||
| 17 | # * Parameters: | ||
| 18 | # + var: A variable that stores the result. | ||
| 19 | # + str: A string. | ||
| 20 | # | ||
| 21 | # STRING_JOIN(var delimiter str_list [str...]) | ||
| 22 | # - Concatenate strings, with delimiter inserted between strings. | ||
| 23 | # * Parameters: | ||
| 24 | # + var: A variable that stores the result. | ||
| 25 | # + str_list: A list of string. | ||
| 26 | # + str: (Optional) more string to be join. | ||
| 27 | # | ||
| 28 | # STRING_SPLIT(var delimiter str [NOESCAPE_SEMICOLON]) | ||
| 29 | # - Split a string into a list using a delimiter, which can be in 1 or more | ||
| 30 | # characters long. | ||
| 31 | # * Parameters: | ||
| 32 | # + var: A variable that stores the result. | ||
| 33 | # + delimiter: To separate a string. | ||
| 34 | # + str: A string. | ||
| 35 | # + NOESCAPE_SEMICOLON: (Optional) Do not escape semicolons. | ||
| 36 | # | ||
| 37 | |||
| 38 | IF(NOT DEFINED _MANAGE_STRING_CMAKE_) | ||
| 39 | SET(_MANAGE_STRING_CMAKE_ "DEFINED") | ||
| 40 | |||
| 41 | MACRO(STRING_TRIM var str) | ||
| 42 | SET(${var} "") | ||
| 43 | IF (NOT "${ARGN}" STREQUAL "NOUNQUOTE") | ||
| 44 | # Need not trim a quoted string. | ||
| 45 | STRING_UNQUOTE(_var "${str}") | ||
| 46 | IF(NOT _var STREQUAL "") | ||
| 47 | # String is quoted | ||
| 48 | SET(${var} "${_var}") | ||
| 49 | ENDIF(NOT _var STREQUAL "") | ||
| 50 | ENDIF(NOT "${ARGN}" STREQUAL "NOUNQUOTE") | ||
| 51 | |||
| 52 | IF(${var} STREQUAL "") | ||
| 53 | SET(_var_1 "${str}") | ||
| 54 | STRING(REGEX REPLACE "^[ \t\r\n]+" "" _var_2 "${str}" ) | ||
| 55 | STRING(REGEX REPLACE "[ \t\r\n]+$" "" _var_3 "${_var_2}" ) | ||
| 56 | SET(${var} "${_var_3}") | ||
| 57 | ENDIF(${var} STREQUAL "") | ||
| 58 | ENDMACRO(STRING_TRIM var str) | ||
| 59 | |||
| 60 | # Internal macro | ||
| 61 | # Variable cannot be escaped here, as variable is already substituted | ||
| 62 | # at the time it passes to this macro. | ||
| 63 | MACRO(STRING_ESCAPE var str) | ||
| 64 | # ';' and '\' are tricky, need to be encoded. | ||
| 65 | # '#' => '#H' | ||
| 66 | # '\' => '#B' | ||
| 67 | # ';' => '#S' | ||
| 68 | SET(_NOESCAPE_SEMICOLON "") | ||
| 69 | SET(_NOESCAPE_HASH "") | ||
| 70 | |||
| 71 | FOREACH(_arg ${ARGN}) | ||
| 72 | IF(${_arg} STREQUAL "NOESCAPE_SEMICOLON") | ||
| 73 | SET(_NOESCAPE_SEMICOLON "NOESCAPE_SEMICOLON") | ||
| 74 | ELSEIF(${_arg} STREQUAL "NOESCAPE_HASH") | ||
| 75 | SET(_NOESCAPE_HASH "NOESCAPE_HASH") | ||
| 76 | ENDIF(${_arg} STREQUAL "NOESCAPE_SEMICOLON") | ||
| 77 | ENDFOREACH(_arg) | ||
| 78 | |||
| 79 | IF(_NOESCAPE_HASH STREQUAL "") | ||
| 80 | STRING(REGEX REPLACE "#" "#H" _ret "${str}") | ||
| 81 | ELSE(_NOESCAPE_HASH STREQUAL "") | ||
| 82 | SET(_ret "${str}") | ||
| 83 | ENDIF(_NOESCAPE_HASH STREQUAL "") | ||
| 84 | |||
| 85 | STRING(REGEX REPLACE "\\\\" "#B" _ret "${_ret}") | ||
| 86 | IF(_NOESCAPE_SEMICOLON STREQUAL "") | ||
| 87 | STRING(REGEX REPLACE ";" "#S" _ret "${_ret}") | ||
| 88 | ENDIF(_NOESCAPE_SEMICOLON STREQUAL "") | ||
| 89 | SET(${var} "${_ret}") | ||
| 90 | ENDMACRO(STRING_ESCAPE var str) | ||
| 91 | |||
| 92 | MACRO(STRING_UNESCAPE var str) | ||
| 93 | # '#B' => '\' | ||
| 94 | # '#H' => '#' | ||
| 95 | # '#D' => '$' | ||
| 96 | # '#S' => ';' | ||
| 97 | SET(_ESCAPE_VARIABLE "") | ||
| 98 | SET(_NOESCAPE_SEMICOLON "") | ||
| 99 | SET(_ret "${str}") | ||
| 100 | FOREACH(_arg ${ARGN}) | ||
| 101 | IF(${_arg} STREQUAL "NOESCAPE_SEMICOLON") | ||
| 102 | SET(_NOESCAPE_SEMICOLON "NOESCAPE_SEMICOLON") | ||
| 103 | ELSEIF(${_arg} STREQUAL "ESCAPE_VARIABLE") | ||
| 104 | SET(_ESCAPE_VARIABLE "ESCAPE_VARIABLE") | ||
| 105 | STRING(REGEX REPLACE "#D" "$" _ret "${_ret}") | ||
| 106 | ENDIF(${_arg} STREQUAL "NOESCAPE_SEMICOLON") | ||
| 107 | ENDFOREACH(_arg) | ||
| 108 | |||
| 109 | STRING(REGEX REPLACE "#B" "\\\\" _ret "${_ret}") | ||
| 110 | IF(_NOESCAPE_SEMICOLON STREQUAL "") | ||
| 111 | # ';' => '#S' | ||
| 112 | STRING(REGEX REPLACE "#S" "\\\\;" _ret "${_ret}") | ||
| 113 | ELSE(_NOESCAPE_SEMICOLON STREQUAL "") | ||
| 114 | STRING(REGEX REPLACE "#S" ";" _ret "${_ret}") | ||
| 115 | ENDIF(_NOESCAPE_SEMICOLON STREQUAL "") | ||
| 116 | |||
| 117 | IF(NOT _ESCAPE_VARIABLE STREQUAL "") | ||
| 118 | # '#D' => '$' | ||
| 119 | STRING(REGEX REPLACE "#D" "$" _ret "${_ret}") | ||
| 120 | ENDIF(NOT _ESCAPE_VARIABLE STREQUAL "") | ||
| 121 | STRING(REGEX REPLACE "#H" "#" _ret "${_ret}") | ||
| 122 | SET(${var} "${_ret}") | ||
| 123 | ENDMACRO(STRING_UNESCAPE var str) | ||
| 124 | |||
| 125 | |||
| 126 | MACRO(STRING_UNQUOTE var str) | ||
| 127 | STRING_ESCAPE(_ret "${str}" ${ARGN}) | ||
| 128 | IF(_ret MATCHES "^[ \t\r\n]+") | ||
| 129 | STRING(REGEX REPLACE "^[ \t\r\n]+" "" _ret "${_ret}") | ||
| 130 | ENDIF(_ret MATCHES "^[ \t\r\n]+") | ||
| 131 | IF(_ret MATCHES "^\"") | ||
| 132 | # Double quote | ||
| 133 | STRING(REGEX REPLACE "\"\(.*\)\"[ \t\r\n]*$" "\\1" _ret "${_ret}") | ||
| 134 | ELSEIF(_ret MATCHES "^'") | ||
| 135 | # Single quote | ||
| 136 | STRING(REGEX REPLACE "'\(.*\)'[ \t\r\n]*$" "\\1" _ret "${_ret}") | ||
| 137 | ELSE(_ret MATCHES "^\"") | ||
| 138 | SET(_ret "") | ||
| 139 | ENDIF(_ret MATCHES "^\"") | ||
| 140 | |||
| 141 | # Unencoding | ||
| 142 | STRING_UNESCAPE(${var} "${_ret}" ${ARGN}) | ||
| 143 | ENDMACRO(STRING_UNQUOTE var str) | ||
| 144 | |||
| 145 | MACRO(STRING_JOIN var delimiter str_list) | ||
| 146 | SET(_ret "") | ||
| 147 | FOREACH(_str ${str_list}) | ||
| 148 | IF(_ret STREQUAL "") | ||
| 149 | SET(_ret "${_str}") | ||
| 150 | ELSE(_ret STREQUAL "") | ||
| 151 | SET(_ret "${_ret}${delimiter}${_str}") | ||
| 152 | ENDIF(_ret STREQUAL "") | ||
| 153 | ENDFOREACH(_str ${str_list}) | ||
| 154 | |||
| 155 | FOREACH(_str ${ARGN}) | ||
| 156 | IF(_ret STREQUAL "") | ||
| 157 | SET(_ret "${_str}") | ||
| 158 | ELSE(_ret STREQUAL "") | ||
| 159 | SET(_ret "${_ret}${delimiter}${_str}") | ||
| 160 | ENDIF(_ret STREQUAL "") | ||
| 161 | ENDFOREACH(_str ${str_list}) | ||
| 162 | SET(${var} "${_ret}") | ||
| 163 | ENDMACRO(STRING_JOIN var delimiter str_list) | ||
| 164 | |||
| 165 | MACRO(STRING_SPLIT var delimiter str) | ||
| 166 | SET(_max_tokens "") | ||
| 167 | SET(_NOESCAPE_SEMICOLON "") | ||
| 168 | SET(_ESCAPE_VARIABLE "") | ||
| 169 | FOREACH(_arg ${ARGN}) | ||
| 170 | IF(${_arg} STREQUAL "NOESCAPE_SEMICOLON") | ||
| 171 | SET(_NOESCAPE_SEMICOLON "NOESCAPE_SEMICOLON") | ||
| 172 | ELSEIF(${_arg} STREQUAL "ESCAPE_VARIABLE") | ||
| 173 | SET(_ESCAPE_VARIABLE "ESCAPE_VARIABLE") | ||
| 174 | ELSE(${_arg} STREQUAL "NOESCAPE_SEMICOLON") | ||
| 175 | SET(_max_tokens ${_arg}) | ||
| 176 | ENDIF(${_arg} STREQUAL "NOESCAPE_SEMICOLON") | ||
| 177 | ENDFOREACH(_arg) | ||
| 178 | |||
| 179 | IF(NOT _max_tokens) | ||
| 180 | SET(_max_tokens -1) | ||
| 181 | ENDIF(NOT _max_tokens) | ||
| 182 | |||
| 183 | STRING_ESCAPE(_str "${str}" ${_NOESCAPE_SEMICOLON} ${_ESCAPE_VARIABLE}) | ||
| 184 | STRING_ESCAPE(_delimiter "${delimiter}" ${_NOESCAPE_SEMICOLON} ${_ESCAPE_VARIABLE}) | ||
| 185 | |||
| 186 | SET(_str_list "") | ||
| 187 | SET(_token_count 0) | ||
| 188 | STRING(LENGTH "${_delimiter}" _de_len) | ||
| 189 | |||
| 190 | WHILE(NOT _token_count EQUAL _max_tokens) | ||
| 191 | MATH(EXPR _token_count ${_token_count}+1) | ||
| 192 | IF(_token_count EQUAL _max_tokens) | ||
| 193 | # Last token, no need splitting | ||
| 194 | SET(_str_list ${_str_list} "${_str}") | ||
| 195 | ELSE(_token_count EQUAL _max_tokens) | ||
| 196 | # in case encoded characters are delimiters | ||
| 197 | STRING(LENGTH "${_str}" _str_len) | ||
| 198 | SET(_index 0) | ||
| 199 | SET(_token "") | ||
| 200 | SET(_str_remain "") | ||
| 201 | MATH(EXPR _str_end ${_str_len}-${_de_len}+1) | ||
| 202 | SET(_bound "k") | ||
| 203 | WHILE(_index LESS _str_end) | ||
| 204 | STRING(SUBSTRING "${_str}" ${_index} ${_de_len} _str_cursor) | ||
| 205 | IF(_str_cursor STREQUAL _delimiter) | ||
| 206 | # Get the token | ||
| 207 | STRING(SUBSTRING "${_str}" 0 ${_index} _token) | ||
| 208 | # Get the rest | ||
| 209 | MATH(EXPR _rest_index ${_index}+${_de_len}) | ||
| 210 | MATH(EXPR _rest_len ${_str_len}-${_index}-${_de_len}) | ||
| 211 | STRING(SUBSTRING "${_str}" ${_rest_index} ${_rest_len} _str_remain) | ||
| 212 | SET(_index ${_str_end}) | ||
| 213 | ELSE(_str_cursor STREQUAL _delimiter) | ||
| 214 | MATH(EXPR _index ${_index}+1) | ||
| 215 | ENDIF(_str_cursor STREQUAL _delimiter) | ||
| 216 | ENDWHILE(_index LESS _str_end) | ||
| 217 | |||
| 218 | IF(_str_remain STREQUAL "") | ||
| 219 | # Meaning: end of string | ||
| 220 | LIST(APPEND _str_list "${_str}") | ||
| 221 | SET(_max_tokens ${_token_count}) | ||
| 222 | ELSE(_str_remain STREQUAL "") | ||
| 223 | LIST(APPEND _str_list "${_token}") | ||
| 224 | SET(_str "${_str_remain}") | ||
| 225 | ENDIF(_str_remain STREQUAL "") | ||
| 226 | ENDIF(_token_count EQUAL _max_tokens) | ||
| 227 | ENDWHILE(NOT _token_count EQUAL _max_tokens) | ||
| 228 | |||
| 229 | |||
| 230 | # Unencoding | ||
| 231 | STRING_UNESCAPE(${var} "${_str_list}" ${_NOESCAPE_SEMICOLON} ${_ESCAPE_VARIABLE}) | ||
| 232 | ENDMACRO(STRING_SPLIT var delimiter str) | ||
| 233 | |||
| 234 | ENDIF(NOT DEFINED _MANAGE_STRING_CMAKE_) | ||
| 235 | |||
diff --git a/project/cmake/scripts/common/pathsetup.cmake b/project/cmake/scripts/common/pathsetup.cmake new file mode 100644 index 0000000..54b352d --- /dev/null +++ b/project/cmake/scripts/common/pathsetup.cmake | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | # This script configures installation paths | ||
| 2 | |||
| 3 | include(${PROJECT_SOURCE_DIR}/scripts/${CORE_SYSTEM_NAME}/pathsetup.cmake) | ||
diff --git a/project/cmake/scripts/common/prepare-env.cmake b/project/cmake/scripts/common/prepare-env.cmake index 3413c45..b9a39e7 100644 --- a/project/cmake/scripts/common/prepare-env.cmake +++ b/project/cmake/scripts/common/prepare-env.cmake | |||
| @@ -12,6 +12,8 @@ if(EXISTS "${APP_ROOT}/version.txt") | |||
| 12 | set(${name} "${value}") | 12 | set(${name} "${value}") |
| 13 | endif() | 13 | endif() |
| 14 | endforeach() | 14 | endforeach() |
| 15 | string(TOLOWER ${APP_NAME} APP_NAME_LC) | ||
| 16 | string(TOUPPER ${APP_NAME} APP_NAME_UC) | ||
| 15 | endif() | 17 | endif() |
| 16 | 18 | ||
| 17 | # bail if we can't parse versions | 19 | # bail if we can't parse versions |
| @@ -19,16 +21,21 @@ if(NOT DEFINED APP_VERSION_MAJOR OR NOT DEFINED APP_VERSION_MINOR) | |||
| 19 | message(FATAL_ERROR "Could not determine app version! make sure that ${APP_ROOT}/version.txt exists") | 21 | message(FATAL_ERROR "Could not determine app version! make sure that ${APP_ROOT}/version.txt exists") |
| 20 | endif() | 22 | endif() |
| 21 | 23 | ||
| 24 | # in case we need to download something, set KODI_MIRROR to the default if not alread set | ||
| 25 | if(NOT DEFINED KODI_MIRROR) | ||
| 26 | set(KODI_MIRROR "http://mirrors.kodi.tv") | ||
| 27 | endif() | ||
| 28 | |||
| 22 | ### copy all the addon binding header files to include/kodi | 29 | ### copy all the addon binding header files to include/kodi |
| 23 | # make sure include/kodi exists and is empty | 30 | # make sure include/kodi exists and is empty |
| 24 | set(KODI_LIB_DIR ${DEPENDS_PATH}/lib/kodi) | 31 | set(APP_LIB_DIR ${DEPENDS_PATH}/lib/${APP_NAME_LC}) |
| 25 | if(NOT EXISTS "${KODI_LIB_DIR}/") | 32 | if(NOT EXISTS "${APP_LIB_DIR}/") |
| 26 | file(MAKE_DIRECTORY ${KODI_LIB_DIR}) | 33 | file(MAKE_DIRECTORY ${APP_LIB_DIR}) |
| 27 | endif() | 34 | endif() |
| 28 | 35 | ||
| 29 | set(KODI_INCLUDE_DIR ${DEPENDS_PATH}/include/kodi) | 36 | set(APP_INCLUDE_DIR ${DEPENDS_PATH}/include/${APP_NAME_LC}) |
| 30 | if(NOT EXISTS "${KODI_INCLUDE_DIR}/") | 37 | if(NOT EXISTS "${APP_INCLUDE_DIR}/") |
| 31 | file(MAKE_DIRECTORY ${KODI_INCLUDE_DIR}) | 38 | file(MAKE_DIRECTORY ${APP_INCLUDE_DIR}) |
| 32 | endif() | 39 | endif() |
| 33 | 40 | ||
| 34 | # we still need XBMC_INCLUDE_DIR and XBMC_LIB_DIR for backwards compatibility to xbmc | 41 | # we still need XBMC_INCLUDE_DIR and XBMC_LIB_DIR for backwards compatibility to xbmc |
| @@ -49,13 +56,13 @@ if(NOT WIN32) | |||
| 49 | endif() | 56 | endif() |
| 50 | endif() | 57 | endif() |
| 51 | 58 | ||
| 52 | # kodi-config.cmake.in (further down) expects a "prefix" variable | ||
| 53 | get_filename_component(prefix "${DEPENDS_PATH}" ABSOLUTE) | ||
| 54 | |||
| 55 | # generate the proper kodi-config.cmake file | 59 | # generate the proper kodi-config.cmake file |
| 56 | configure_file(${APP_ROOT}/project/cmake/kodi-config.cmake.in ${KODI_LIB_DIR}/kodi-config.cmake @ONLY) | 60 | configure_file(${APP_ROOT}/project/cmake/kodi-config.cmake.in ${APP_LIB_DIR}/kodi-config.cmake @ONLY) |
| 61 | |||
| 57 | # copy cmake helpers to lib/kodi | 62 | # copy cmake helpers to lib/kodi |
| 58 | file(COPY ${APP_ROOT}/project/cmake/scripts/common/addon-helpers.cmake ${APP_ROOT}/project/cmake/scripts/common/addoptions.cmake DESTINATION ${KODI_LIB_DIR}) | 63 | file(COPY ${APP_ROOT}/project/cmake/scripts/common/addon-helpers.cmake |
| 64 | ${APP_ROOT}/project/cmake/scripts/common/addoptions.cmake | ||
| 65 | DESTINATION ${APP_LIB_DIR}) | ||
| 59 | 66 | ||
| 60 | # generate xbmc-config.cmake for backwards compatibility to xbmc | 67 | # generate xbmc-config.cmake for backwards compatibility to xbmc |
| 61 | configure_file(${APP_ROOT}/project/cmake/xbmc-config.cmake.in ${XBMC_LIB_DIR}/xbmc-config.cmake @ONLY) | 68 | configure_file(${APP_ROOT}/project/cmake/xbmc-config.cmake.in ${XBMC_LIB_DIR}/xbmc-config.cmake @ONLY) |
| @@ -69,7 +76,7 @@ foreach(binding ${bindings}) | |||
| 69 | string(REPLACE "+=" ";" binding "${binding}") | 76 | string(REPLACE "+=" ";" binding "${binding}") |
| 70 | list(GET binding 1 header) | 77 | list(GET binding 1 header) |
| 71 | # copy the header file to include/kodi | 78 | # copy the header file to include/kodi |
| 72 | file(COPY ${APP_ROOT}/${header} DESTINATION ${KODI_INCLUDE_DIR}) | 79 | file(COPY ${APP_ROOT}/${header} DESTINATION ${APP_INCLUDE_DIR}) |
| 73 | 80 | ||
| 74 | # auto-generate header files for backwards compatibility to xbmc with deprecation warning | 81 | # auto-generate header files for backwards compatibility to xbmc with deprecation warning |
| 75 | # but only do it if the file doesn't already exist | 82 | # but only do it if the file doesn't already exist |
| @@ -95,7 +102,7 @@ if(WIN32) | |||
| 95 | else() | 102 | else() |
| 96 | set(PATCH_ARCHIVE_NAME "patch-2.5.9-7-bin-1") | 103 | set(PATCH_ARCHIVE_NAME "patch-2.5.9-7-bin-1") |
| 97 | set(PATCH_ARCHIVE "${PATCH_ARCHIVE_NAME}.zip") | 104 | set(PATCH_ARCHIVE "${PATCH_ARCHIVE_NAME}.zip") |
| 98 | set(PATCH_URL "http://mirrors.xbmc.org/build-deps/win32/${PATCH_ARCHIVE}") | 105 | set(PATCH_URL "${KODI_MIRROR}/build-deps/win32/${PATCH_ARCHIVE}") |
| 99 | set(PATCH_DOWNLOAD ${BUILD_DIR}/download/${PATCH_ARCHIVE}) | 106 | set(PATCH_DOWNLOAD ${BUILD_DIR}/download/${PATCH_ARCHIVE}) |
| 100 | 107 | ||
| 101 | # download the archive containing patch.exe | 108 | # download the archive containing patch.exe |
diff --git a/project/cmake/scripts/common/projectmacros.cmake b/project/cmake/scripts/common/projectmacros.cmake new file mode 100644 index 0000000..d0739c4 --- /dev/null +++ b/project/cmake/scripts/common/projectmacros.cmake | |||
| @@ -0,0 +1,84 @@ | |||
| 1 | # This script holds macros which are project specific | ||
| 2 | |||
| 3 | # Pack a skin xbt file | ||
| 4 | # Arguments: | ||
| 5 | # input input directory to pack | ||
| 6 | # output ouput xbt file | ||
| 7 | # On return: | ||
| 8 | # xbt is added to ${XBT_FILES} | ||
| 9 | function(pack_xbt input output) | ||
| 10 | file(GLOB_RECURSE MEDIA_FILES ${input}/*) | ||
| 11 | get_filename_component(dir ${output} PATH) | ||
| 12 | add_custom_command(OUTPUT ${output} | ||
| 13 | COMMAND ${CMAKE_COMMAND} -E make_directory ${dir} | ||
| 14 | COMMAND TexturePacker::TexturePacker | ||
| 15 | ARGS -input ${input} | ||
| 16 | -output ${output} | ||
| 17 | -dupecheck | ||
| 18 | DEPENDS ${MEDIA_FILES}) | ||
| 19 | list(APPEND XBT_FILES ${output}) | ||
| 20 | set(XBT_FILES ${XBT_FILES} PARENT_SCOPE) | ||
| 21 | endfunction() | ||
| 22 | |||
| 23 | # Add a skin to installation list, mirroring it in build tree, packing textures | ||
| 24 | # Arguments: | ||
| 25 | # skin skin directory | ||
| 26 | # relative relative base path in build tree | ||
| 27 | # On return: | ||
| 28 | # xbt is added to ${XBT_FILES}, data added to ${install_data}, mirror in build tree | ||
| 29 | function(copy_skin_to_buildtree skin relative) | ||
| 30 | file(GLOB_RECURSE FILES ${skin}/*) | ||
| 31 | file(GLOB_RECURSE MEDIA_FILES ${skin}/media/*) | ||
| 32 | list(REMOVE_ITEM FILES ${MEDIA_FILES}) | ||
| 33 | foreach(file ${FILES}) | ||
| 34 | copy_file_to_buildtree(${file} ${relative}) | ||
| 35 | endforeach() | ||
| 36 | file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${dest}/media) | ||
| 37 | string(REPLACE "${relative}/" "" dest ${skin}) | ||
| 38 | pack_xbt(${skin}/media | ||
| 39 | ${CMAKE_BINARY_DIR}/${dest}/media/Textures.xbt | ||
| 40 | ${CMAKE_BINARY_DIR}) | ||
| 41 | |||
| 42 | set(XBT_FILES ${XBT_FILES} PARENT_SCOPE) | ||
| 43 | set(install_data ${install_data} PARENT_SCOPE) | ||
| 44 | endfunction() | ||
| 45 | |||
| 46 | # Get GTest tests as CMake tests. | ||
| 47 | # Copied from FindGTest.cmake | ||
| 48 | # Thanks to Daniel Blezek <blezek@gmail.com> for the GTEST_ADD_TESTS code | ||
| 49 | function(GTEST_ADD_TESTS executable extra_args) | ||
| 50 | if(NOT ARGN) | ||
| 51 | message(FATAL_ERROR "Missing ARGN: Read the documentation for GTEST_ADD_TESTS") | ||
| 52 | endif() | ||
| 53 | foreach(source ${ARGN}) | ||
| 54 | file(READ "${source}" contents) | ||
| 55 | string(REGEX MATCHALL "TEST_?[F]?\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents}) | ||
| 56 | foreach(hit ${found_tests}) | ||
| 57 | string(REGEX REPLACE ".*\\( *([A-Za-z_0-9]+), *([A-Za-z_0-9]+) *\\).*" "\\1.\\2" test_name ${hit}) | ||
| 58 | add_test(${test_name} ${executable} --gtest_filter=${test_name} ${extra_args}) | ||
| 59 | endforeach() | ||
| 60 | # Groups parametrized tests under a single ctest entry | ||
| 61 | string(REGEX MATCHALL "INSTANTIATE_TEST_CASE_P\\(([^,]+), *([^,]+)" found_tests2 ${contents}) | ||
| 62 | foreach(hit ${found_tests2}) | ||
| 63 | string(SUBSTRING ${hit} 24 -1 test_name) | ||
| 64 | string(REPLACE "," ";" test_name "${test_name}") | ||
| 65 | list(GET test_name 0 filter_name) | ||
| 66 | list(GET test_name 1 test_prefix) | ||
| 67 | string(STRIP ${test_prefix} test_prefix) | ||
| 68 | add_test(${test_prefix}.${filter_name} ${executable} --gtest_filter=${filter_name}* ${extra_args}) | ||
| 69 | endforeach() | ||
| 70 | endforeach() | ||
| 71 | endfunction() | ||
| 72 | |||
| 73 | function(whole_archive output) | ||
| 74 | if(CMAKE_CXX_COMPILER_ID STREQUAL GNU OR CMAKE_CXX_COMPILER_ID STREQUAL Clang) | ||
| 75 | set(${output} -Wl,--whole-archive ${ARGN} -Wl,--no-whole-archive PARENT_SCOPE) | ||
| 76 | elseif(CMAKE_CXX_COMPILER_ID STREQUAL AppleClang) | ||
| 77 | foreach(library ${ARGN}) | ||
| 78 | list(APPEND ${output} -Wl,-force_load ${library}) | ||
| 79 | set(${output} ${${output}} PARENT_SCOPE) | ||
| 80 | endforeach() | ||
| 81 | else() | ||
| 82 | set(${output} ${ARGN} PARENT_SCOPE) | ||
| 83 | endif() | ||
| 84 | endfunction() | ||
diff --git a/project/cmake/scripts/darwin/archsetup.cmake b/project/cmake/scripts/darwin/archsetup.cmake new file mode 100644 index 0000000..accb8ab --- /dev/null +++ b/project/cmake/scripts/darwin/archsetup.cmake | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | if(NOT CMAKE_TOOLCHAIN_FILE) | ||
| 2 | message(FATAL_ERROR "CMAKE_TOOLCHAIN_FILE required for darwin. See ${PROJECT_SOURCE_DIR}/README.md") | ||
| 3 | endif() | ||
| 4 | |||
| 5 | set(CORE_MAIN_SOURCE ${CORE_SOURCE_DIR}/xbmc/platform/posix/main.cpp | ||
| 6 | ${CORE_SOURCE_DIR}/xbmc/platform/darwin/osx/SDLMain.mm | ||
| 7 | ${CORE_SOURCE_DIR}/xbmc/platform/darwin/osx/SDLMain.h) | ||
| 8 | |||
| 9 | set(ARCH_DEFINES -D_LINUX -DTARGET_POSIX -DTARGET_DARWIN -DTARGET_DARWIN_OSX) | ||
| 10 | set(SYSTEM_DEFINES -D_REENTRANT -D_FILE_DEFINED -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE | ||
| 11 | -D__STDC_CONSTANT_MACROS) | ||
| 12 | set(PLATFORM_DIR linux) | ||
| 13 | set(CMAKE_SYSTEM_NAME Darwin) | ||
| 14 | if(WITH_ARCH) | ||
| 15 | set(ARCH ${WITH_ARCH}) | ||
| 16 | else() | ||
| 17 | if(CPU STREQUAL x86_64) | ||
| 18 | set(ARCH x86_64-apple-darwin) | ||
| 19 | elseif(CPU STREQUAL i386) | ||
| 20 | set(ARCH i386-apple-darwin) | ||
| 21 | else() | ||
| 22 | message(SEND_ERROR "Unknown CPU: ${CPU}") | ||
| 23 | endif() | ||
| 24 | endif() | ||
| 25 | |||
| 26 | find_package(CXX11 REQUIRED) | ||
| 27 | |||
| 28 | list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${NATIVEPREFIX}) | ||
| 29 | |||
| 30 | list(APPEND DEPLIBS "-framework DiskArbitration" "-framework IOKit" | ||
| 31 | "-framework IOSurface" "-framework SystemConfiguration" | ||
| 32 | "-framework ApplicationServices" "-framework AppKit" | ||
| 33 | "-framework CoreAudio" "-framework AudioToolbox" | ||
| 34 | "-framework CoreGraphics") | ||
diff --git a/project/cmake/scripts/darwin/install.cmake b/project/cmake/scripts/darwin/install.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/project/cmake/scripts/darwin/install.cmake | |||
diff --git a/project/cmake/scripts/darwin/macros.cmake b/project/cmake/scripts/darwin/macros.cmake new file mode 100644 index 0000000..4ee17c2 --- /dev/null +++ b/project/cmake/scripts/darwin/macros.cmake | |||
| @@ -0,0 +1,108 @@ | |||
| 1 | function(core_link_library lib wraplib) | ||
| 2 | if(CMAKE_GENERATOR MATCHES "Unix Makefiles") | ||
| 3 | set(wrapper_obj cores/dll-loader/exports/CMakeFiles/wrapper.dir/wrapper.c.o) | ||
| 4 | elseif(CMAKE_GENERATOR MATCHES "Xcode") | ||
| 5 | set(wrapper_obj cores/dll-loader/exports/kodi.build/$(CONFIGURATION)/wrapper.build/Objects-$(CURRENT_VARIANT)/$(CURRENT_ARCH)/wrapper.o) | ||
| 6 | else() | ||
| 7 | message(FATAL_ERROR "Unsupported generator in core_link_library") | ||
| 8 | endif() | ||
| 9 | |||
| 10 | set(export -bundle -undefined dynamic_lookup -read_only_relocs suppress | ||
| 11 | -Wl,-alias_list,${CORE_BUILD_DIR}/cores/dll-loader/exports/wrapper.def | ||
| 12 | ${CORE_BUILD_DIR}/${wrapper_obj}) | ||
| 13 | set(check_arg "") | ||
| 14 | if(TARGET ${lib}) | ||
| 15 | set(target ${lib}) | ||
| 16 | set(link_lib $<TARGET_FILE:${lib}>) | ||
| 17 | set(check_arg ${ARGV2}) | ||
| 18 | set(data_arg ${ARGV3}) | ||
| 19 | else() | ||
| 20 | set(target ${ARGV2}) | ||
| 21 | set(link_lib ${lib}) | ||
| 22 | set(check_arg ${ARGV3}) | ||
| 23 | set(data_arg ${ARGV4}) | ||
| 24 | endif() | ||
| 25 | if(check_arg STREQUAL export) | ||
| 26 | set(export ${export} | ||
| 27 | -Wl,--version-script=${ARGV3}) | ||
| 28 | elseif(check_arg STREQUAL nowrap) | ||
| 29 | set(export ${data_arg}) | ||
| 30 | elseif(check_arg STREQUAL extras) | ||
| 31 | foreach(arg ${data_arg}) | ||
| 32 | list(APPEND export ${arg}) | ||
| 33 | endforeach() | ||
| 34 | endif() | ||
| 35 | get_filename_component(dir ${wraplib} PATH) | ||
| 36 | |||
| 37 | # We can't simply pass the linker flags to the args section of the custom command | ||
| 38 | # because cmake will add quotes around it (and the linker will fail due to those). | ||
| 39 | # We need to do this handstand first ... | ||
| 40 | separate_arguments(CUSTOM_COMMAND_ARGS_LDFLAGS UNIX_COMMAND "${CMAKE_SHARED_LINKER_FLAGS}") | ||
| 41 | |||
| 42 | add_custom_command(OUTPUT ${wraplib}-${ARCH}${CMAKE_SHARED_MODULE_SUFFIX} | ||
| 43 | COMMAND ${CMAKE_COMMAND} -E make_directory ${dir} | ||
| 44 | COMMAND ${CMAKE_C_COMPILER} | ||
| 45 | ARGS ${CUSTOM_COMMAND_ARGS_LDFLAGS} ${export} -Wl,-force_load ${link_lib} | ||
| 46 | -o ${CMAKE_BINARY_DIR}/${wraplib}-${ARCH}${CMAKE_SHARED_MODULE_SUFFIX} | ||
| 47 | DEPENDS ${target} wrapper.def wrapper | ||
| 48 | VERBATIM) | ||
| 49 | |||
| 50 | # Uncomment to create wrap_<lib> targets for debugging | ||
| 51 | #get_filename_component(libname ${wraplib} NAME_WE) | ||
| 52 | #add_custom_target(wrap_${libname} ALL DEPENDS ${wraplib}-${ARCH}${CMAKE_SHARED_MODULE_SUFFIX}) | ||
| 53 | |||
| 54 | list(APPEND WRAP_FILES ${wraplib}-${ARCH}${CMAKE_SHARED_MODULE_SUFFIX}) | ||
| 55 | set(WRAP_FILES ${WRAP_FILES} PARENT_SCOPE) | ||
| 56 | endfunction() | ||
| 57 | |||
| 58 | function(find_soname lib) | ||
| 59 | cmake_parse_arguments(arg "REQUIRED" "" "" ${ARGN}) | ||
| 60 | |||
| 61 | string(TOLOWER ${lib} liblow) | ||
| 62 | if(${lib}_LDFLAGS) | ||
| 63 | set(link_lib "${${lib}_LDFLAGS}") | ||
| 64 | else() | ||
| 65 | set(link_lib "${${lib}_LIBRARIES}") | ||
| 66 | endif() | ||
| 67 | |||
| 68 | execute_process(COMMAND ${CMAKE_C_COMPILER} -print-search-dirs | ||
| 69 | COMMAND fgrep libraries: | ||
| 70 | COMMAND sed "s/[^=]*=\\(.*\\)/\\1/" | ||
| 71 | COMMAND sed "s/:/ /g" | ||
| 72 | ERROR_QUIET | ||
| 73 | OUTPUT_VARIABLE cc_lib_path | ||
| 74 | OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
| 75 | execute_process(COMMAND echo ${link_lib} | ||
| 76 | COMMAND sed "s/-L[ ]*//g" | ||
| 77 | COMMAND sed "s/-l[^ ]*//g" | ||
| 78 | ERROR_QUIET | ||
| 79 | OUTPUT_VARIABLE env_lib_path | ||
| 80 | OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
| 81 | |||
| 82 | foreach(path ${cc_lib_path} ${env_lib_path}) | ||
| 83 | if(IS_DIRECTORY ${path}) | ||
| 84 | execute_process(COMMAND ls -- ${path}/lib${liblow}.dylib | ||
| 85 | ERROR_QUIET | ||
| 86 | OUTPUT_VARIABLE lib_file | ||
| 87 | OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
| 88 | else() | ||
| 89 | set(lib_file ${path}) | ||
| 90 | endif() | ||
| 91 | if(lib_file) | ||
| 92 | # we want the path/name that is embedded in the dylib | ||
| 93 | execute_process(COMMAND otool -L ${lib_file} | ||
| 94 | COMMAND grep -v lib${liblow}.dylib | ||
| 95 | COMMAND grep ${liblow} | ||
| 96 | COMMAND awk "{V=1; print $V}" | ||
| 97 | ERROR_QUIET | ||
| 98 | OUTPUT_VARIABLE filename | ||
| 99 | OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
| 100 | get_filename_component(${lib}_SONAME "${filename}" NAME) | ||
| 101 | message(STATUS "${lib} soname: ${${lib}_SONAME}") | ||
| 102 | endif() | ||
| 103 | endforeach() | ||
| 104 | if(arg_REQUIRED AND NOT ${lib}_SONAME) | ||
| 105 | message(FATAL_ERROR "Could not find dynamically loadable library ${lib}") | ||
| 106 | endif() | ||
| 107 | set(${lib}_SONAME ${${lib}_SONAME} PARENT_SCOPE) | ||
| 108 | endfunction() | ||
diff --git a/project/cmake/scripts/darwin/pathsetup.cmake b/project/cmake/scripts/darwin/pathsetup.cmake new file mode 100644 index 0000000..e31f66e --- /dev/null +++ b/project/cmake/scripts/darwin/pathsetup.cmake | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | if(NOT prefix) | ||
| 2 | set(prefix ${DEPENDS_PATH}) | ||
| 3 | endif() | ||
| 4 | if(NOT exec_prefix) | ||
| 5 | set(exec_prefix \${prefix}) | ||
| 6 | endif() | ||
| 7 | if(NOT libdir) | ||
| 8 | set(libdir ${prefix}/lib) | ||
| 9 | endif() | ||
| 10 | if(NOT bindir) | ||
| 11 | set(bindir ${prefix}/bin) | ||
| 12 | endif() | ||
| 13 | if(NOT includedir) | ||
| 14 | set(includedir ${prefix}/include) | ||
| 15 | endif() | ||
| 16 | if(NOT datarootdir) | ||
| 17 | set(datarootdir ${prefix}/share) | ||
| 18 | endif() | ||
| 19 | if(NOT datadir) | ||
| 20 | set(datadir \${datarootdir}) | ||
| 21 | endif() | ||
| 22 | |||
| 23 | list(APPEND final_message "-- PATH config --") | ||
| 24 | list(APPEND final_message "Prefix: ${prefix}") | ||
| 25 | list(APPEND final_message "Libdir: ${libdir}") | ||
| 26 | list(APPEND final_message "Bindir: ${bindir}") | ||
| 27 | list(APPEND final_message "Includedir: ${includedir}") | ||
| 28 | list(APPEND final_message "Datarootdir: ${datarootdir}") | ||
| 29 | list(APPEND final_message "Datadir: ${datadir}") | ||
| 30 | |||
| 31 | set(PATH_DEFINES -DBIN_INSTALL_PATH=\"${libdir}/xbmc\" | ||
| 32 | -DINSTALL_PATH=\"${datarootdir}/xbmc\") | ||
diff --git a/project/cmake/scripts/freebsd/archsetup.cmake b/project/cmake/scripts/freebsd/archsetup.cmake new file mode 100644 index 0000000..edc77f1 --- /dev/null +++ b/project/cmake/scripts/freebsd/archsetup.cmake | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | set(ARCH_DEFINES -D_LINUX -DTARGET_POSIX -DTARGET_FREEBSD) | ||
| 2 | set(SYSTEM_DEFINES -D__STDC_CONSTANT_MACROS -D_FILE_DEFINED | ||
| 3 | -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64) | ||
| 4 | set(PLATFORM_DIR linux) | ||
| 5 | set(SYSTEM_LDFLAGS -L/usr/local/lib) | ||
| 6 | if(WITH_ARCH) | ||
| 7 | set(ARCH ${WITH_ARCH}) | ||
| 8 | else() | ||
| 9 | if(CMAKE_SYSTEM_PROCESSOR STREQUAL amd64) | ||
| 10 | set(ARCH x86_64-freebsd) | ||
| 11 | elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i.86") | ||
| 12 | set(ARCH x86-freebsd) | ||
| 13 | else() | ||
| 14 | message(WARNING "unknown CPU: ${CPU}") | ||
| 15 | endif() | ||
| 16 | endif() | ||
| 17 | |||
| 18 | set(LIRC_DEVICE "\"/dev/lircd\"" CACHE STRING "LIRC device to use") | ||
| 19 | set(DEP_DEFINES -DLIRC_DEVICE=${LIRC_DEVICE}) | ||
diff --git a/project/cmake/scripts/freebsd/install.cmake b/project/cmake/scripts/freebsd/install.cmake new file mode 100644 index 0000000..0c8939e --- /dev/null +++ b/project/cmake/scripts/freebsd/install.cmake | |||
| @@ -0,0 +1,58 @@ | |||
| 1 | set(libdir ${CMAKE_INSTALL_PREFIX}/lib) | ||
| 2 | set(bindir ${CMAKE_INSTALL_PREFIX}/bin) | ||
| 3 | |||
| 4 | configure_file(${CORE_SOURCE_DIR}/tools/Linux/xbmc.sh.in | ||
| 5 | ${CORE_BUILD_DIR}/scripts/xbmc @ONLY) | ||
| 6 | configure_file(${CORE_SOURCE_DIR}/tools/Linux/xbmc-standalone.sh.in | ||
| 7 | ${CORE_BUILD_DIR}/scripts/xbmc-standalone @ONLY) | ||
| 8 | |||
| 9 | install(TARGETS xbmc-xrandr DESTINATION lib/xbmc) | ||
| 10 | install(FILES ${addon_bindings} DESTINATION include/xbmc) | ||
| 11 | install(FILES ${cmake_files} ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/modules/xbmc-config.cmake | ||
| 12 | DESTINATION lib/xbmc) | ||
| 13 | install(PROGRAMS ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/scripts/xbmc | ||
| 14 | ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/scripts/xbmc-standalone | ||
| 15 | DESTINATION bin) | ||
| 16 | install(FILES ${CORE_SOURCE_DIR}/tools/Linux/FEH.py | ||
| 17 | DESTINATION share/xbmc) | ||
| 18 | |||
| 19 | install(FILES ${CORE_SOURCE_DIR}/tools/Linux/xbmc-xsession.desktop | ||
| 20 | RENAME XBMC.desktop | ||
| 21 | DESTINATION share/xsessions) | ||
| 22 | |||
| 23 | install(FILES ${CORE_SOURCE_DIR}/LICENSE.GPL | ||
| 24 | ${CORE_SOURCE_DIR}/docs/README.freebsd | ||
| 25 | DESTINATION share/doc/xbmc) | ||
| 26 | |||
| 27 | foreach(texture ${XBT_FILES}) | ||
| 28 | string(REPLACE "${CMAKE_BINARY_DIR}/" "" dir ${texture}) | ||
| 29 | get_filename_component(dir ${dir} PATH) | ||
| 30 | install(FILES ${texture} | ||
| 31 | DESTINATION share/xbmc/${dir}) | ||
| 32 | endforeach() | ||
| 33 | |||
| 34 | foreach(wraplib ${WRAP_FILES}) | ||
| 35 | get_filename_component(dir ${wraplib} PATH) | ||
| 36 | install(PROGRAMS ${CMAKE_BINARY_DIR}/${wraplib} | ||
| 37 | DESTINATION lib/xbmc/${dir}) | ||
| 38 | endforeach() | ||
| 39 | |||
| 40 | foreach(file ${install_data}) | ||
| 41 | get_filename_component(dir ${file} PATH) | ||
| 42 | install(FILES ${CMAKE_BINARY_DIR}/${file} | ||
| 43 | DESTINATION share/xbmc/${dir}) | ||
| 44 | endforeach() | ||
| 45 | |||
| 46 | install(CODE "file(STRINGS ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/extra-installs dirs) | ||
| 47 | foreach(dir \${dirs}) | ||
| 48 | file(GLOB_RECURSE FILES RELATIVE ${CMAKE_BINARY_DIR} \${dir}/*) | ||
| 49 | foreach(file \${FILES}) | ||
| 50 | get_filename_component(dir \${file} PATH) | ||
| 51 | file(INSTALL \${file} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/xbmc/\${dir}) | ||
| 52 | endforeach() | ||
| 53 | endforeach()") | ||
| 54 | foreach(subdir ${build_dirs}) | ||
| 55 | string(REPLACE " " ";" subdir ${subdir}) | ||
| 56 | list(GET subdir 0 id) | ||
| 57 | install(CODE "execute_process(COMMAND make -C ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/${id}/src/${id}-build install)") | ||
| 58 | endforeach() | ||
diff --git a/project/cmake/scripts/freebsd/macros.cmake b/project/cmake/scripts/freebsd/macros.cmake new file mode 100644 index 0000000..f0bf7ba --- /dev/null +++ b/project/cmake/scripts/freebsd/macros.cmake | |||
| @@ -0,0 +1 @@ | |||
| include(../linux/macros.cmake) | |||
diff --git a/project/cmake/scripts/freebsd/pathsetup.cmake b/project/cmake/scripts/freebsd/pathsetup.cmake new file mode 100644 index 0000000..1fb45b6 --- /dev/null +++ b/project/cmake/scripts/freebsd/pathsetup.cmake | |||
| @@ -0,0 +1 @@ | |||
| include(${PROJECT_SOURCE_DIR}/scripts/linux/pathsetup.cmake) | |||
diff --git a/project/cmake/scripts/ios/archsetup.cmake b/project/cmake/scripts/ios/archsetup.cmake new file mode 100644 index 0000000..e6639f7 --- /dev/null +++ b/project/cmake/scripts/ios/archsetup.cmake | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | if(NOT CMAKE_TOOLCHAIN_FILE) | ||
| 2 | message(FATAL_ERROR "CMAKE_TOOLCHAIN_FILE required for ios. See ${PROJECT_SOURCE_DIR}/README.md") | ||
| 3 | endif() | ||
| 4 | |||
| 5 | set(CORE_MAIN_SOURCE ${CORE_SOURCE_DIR}/xbmc/platform/darwin/ios/XBMCApplication.m) | ||
| 6 | |||
| 7 | set(ARCH_DEFINES -D_LINUX -DTARGET_POSIX -DTARGET_DARWIN -DTARGET_DARWIN_IOS) | ||
| 8 | set(SYSTEM_DEFINES -D_REENTRANT -D_FILE_DEFINED -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE | ||
| 9 | -D__STDC_CONSTANT_MACROS) | ||
| 10 | set(PLATFORM_DIR linux) | ||
| 11 | set(CMAKE_SYSTEM_NAME Darwin) | ||
| 12 | if(WITH_ARCH) | ||
| 13 | set(ARCH ${WITH_ARCH}) | ||
| 14 | else() | ||
| 15 | if(CPU STREQUAL armv7) | ||
| 16 | set(ARCH arm-apple-darwin) | ||
| 17 | elseif(CPU STREQUAL arm64) | ||
| 18 | set(ARCH arm-apple-darwin) | ||
| 19 | else() | ||
| 20 | message(SEND_ERROR "Unknown CPU: ${CPU}") | ||
| 21 | endif() | ||
| 22 | endif() | ||
| 23 | |||
| 24 | find_package(CXX11 REQUIRED) | ||
| 25 | |||
| 26 | list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${NATIVEPREFIX}) | ||
| 27 | |||
| 28 | list(APPEND DEPLIBS "-framework CoreFoundation" "-framework CoreVideo" | ||
| 29 | "-framework CoreAudio" "-framework AudioToolbox" | ||
| 30 | "-framework QuartzCore" "-framework MediaPlayer" | ||
| 31 | "-framework CFNetwork" "-framework CoreGraphics" | ||
| 32 | "-framework Foundation" "-framework UIKit" | ||
| 33 | "-framework CoreMedia" "-framework AVFoundation") | ||
| 34 | |||
| 35 | set(ENABLE_DVDCSS OFF) | ||
| 36 | set(ENABLE_OPTICAL OFF) | ||
| 37 | set(ENABLE_VTB ON) | ||
| 38 | set(VTB_FOUND 1 CACHE INTERNAL "VTB") | ||
diff --git a/project/cmake/scripts/ios/install.cmake b/project/cmake/scripts/ios/install.cmake new file mode 120000 index 0000000..0ea6586 --- /dev/null +++ b/project/cmake/scripts/ios/install.cmake | |||
| @@ -0,0 +1 @@ | |||
| ../darwin/install.cmake \ No newline at end of file | |||
diff --git a/project/cmake/scripts/ios/macros.cmake b/project/cmake/scripts/ios/macros.cmake new file mode 120000 index 0000000..45c7ad1 --- /dev/null +++ b/project/cmake/scripts/ios/macros.cmake | |||
| @@ -0,0 +1 @@ | |||
| ../darwin/macros.cmake \ No newline at end of file | |||
diff --git a/project/cmake/scripts/ios/pathsetup.cmake b/project/cmake/scripts/ios/pathsetup.cmake new file mode 120000 index 0000000..f8e1248 --- /dev/null +++ b/project/cmake/scripts/ios/pathsetup.cmake | |||
| @@ -0,0 +1 @@ | |||
| ../darwin/pathsetup.cmake \ No newline at end of file | |||
diff --git a/project/cmake/scripts/linux/archsetup.cmake b/project/cmake/scripts/linux/archsetup.cmake new file mode 100644 index 0000000..d0e149e --- /dev/null +++ b/project/cmake/scripts/linux/archsetup.cmake | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | set(ARCH_DEFINES -D_LINUX -DTARGET_POSIX -DTARGET_LINUX) | ||
| 2 | set(SYSTEM_DEFINES -D__STDC_CONSTANT_MACROS -D_FILE_DEFINED | ||
| 3 | -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64) | ||
| 4 | set(PLATFORM_DIR linux) | ||
| 5 | set(CMAKE_SYSTEM_NAME Linux) | ||
| 6 | if(WITH_ARCH) | ||
| 7 | set(ARCH ${WITH_ARCH}) | ||
| 8 | else() | ||
| 9 | if(CPU STREQUAL x86_64) | ||
| 10 | set(ARCH x86_64-linux) | ||
| 11 | elseif(CPU MATCHES "i.86") | ||
| 12 | set(ARCH i486-linux) | ||
| 13 | else() | ||
| 14 | message(SEND_ERROR "Unknown CPU: ${CPU}") | ||
| 15 | endif() | ||
| 16 | endif() | ||
| 17 | |||
| 18 | find_package(CXX11 REQUIRED) | ||
| 19 | |||
| 20 | set(LIRC_DEVICE "\"/dev/lircd\"" CACHE STRING "LIRC device to use") | ||
| 21 | set(DEP_DEFINES -DLIRC_DEVICE=${LIRC_DEVICE}) | ||
diff --git a/project/cmake/scripts/linux/install.cmake b/project/cmake/scripts/linux/install.cmake new file mode 100644 index 0000000..b887610 --- /dev/null +++ b/project/cmake/scripts/linux/install.cmake | |||
| @@ -0,0 +1,93 @@ | |||
| 1 | if(X_FOUND) | ||
| 2 | set(USE_X11 1) | ||
| 3 | else() | ||
| 4 | set(USE_X11 0) | ||
| 5 | endif() | ||
| 6 | if(OPENGL_FOUND) | ||
| 7 | set(USE_OPENGL 1) | ||
| 8 | else() | ||
| 9 | set(USE_OPENGL 0) | ||
| 10 | endif() | ||
| 11 | if(OPENGLES_FOUND) | ||
| 12 | set(USE_OPENGLES 1) | ||
| 13 | else() | ||
| 14 | set(USE_OPENGLES 0) | ||
| 15 | endif() | ||
| 16 | |||
| 17 | configure_file(${CORE_SOURCE_DIR}/tools/Linux/kodi.sh.in | ||
| 18 | ${CORE_BUILD_DIR}/scripts/${APP_NAME_LC} @ONLY) | ||
| 19 | configure_file(${CORE_SOURCE_DIR}/tools/Linux/kodi-standalone.sh.in | ||
| 20 | ${CORE_BUILD_DIR}/scripts/${APP_NAME_LC}-standalone @ONLY) | ||
| 21 | |||
| 22 | install(TARGETS ${APP_NAME_LC} DESTINATION ${libdir}/kodi) | ||
| 23 | if(ENABLE_X11 AND XRANDR_FOUND) | ||
| 24 | install(TARGETS ${APP_NAME_LC}-xrandr DESTINATION ${libdir}/${APP_NAME_LC}) | ||
| 25 | endif() | ||
| 26 | install(FILES ${addon_bindings} DESTINATION ${includedir}/kodi) | ||
| 27 | install(FILES ${cmake-files} | ||
| 28 | DESTINATION ${libdir}/kodi) | ||
| 29 | install(PROGRAMS ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/scripts/${APP_NAME_LC} | ||
| 30 | ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/scripts/${APP_NAME_LC}-standalone | ||
| 31 | DESTINATION ${bindir}) | ||
| 32 | |||
| 33 | configure_file(${CORE_SOURCE_DIR}/tools/Linux/kodi-xsession.desktop.in | ||
| 34 | ${CORE_BUILD_DIR}/${APP_NAME_LC}-xsession.desktop) | ||
| 35 | install(FILES ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/${APP_NAME_LC}-xsession.desktop | ||
| 36 | DESTINATION ${datarootdir}/xsessions) | ||
| 37 | |||
| 38 | install(FILES ${CORE_SOURCE_DIR}/LICENSE.GPL | ||
| 39 | ${CORE_SOURCE_DIR}/docs/README.linux | ||
| 40 | DESTINATION ${datarootdir}/doc/kodi) | ||
| 41 | |||
| 42 | install(FILES ${CORE_SOURCE_DIR}/tools/Linux/kodi.desktop | ||
| 43 | DESTINATION ${datarootdir}/applications) | ||
| 44 | |||
| 45 | foreach(texture ${XBT_FILES}) | ||
| 46 | string(REPLACE "${CMAKE_BINARY_DIR}/" "" dir ${texture}) | ||
| 47 | get_filename_component(dir ${dir} PATH) | ||
| 48 | install(FILES ${texture} | ||
| 49 | DESTINATION ${datarootdir}/kodi/${dir}) | ||
| 50 | endforeach() | ||
| 51 | |||
| 52 | foreach(wraplib ${WRAP_FILES}) | ||
| 53 | get_filename_component(dir ${wraplib} PATH) | ||
| 54 | install(PROGRAMS ${CMAKE_BINARY_DIR}/${wraplib} | ||
| 55 | DESTINATION ${libdir}/kodi/${dir}) | ||
| 56 | endforeach() | ||
| 57 | |||
| 58 | foreach(file ${install_data}) | ||
| 59 | get_filename_component(dir ${file} PATH) | ||
| 60 | install(FILES ${CMAKE_BINARY_DIR}/${file} | ||
| 61 | DESTINATION ${datarootdir}/kodi/${dir}) | ||
| 62 | endforeach() | ||
| 63 | |||
| 64 | if(EXISTS ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/extra-installs) | ||
| 65 | install(CODE "file(STRINGS ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/extra-installs dirs) | ||
| 66 | foreach(dir \${dirs}) | ||
| 67 | file(GLOB_RECURSE FILES RELATIVE ${CMAKE_BINARY_DIR} \${dir}/*) | ||
| 68 | foreach(file \${FILES}) | ||
| 69 | get_filename_component(dir \${file} PATH) | ||
| 70 | file(INSTALL \${file} DESTINATION ${datarootdir}/kodi/\${dir}) | ||
| 71 | endforeach() | ||
| 72 | endforeach()") | ||
| 73 | endif() | ||
| 74 | |||
| 75 | if(NOT "$ENV{DESTDIR}" STREQUAL "") | ||
| 76 | set(DESTDIR ${CMAKE_BINARY_DIR}/$ENV{DESTDIR}) | ||
| 77 | endif() | ||
| 78 | foreach(subdir ${build_dirs}) | ||
| 79 | if(NOT subdir MATCHES kodi-platform) | ||
| 80 | string(REPLACE " " ";" subdir ${subdir}) | ||
| 81 | list(GET subdir 0 id) | ||
| 82 | install(CODE "execute_process(COMMAND make -C ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/${id}/src/${id}-build install DESTDIR=${DESTDIR})") | ||
| 83 | endif() | ||
| 84 | endforeach() | ||
| 85 | |||
| 86 | install(FILES ${CORE_SOURCE_DIR}/media/icon48x48.png | ||
| 87 | RENAME ${APP_NAME_LC}.png | ||
| 88 | DESTINATION ${datarootdir}/icons/hicolor/48x48/apps) | ||
| 89 | install(FILES ${CORE_SOURCE_DIR}/media/icon256x256.png | ||
| 90 | RENAME ${APP_NAME_LC}.png | ||
| 91 | DESTINATION ${datarootdir}/icons/hicolor/256x256/apps) | ||
| 92 | |||
| 93 | install(CODE "execute_process(COMMAND gtk-update-icon-cache -f -q -t $ENV{DESTDIR}${datarootdir}/icons/hicolor ERROR_QUIET)") | ||
diff --git a/project/cmake/scripts/linux/macros.cmake b/project/cmake/scripts/linux/macros.cmake new file mode 100644 index 0000000..7453a1c --- /dev/null +++ b/project/cmake/scripts/linux/macros.cmake | |||
| @@ -0,0 +1,79 @@ | |||
| 1 | function(core_link_library lib wraplib) | ||
| 2 | set(export -Wl,--unresolved-symbols=ignore-all | ||
| 3 | `cat ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/cores/dll-loader/exports/wrapper.def` | ||
| 4 | ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/cores/dll-loader/exports/CMakeFiles/wrapper.dir/wrapper.c.o) | ||
| 5 | set(check_arg "") | ||
| 6 | if(TARGET ${lib}) | ||
| 7 | set(target ${lib}) | ||
| 8 | set(link_lib ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/${lib}/${lib}.a) | ||
| 9 | set(check_arg ${ARGV2}) | ||
| 10 | set(data_arg ${ARGV3}) | ||
| 11 | else() | ||
| 12 | set(target ${ARGV2}) | ||
| 13 | set(link_lib ${lib}) | ||
| 14 | set(check_arg ${ARGV3}) | ||
| 15 | set(data_arg ${ARGV4}) | ||
| 16 | endif() | ||
| 17 | if(check_arg STREQUAL export) | ||
| 18 | set(export ${export} | ||
| 19 | -Wl,--version-script=${ARGV3}) | ||
| 20 | elseif(check_arg STREQUAL nowrap) | ||
| 21 | set(export ${data_arg}) | ||
| 22 | elseif(check_arg STREQUAL extras) | ||
| 23 | foreach(arg ${data_arg}) | ||
| 24 | list(APPEND export ${arg}) | ||
| 25 | endforeach() | ||
| 26 | endif() | ||
| 27 | get_filename_component(dir ${wraplib} PATH) | ||
| 28 | add_custom_command(OUTPUT ${wraplib}-${ARCH}${CMAKE_SHARED_MODULE_SUFFIX} | ||
| 29 | COMMAND cmake -E make_directory ${dir} | ||
| 30 | COMMAND ${CMAKE_C_COMPILER} | ||
| 31 | ARGS -Wl,--whole-archive | ||
| 32 | ${link_lib} | ||
| 33 | -Wl,--no-whole-archive -lm | ||
| 34 | -shared -o ${CMAKE_BINARY_DIR}/${wraplib}-${ARCH}${CMAKE_SHARED_MODULE_SUFFIX} | ||
| 35 | ${export} | ||
| 36 | DEPENDS ${target} wrapper.def wrapper) | ||
| 37 | list(APPEND WRAP_FILES ${wraplib}-${ARCH}${CMAKE_SHARED_MODULE_SUFFIX}) | ||
| 38 | set(WRAP_FILES ${WRAP_FILES} PARENT_SCOPE) | ||
| 39 | endfunction() | ||
| 40 | |||
| 41 | function(find_soname lib) | ||
| 42 | cmake_parse_arguments(arg "REQUIRED" "" "" ${ARGN}) | ||
| 43 | |||
| 44 | string(TOLOWER ${lib} liblow) | ||
| 45 | if(${lib}_LDFLAGS) | ||
| 46 | set(link_lib "${${lib}_LDFLAGS}") | ||
| 47 | else() | ||
| 48 | if(IS_ABSOLUTE "${${lib}_LIBRARIES}") | ||
| 49 | set(link_lib "${${lib}_LIBRARIES}") | ||
| 50 | else() | ||
| 51 | set(link_lib -l${${lib}_LIBRARIES}) | ||
| 52 | endif() | ||
| 53 | endif() | ||
| 54 | execute_process(COMMAND ${CMAKE_C_COMPILER} -nostdlib -o /dev/null -Wl,-M ${link_lib} | ||
| 55 | COMMAND grep LOAD.*${liblow} | ||
| 56 | ERROR_QUIET | ||
| 57 | OUTPUT_VARIABLE ${lib}_FILENAME) | ||
| 58 | string(REPLACE "LOAD " "" ${lib}_FILENAME "${${lib}_FILENAME}") | ||
| 59 | string(STRIP "${${lib}_FILENAME}" ${lib}_FILENAME) | ||
| 60 | if(NOT ${lib}_FILENAME) | ||
| 61 | execute_process(COMMAND ${CMAKE_C_COMPILER} -nostdlib -o /dev/null -Wl,-t ${link_lib} | ||
| 62 | OUTPUT_QUIET | ||
| 63 | ERROR_VARIABLE _TMP_FILENAME) | ||
| 64 | string(REGEX MATCH ".*lib${liblow}.so" ${lib}_FILENAME ${_TMP_FILENAME}) | ||
| 65 | endif() | ||
| 66 | if(${lib}_FILENAME) | ||
| 67 | execute_process(COMMAND objdump -p ${${lib}_FILENAME} | ||
| 68 | COMMAND grep SONAME.*${liblow} | ||
| 69 | ERROR_QUIET | ||
| 70 | OUTPUT_VARIABLE ${lib}_SONAME) | ||
| 71 | string(REPLACE "SONAME " "" ${lib}_SONAME ${${lib}_SONAME}) | ||
| 72 | string(STRIP ${${lib}_SONAME} ${lib}_SONAME) | ||
| 73 | message(STATUS "${lib} soname: ${${lib}_SONAME}") | ||
| 74 | set(${lib}_SONAME ${${lib}_SONAME} PARENT_SCOPE) | ||
| 75 | endif() | ||
| 76 | if(arg_REQUIRED AND NOT ${lib}_SONAME) | ||
| 77 | message(FATAL_ERROR "Could not find dynamically loadable library ${lib}") | ||
| 78 | endif() | ||
| 79 | endfunction() | ||
diff --git a/project/cmake/scripts/linux/pathsetup.cmake b/project/cmake/scripts/linux/pathsetup.cmake new file mode 100644 index 0000000..940fb62 --- /dev/null +++ b/project/cmake/scripts/linux/pathsetup.cmake | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | if(NOT prefix) | ||
| 2 | set(prefix ${CMAKE_INSTALL_PREFIX}) | ||
| 3 | else() | ||
| 4 | set(CMAKE_INSTALL_PREFIX ${prefix}) | ||
| 5 | endif() | ||
| 6 | if(NOT exec_prefix) | ||
| 7 | set(exec_prefix \${prefix}) | ||
| 8 | endif() | ||
| 9 | if(NOT libdir) | ||
| 10 | set(libdir ${prefix}/lib) | ||
| 11 | endif() | ||
| 12 | if(NOT bindir) | ||
| 13 | set(bindir ${prefix}/bin) | ||
| 14 | endif() | ||
| 15 | if(NOT includedir) | ||
| 16 | set(includedir ${prefix}/include) | ||
| 17 | endif() | ||
| 18 | if(NOT datarootdir) | ||
| 19 | set(datarootdir ${prefix}/share) | ||
| 20 | endif() | ||
| 21 | if(NOT datadir) | ||
| 22 | set(datadir \${datarootdir}) | ||
| 23 | endif() | ||
| 24 | |||
| 25 | list(APPEND final_message "-- PATH config --") | ||
| 26 | list(APPEND final_message "Prefix: ${prefix}") | ||
| 27 | list(APPEND final_message "Libdir: ${libdir}") | ||
| 28 | list(APPEND final_message "Bindir: ${bindir}") | ||
| 29 | list(APPEND final_message "Includedir: ${includedir}") | ||
| 30 | list(APPEND final_message "Datarootdir: ${datarootdir}") | ||
| 31 | list(APPEND final_message "Datadir: ${datadir}") | ||
| 32 | |||
| 33 | set(PATH_DEFINES -DBIN_INSTALL_PATH=\"${libdir}/xbmc\" | ||
| 34 | -DINSTALL_PATH=\"${datarootdir}/xbmc\") | ||
diff --git a/project/cmake/scripts/rbpi/archsetup.cmake b/project/cmake/scripts/rbpi/archsetup.cmake new file mode 100644 index 0000000..84f1dad --- /dev/null +++ b/project/cmake/scripts/rbpi/archsetup.cmake | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | if(NOT CMAKE_TOOLCHAIN_FILE) | ||
| 2 | message(FATAL_ERROR "CMAKE_TOOLCHAIN_FILE required for rbpi. See ${PROJECT_SOURCE_DIR}/README.md") | ||
| 3 | endif() | ||
| 4 | |||
| 5 | set(ARCH_DEFINES -DTARGET_POSIX -DTARGET_LINUX -D_LINUX -D_ARMEL -DTARGET_RASPBERRY_PI | ||
| 6 | -DHAS_OMXPLAYER -DHAVE_OMXLIB) | ||
| 7 | set(SYSTEM_DEFINES -D__STDC_CONSTANT_MACROS -D_FILE_DEFINED | ||
| 8 | -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64) | ||
| 9 | set(PLATFORM_DIR linux) | ||
| 10 | |||
| 11 | string(REGEX REPLACE "[ ]+" ";" SYSTEM_LDFLAGS $ENV{LDFLAGS}) | ||
| 12 | set(CMAKE_SYSTEM_NAME Linux) | ||
| 13 | |||
| 14 | if(WITH_ARCH) | ||
| 15 | set(ARCH ${WITH_ARCH}) | ||
| 16 | else() | ||
| 17 | if(CPU STREQUAL arm1176jzf-s) | ||
| 18 | set(ARCH arm-linux-gnueabihf) | ||
| 19 | elseif(CPU MATCHES "cortex-a7") | ||
| 20 | set(ARCH arm-linux-gnueabihf) | ||
| 21 | else() | ||
| 22 | message(SEND_ERROR "Unknown CPU: ${CPU}") | ||
| 23 | endif() | ||
| 24 | endif() | ||
| 25 | |||
| 26 | find_package(CXX11 REQUIRED) | ||
| 27 | |||
| 28 | set(LIRC_DEVICE "\"/dev/lircd\"" CACHE STRING "LIRC device to use") | ||
| 29 | set(DEP_DEFINES -DLIRC_DEVICE=${LIRC_DEVICE}) | ||
| 30 | set(MMAL_FOUND 1 CACHE INTERNAL "MMAL") | ||
| 31 | set(OMX_FOUND 1 CACHE INTERNAL "OMX") | ||
| 32 | set(OMXLIB_FOUND 1 CACHE INTERNAL "OMX") | ||
diff --git a/project/cmake/scripts/rbpi/install.cmake b/project/cmake/scripts/rbpi/install.cmake new file mode 120000 index 0000000..0409981 --- /dev/null +++ b/project/cmake/scripts/rbpi/install.cmake | |||
| @@ -0,0 +1 @@ | |||
| ../linux/install.cmake \ No newline at end of file | |||
diff --git a/project/cmake/scripts/rbpi/macros.cmake b/project/cmake/scripts/rbpi/macros.cmake new file mode 120000 index 0000000..28c77ca --- /dev/null +++ b/project/cmake/scripts/rbpi/macros.cmake | |||
| @@ -0,0 +1 @@ | |||
| ../linux/macros.cmake \ No newline at end of file | |||
diff --git a/project/cmake/scripts/rbpi/pathsetup.cmake b/project/cmake/scripts/rbpi/pathsetup.cmake new file mode 120000 index 0000000..26d7f17 --- /dev/null +++ b/project/cmake/scripts/rbpi/pathsetup.cmake | |||
| @@ -0,0 +1 @@ | |||
| ../linux/pathsetup.cmake \ No newline at end of file | |||
diff --git a/project/cmake/scripts/windows/archsetup.cmake b/project/cmake/scripts/windows/archsetup.cmake new file mode 100644 index 0000000..baa3624 --- /dev/null +++ b/project/cmake/scripts/windows/archsetup.cmake | |||
| @@ -0,0 +1,91 @@ | |||
| 1 | # -------- Architecture settings --------- | ||
| 2 | |||
| 3 | set(ARCH win32) | ||
| 4 | |||
| 5 | |||
| 6 | # -------- Paths (mainly for find_package) --------- | ||
| 7 | |||
| 8 | set(PLATFORM_DIR win32) | ||
| 9 | |||
| 10 | # Precompiled headers fail with per target output directory. (needs CMake 3.1) | ||
| 11 | set(PRECOMPILEDHEADER_DIR ${PROJECT_BINARY_DIR}/${CORE_BUILD_CONFIG}/objs) | ||
| 12 | |||
| 13 | set(CMAKE_SYSTEM_NAME Windows) | ||
| 14 | list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${PROJECT_SOURCE_DIR}/../../lib/win32) | ||
| 15 | list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${PROJECT_SOURCE_DIR}/../../lib/win32/ffmpeg) | ||
| 16 | list(APPEND CMAKE_SYSTEM_LIBRARY_PATH ${PROJECT_SOURCE_DIR}/../../lib/win32/ffmpeg/bin) | ||
| 17 | list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${PROJECT_SOURCE_DIR}/../BuildDependencies) | ||
| 18 | set(CONFIGURATION_LIBDIR lib/${CORE_BUILD_CONFIG}-vc120) | ||
| 19 | set(CONFIGURATION_LIBDIR_RELEASE lib/Release-vc120) | ||
| 20 | set(CONFIGURATION_LIBDIR_DEBUG lib/Debug-vc120) | ||
| 21 | |||
| 22 | set(JPEG_NAMES ${JPEG_NAMES} jpeg-static) | ||
| 23 | set(PYTHON_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/../BuildDependencies/include/python) | ||
| 24 | |||
| 25 | |||
| 26 | # -------- Compiler options --------- | ||
| 27 | |||
| 28 | add_options(CXX ALL_BUILDS "/wd\"4996\"") | ||
| 29 | set(ARCH_DEFINES -D_WINDOWS -DTARGET_WINDOWS) | ||
| 30 | set(SYSTEM_DEFINES -DNOMINMAX -D_USE_32BIT_TIME_T -DHAS_DX -D__STDC_CONSTANT_MACROS | ||
| 31 | -DTAGLIB_STATIC -DNPT_CONFIG_ENABLE_LOGGING | ||
| 32 | -DPLT_HTTP_DEFAULT_USER_AGENT="UPnP/1.0 DLNADOC/1.50 Kodi" | ||
| 33 | -DPLT_HTTP_DEFAULT_SERVER="UPnP/1.0 DLNADOC/1.50 Kodi" | ||
| 34 | -DBUILDING_WITH_CMAKE | ||
| 35 | $<$<CONFIG:Debug>:-DD3D_DEBUG_INFO -D_SECURE_SCL=0 -D_HAS_ITERATOR_DEBUGGING=0>) | ||
| 36 | |||
| 37 | # Compile with /MT (to be compatible with the dependent libraries) | ||
| 38 | foreach(CompilerFlag CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE | ||
| 39 | CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) | ||
| 40 | string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}") | ||
| 41 | endforeach() | ||
| 42 | |||
| 43 | # Make sure /FS is set for Visual Studio in order to prevent simultanious access to pdb files. | ||
| 44 | if(CMAKE_GENERATOR MATCHES "Visual Studio") | ||
| 45 | set(CMAKE_CXX_FLAGS "/MP /FS ${CMAKE_CXX_FLAGS}") | ||
| 46 | endif() | ||
| 47 | |||
| 48 | |||
| 49 | # -------- Linker options --------- | ||
| 50 | |||
| 51 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO") | ||
| 52 | |||
| 53 | # For #pragma comment(lib X) | ||
| 54 | # TODO: It would certainly be better to handle these libraries via CMake modules. | ||
| 55 | link_directories(${PROJECT_SOURCE_DIR}/../../lib/win32/ffmpeg/bin | ||
| 56 | ${PROJECT_SOURCE_DIR}/../BuildDependencies/lib | ||
| 57 | ${PROJECT_SOURCE_DIR}/../BuildDependencies/${CONFIGURATION_LIBDIR}) | ||
| 58 | |||
| 59 | # Additional libraries | ||
| 60 | list(APPEND DEPLIBS d3d11.lib DInput8.lib DSound.lib winmm.lib Mpr.lib Iphlpapi.lib | ||
| 61 | PowrProf.lib setupapi.lib dwmapi.lib yajl.lib dxguid.lib DelayImp.lib) | ||
| 62 | |||
| 63 | # NODEFAULTLIB option | ||
| 64 | set(_nodefaultlibs_RELEASE libc msvcrt libci msvcprt) | ||
| 65 | set(_nodefaultlibs_DEBUG libcpmt libc msvcrt libcmt msvcrtd msvcprtd) | ||
| 66 | foreach(_lib ${_nodefaultlibs_RELEASE}) | ||
| 67 | set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:\"${_lib}\"") | ||
| 68 | endforeach() | ||
| 69 | foreach(_lib ${_nodefaultlibs_DEBUG}) | ||
| 70 | set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:\"${_lib}\"") | ||
| 71 | endforeach() | ||
| 72 | |||
| 73 | # DELAYLOAD option | ||
| 74 | set(_delayloadlibs libxslt.dll dnssd.dll dwmapi.dll ssh.dll sqlite3.dll | ||
| 75 | avcodec-56.dll avfilter-5.dll avformat-56.dll avutil-54.dll | ||
| 76 | postproc-53.dll swresample-1.dll swscale-3.dll d3dcompiler_47.dll) | ||
| 77 | foreach(_lib ${_delayloadlibs}) | ||
| 78 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:\"${_lib}\"") | ||
| 79 | endforeach() | ||
| 80 | |||
| 81 | # Make the Release version create a PDB | ||
| 82 | set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi") | ||
| 83 | # Minimize the size or the resulting DLLs | ||
| 84 | set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF") | ||
| 85 | |||
| 86 | |||
| 87 | # -------- Visual Studio options --------- | ||
| 88 | |||
| 89 | if(CMAKE_GENERATOR MATCHES "Visual Studio") | ||
| 90 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) | ||
| 91 | endif() | ||
diff --git a/project/cmake/scripts/windows/install.cmake b/project/cmake/scripts/windows/install.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/project/cmake/scripts/windows/install.cmake | |||
diff --git a/project/cmake/scripts/windows/macros.cmake b/project/cmake/scripts/windows/macros.cmake new file mode 100644 index 0000000..6aabf7d --- /dev/null +++ b/project/cmake/scripts/windows/macros.cmake | |||
| @@ -0,0 +1,143 @@ | |||
| 1 | function(core_link_library lib wraplib) | ||
| 2 | # set(export -Wl,--unresolved-symbols=ignore-all | ||
| 3 | # `cat ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/cores/dll-loader/exports/wrapper.def` | ||
| 4 | # ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/cores/dll-loader/exports/CMakeFiles/wrapper.dir/wrapper.c.o) | ||
| 5 | # set(check_arg "") | ||
| 6 | # if(TARGET ${lib}) | ||
| 7 | # set(target ${lib}) | ||
| 8 | # set(link_lib ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/${lib}/${lib}.a) | ||
| 9 | # set(check_arg ${ARGV2}) | ||
| 10 | # set(data_arg ${ARGV3}) | ||
| 11 | # else() | ||
| 12 | # set(target ${ARGV2}) | ||
| 13 | # set(link_lib ${lib}) | ||
| 14 | # set(check_arg ${ARGV3}) | ||
| 15 | # set(data_arg ${ARGV4}) | ||
| 16 | # endif() | ||
| 17 | # if(check_arg STREQUAL "export") | ||
| 18 | # set(export ${export} | ||
| 19 | # -Wl,--version-script=${ARGV3}) | ||
| 20 | # elseif(check_arg STREQUAL "nowrap") | ||
| 21 | # set(export ${data_arg}) | ||
| 22 | # elseif(check_arg STREQUAL "extras") | ||
| 23 | # foreach(arg ${data_arg}) | ||
| 24 | # list(APPEND export ${arg}) | ||
| 25 | # endforeach() | ||
| 26 | # endif() | ||
| 27 | # get_filename_component(dir ${wraplib} PATH) | ||
| 28 | # add_custom_command(OUTPUT ${wraplib}-${ARCH}${CMAKE_SHARED_MODULE_SUFFIX} | ||
| 29 | # COMMAND cmake -E make_directory ${dir} | ||
| 30 | # COMMAND ${CMAKE_C_COMPILER} | ||
| 31 | # ARGS -Wl,--whole-archive | ||
| 32 | # ${link_lib} | ||
| 33 | # -Wl,--no-whole-archive -lm | ||
| 34 | # -shared -o ${CMAKE_BINARY_DIR}/${wraplib}-${ARCH}${CMAKE_SHARED_MODULE_SUFFIX} | ||
| 35 | # ${export} | ||
| 36 | # DEPENDS ${target} wrapper.def wrapper) | ||
| 37 | # list(APPEND WRAP_FILES ${wraplib}-${ARCH}${CMAKE_SHARED_MODULE_SUFFIX}) | ||
| 38 | # set(WRAP_FILES ${WRAP_FILES} PARENT_SCOPE) | ||
| 39 | endfunction() | ||
| 40 | |||
| 41 | function(find_soname lib) | ||
| 42 | # Windows uses hardcoded dlls in xbmc/DllPaths_win32.h. | ||
| 43 | # Therefore the output of this function is unused. | ||
| 44 | endfunction() | ||
| 45 | |||
| 46 | # Add precompiled header to target | ||
| 47 | # Arguments: | ||
| 48 | # target existing target that will be set up to compile with a precompiled header | ||
| 49 | # pch_header the precompiled header file | ||
| 50 | # pch_source the precompiled header source file | ||
| 51 | # Optional Arguments: | ||
| 52 | # PCH_TARGET build precompiled header as separate target with the given name | ||
| 53 | # so that the same precompiled header can be used for multiple libraries | ||
| 54 | # EXCLUDE_SOURCES if not all target sources shall use the precompiled header, | ||
| 55 | # the relevant files can be listed here | ||
| 56 | # On return: | ||
| 57 | # Compiles the pch_source into a precompiled header and adds the header to | ||
| 58 | # the given target | ||
| 59 | function(add_precompiled_header target pch_header pch_source) | ||
| 60 | cmake_parse_arguments(PCH "" "PCH_TARGET" "EXCLUDE_SOURCES" ${ARGN}) | ||
| 61 | |||
| 62 | if(PCH_PCH_TARGET) | ||
| 63 | set(pch_binary ${PRECOMPILEDHEADER_DIR}/${PCH_PCH_TARGET}.pch) | ||
| 64 | else() | ||
| 65 | set(pch_binary ${PRECOMPILEDHEADER_DIR}/${target}.pch) | ||
| 66 | endif() | ||
| 67 | |||
| 68 | # Set compile options and dependency for sources | ||
| 69 | get_target_property(sources ${target} SOURCES) | ||
| 70 | list(REMOVE_ITEM sources ${pch_source}) | ||
| 71 | foreach(exclude_source IN LISTS PCH_EXCLUDE_SOURCES) | ||
| 72 | list(REMOVE_ITEM sources ${exclude_source}) | ||
| 73 | endforeach() | ||
| 74 | set_source_files_properties(${sources} | ||
| 75 | PROPERTIES COMPILE_FLAGS "/Yu\"${pch_header}\" /Fp\"${pch_binary}\" /FI\"${pch_header}\"" | ||
| 76 | OBJECT_DEPENDS "${pch_binary}") | ||
| 77 | |||
| 78 | # Set compile options for precompiled header | ||
| 79 | if(NOT PCH_PCH_TARGET OR NOT TARGET ${PCH_PCH_TARGET}_pch) | ||
| 80 | set_source_files_properties(${pch_source} | ||
| 81 | PROPERTIES COMPILE_FLAGS "/Yc\"${pch_header}\" /Fp\"${pch_binary}\"" | ||
| 82 | OBJECT_OUTPUTS "${pch_binary}") | ||
| 83 | endif() | ||
| 84 | |||
| 85 | # Compile precompiled header | ||
| 86 | if(PCH_PCH_TARGET) | ||
| 87 | # As own target for usage in multiple libraries | ||
| 88 | if(NOT TARGET ${PCH_PCH_TARGET}_pch) | ||
| 89 | add_library(${PCH_PCH_TARGET}_pch STATIC ${pch_source}) | ||
| 90 | set_target_properties(${PCH_PCH_TARGET}_pch PROPERTIES COMPILE_PDB_OUTPUT_DIRECTORY ${PRECOMPILEDHEADER_DIR}) | ||
| 91 | endif() | ||
| 92 | # From VS2012 onwards, precompiled headers have to be linked against (LNK2011). | ||
| 93 | target_link_libraries(${target} PUBLIC ${PCH_PCH_TARGET}_pch) | ||
| 94 | set_target_properties(${target} PROPERTIES COMPILE_PDB_OUTPUT_DIRECTORY ${PRECOMPILEDHEADER_DIR}) | ||
| 95 | else() | ||
| 96 | # As part of the target | ||
| 97 | target_sources(${target} PRIVATE ${pch_source}) | ||
| 98 | endif() | ||
| 99 | endfunction() | ||
| 100 | |||
| 101 | # Adds an FX-compiled shader to a target | ||
| 102 | # Creates a custom command that FX-compiles the given shader and adds the | ||
| 103 | # generated header file to the given target. | ||
| 104 | # Arguments: | ||
| 105 | # target Target to add the FX-compiled shader to | ||
| 106 | # hlsl HLSL shader input file | ||
| 107 | # profile HLSL profile that specifies the shader model | ||
| 108 | # entrypoint Shader entry point | ||
| 109 | # On return: | ||
| 110 | # FXC_FILE is set to the name of the generated header file. | ||
| 111 | function(add_shader_dx target hlsl profile entrypoint) | ||
| 112 | get_filename_component(file ${hlsl} NAME_WE) | ||
| 113 | add_custom_command(OUTPUT ${file}.h | ||
| 114 | COMMAND ${FXC} /Fh ${file}.h | ||
| 115 | /E ${entrypoint} | ||
| 116 | /T ${profile} | ||
| 117 | /Vn ${file} | ||
| 118 | /Qstrip_reflect | ||
| 119 | ${hlsl} | ||
| 120 | DEPENDS ${hlsl} | ||
| 121 | COMMENT "FX compile ${hlsl}" | ||
| 122 | VERBATIM) | ||
| 123 | target_sources(${target} PRIVATE ${file}.h) | ||
| 124 | target_include_directories(${target} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) | ||
| 125 | endfunction() | ||
| 126 | |||
| 127 | # Copies the main dlls to the root of the buildtree | ||
| 128 | # On return: | ||
| 129 | # files added to ${install_data}, mirror in build tree | ||
| 130 | function(copy_main_dlls_to_buildtree) | ||
| 131 | set(dir ${PROJECT_SOURCE_DIR}/../Win32BuildSetup/dependencies) | ||
| 132 | file(GLOB_RECURSE files ${dir}/*) | ||
| 133 | foreach(file ${files}) | ||
| 134 | copy_file_to_buildtree(${file} ${dir}) | ||
| 135 | endforeach() | ||
| 136 | |||
| 137 | if(D3DCOMPILER_DLL) | ||
| 138 | get_filename_component(d3dcompiler_dir ${D3DCOMPILER_DLL} DIRECTORY) | ||
| 139 | copy_file_to_buildtree(${D3DCOMPILER_DLL} ${d3dcompiler_dir}) | ||
| 140 | endif() | ||
| 141 | |||
| 142 | set(install_data ${install_data} PARENT_SCOPE) | ||
| 143 | endfunction() | ||
diff --git a/project/cmake/scripts/windows/pathsetup.cmake b/project/cmake/scripts/windows/pathsetup.cmake new file mode 100644 index 0000000..940fb62 --- /dev/null +++ b/project/cmake/scripts/windows/pathsetup.cmake | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | if(NOT prefix) | ||
| 2 | set(prefix ${CMAKE_INSTALL_PREFIX}) | ||
| 3 | else() | ||
| 4 | set(CMAKE_INSTALL_PREFIX ${prefix}) | ||
| 5 | endif() | ||
| 6 | if(NOT exec_prefix) | ||
| 7 | set(exec_prefix \${prefix}) | ||
| 8 | endif() | ||
| 9 | if(NOT libdir) | ||
| 10 | set(libdir ${prefix}/lib) | ||
| 11 | endif() | ||
| 12 | if(NOT bindir) | ||
| 13 | set(bindir ${prefix}/bin) | ||
| 14 | endif() | ||
| 15 | if(NOT includedir) | ||
| 16 | set(includedir ${prefix}/include) | ||
| 17 | endif() | ||
| 18 | if(NOT datarootdir) | ||
| 19 | set(datarootdir ${prefix}/share) | ||
| 20 | endif() | ||
| 21 | if(NOT datadir) | ||
| 22 | set(datadir \${datarootdir}) | ||
| 23 | endif() | ||
| 24 | |||
| 25 | list(APPEND final_message "-- PATH config --") | ||
| 26 | list(APPEND final_message "Prefix: ${prefix}") | ||
| 27 | list(APPEND final_message "Libdir: ${libdir}") | ||
| 28 | list(APPEND final_message "Bindir: ${bindir}") | ||
| 29 | list(APPEND final_message "Includedir: ${includedir}") | ||
| 30 | list(APPEND final_message "Datarootdir: ${datarootdir}") | ||
| 31 | list(APPEND final_message "Datadir: ${datadir}") | ||
| 32 | |||
| 33 | set(PATH_DEFINES -DBIN_INSTALL_PATH=\"${libdir}/xbmc\" | ||
| 34 | -DINSTALL_PATH=\"${datarootdir}/xbmc\") | ||
