diff options
| author | manuel <manuel@mausz.at> | 2017-06-04 16:57:49 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2017-06-04 16:57:49 +0200 |
| commit | f44ecaa4f27e7538ddcad66d40e543bffa2d2d86 (patch) | |
| tree | d8de60fc7e17edeb6f0921726c038ee54b281445 /project/cmake/scripts/common | |
| parent | ae08c8b7221bc965ac40d70e53fc8fcddb050c46 (diff) | |
| download | kodi-pvr-build-f44ecaa4f27e7538ddcad66d40e543bffa2d2d86.tar.gz kodi-pvr-build-f44ecaa4f27e7538ddcad66d40e543bffa2d2d86.tar.bz2 kodi-pvr-build-f44ecaa4f27e7538ddcad66d40e543bffa2d2d86.zip | |
sync with upstream
Diffstat (limited to 'project/cmake/scripts/common')
| -rw-r--r-- | project/cmake/scripts/common/AddOptions.cmake | 78 | ||||
| -rw-r--r-- | project/cmake/scripts/common/AddonHelpers.cmake | 268 | ||||
| -rw-r--r-- | project/cmake/scripts/common/ArchSetup.cmake | 155 | ||||
| -rw-r--r-- | project/cmake/scripts/common/CMakeHelpers.cmake | 54 | ||||
| -rw-r--r-- | project/cmake/scripts/common/CheckCommits.cmake | 75 | ||||
| -rw-r--r-- | project/cmake/scripts/common/CheckTargetPlatform.cmake | 67 | ||||
| -rw-r--r-- | project/cmake/scripts/common/GenerateVersionedFiles.cmake | 18 | ||||
| -rw-r--r-- | project/cmake/scripts/common/GeneratorSetup.cmake | 49 | ||||
| -rw-r--r-- | project/cmake/scripts/common/HandleDepends.cmake | 252 | ||||
| -rw-r--r-- | project/cmake/scripts/common/Macros.cmake | 622 | ||||
| -rw-r--r-- | project/cmake/scripts/common/PrepareEnv.cmake | 64 | ||||
| -rw-r--r-- | project/cmake/scripts/common/ProjectMacros.cmake | 89 | ||||
| -rw-r--r-- | project/cmake/scripts/common/Uninstall.cmake | 22 |
13 files changed, 0 insertions, 1813 deletions
diff --git a/project/cmake/scripts/common/AddOptions.cmake b/project/cmake/scripts/common/AddOptions.cmake deleted file mode 100644 index 96837c1..0000000 --- a/project/cmake/scripts/common/AddOptions.cmake +++ /dev/null | |||
| @@ -1,78 +0,0 @@ | |||
| 1 | # - Add options without repeating them on the command line | ||
| 2 | # | ||
| 3 | # Synopsis: | ||
| 4 | # | ||
| 5 | # add_options (lang build opts) | ||
| 6 | # | ||
| 7 | # where: | ||
| 8 | # | ||
| 9 | # lang Name of the language whose compiler should receive the | ||
| 10 | # options, e.g. CXX. If a comma-separated list is received | ||
| 11 | # then the option is added for all those languages. Use the | ||
| 12 | # special value ALL_LANGUAGES for these languages: CXX, C | ||
| 13 | # and Fortran | ||
| 14 | # | ||
| 15 | # build Kind of build to which this options should apply, | ||
| 16 | # such as DEBUG and RELEASE. This can also be a comma- | ||
| 17 | # separated list. Use the special value ALL_BUILDS to apply | ||
| 18 | # to all builds. | ||
| 19 | # | ||
| 20 | # opts List of options to add. Each should be quoted. | ||
| 21 | # | ||
| 22 | # Example: | ||
| 23 | # | ||
| 24 | # add_options (CXX RELEASE "-O3" "-DNDEBUG" "-Wall") | ||
| 25 | |||
| 26 | function(add_options langs builds) | ||
| 27 | # special handling of empty language specification | ||
| 28 | if("${langs}" STREQUAL "ALL_LANGUAGES") | ||
| 29 | set(langs CXX C Fortran) | ||
| 30 | endif() | ||
| 31 | foreach(lang IN LISTS langs) | ||
| 32 | # prepend underscore if necessary | ||
| 33 | foreach(build IN LISTS builds) | ||
| 34 | if(NOT ("${build}" STREQUAL "ALL_BUILDS")) | ||
| 35 | set(_bld "_${build}") | ||
| 36 | string(TOUPPER "${_bld}" _bld) | ||
| 37 | else() | ||
| 38 | set(_bld "") | ||
| 39 | endif() | ||
| 40 | foreach(_opt IN LISTS ARGN) | ||
| 41 | set(_var "CMAKE_${lang}_FLAGS${_bld}") | ||
| 42 | #message(STATUS "Adding \"${_opt}\" to \${${_var}}") | ||
| 43 | # remove it first | ||
| 44 | string(REPLACE "${_opt}" "" _without "${${_var}}") | ||
| 45 | string(STRIP "${_without}" _without) | ||
| 46 | # we need to strip this one as well, so they are comparable | ||
| 47 | string(STRIP "${${_var}}" _stripped) | ||
| 48 | # if it wasn't there, then add it at the end | ||
| 49 | if("${_without}" STREQUAL "${_stripped}") | ||
| 50 | # don't add any extra spaces if no options yet are set | ||
| 51 | if(NOT ${_stripped} STREQUAL "") | ||
| 52 | set(${_var} "${_stripped} ${_opt}") | ||
| 53 | else() | ||
| 54 | set(${_var} "${_opt}") | ||
| 55 | endif() | ||
| 56 | set(${_var} "${${_var}}" PARENT_SCOPE) | ||
| 57 | endif() | ||
| 58 | endforeach() | ||
| 59 | endforeach() | ||
| 60 | endforeach() | ||
| 61 | endfunction() | ||
| 62 | |||
| 63 | # set varname to flag unless user has specified something that matches regex | ||
| 64 | function(set_default_option varname flag regex) | ||
| 65 | if(NOT "$ENV{CXXFLAGS}" MATCHES "${regex}" | ||
| 66 | AND NOT "${CMAKE_CXX_FLAGS}" MATCHES "${regex}" | ||
| 67 | AND NOT "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}" MATCHES "${regex}") | ||
| 68 | set(${varname} ${flag} PARENT_SCOPE) | ||
| 69 | else() | ||
| 70 | set(${varname} PARENT_SCOPE) | ||
| 71 | endif() | ||
| 72 | endfunction() | ||
| 73 | |||
| 74 | # note: this must be called before project() | ||
| 75 | macro(no_default_options) | ||
| 76 | # prevent the platform probe to set options | ||
| 77 | set(CMAKE_NOT_USING_CONFIG_FLAGS TRUE) | ||
| 78 | endmacro() | ||
diff --git a/project/cmake/scripts/common/AddonHelpers.cmake b/project/cmake/scripts/common/AddonHelpers.cmake deleted file mode 100644 index 6680ed1..0000000 --- a/project/cmake/scripts/common/AddonHelpers.cmake +++ /dev/null | |||
| @@ -1,268 +0,0 @@ | |||
| 1 | # Workaround for the fact that cpack's filenames are not customizable. | ||
| 2 | # Each add-on is added as a separate component to facilitate zip/tgz packaging. | ||
| 3 | # The filenames are always of the form basename-component, which is | ||
| 4 | # incompatible with the addonid-version scheme we want. This hack renames | ||
| 5 | # the files from the file names generated by the 'package' target. | ||
| 6 | # Sadly we cannot extend the 'package' target, as it is a builtin target, see | ||
| 7 | # http://public.kitware.com/Bug/view.php?id=8438 | ||
| 8 | # Thus, we have to add an 'addon-package' target. | ||
| 9 | add_custom_target(addon-package | ||
| 10 | COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target package) | ||
| 11 | |||
| 12 | macro(add_cpack_workaround target version ext) | ||
| 13 | if(NOT PACKAGE_DIR) | ||
| 14 | set(PACKAGE_DIR "${CMAKE_INSTALL_PREFIX}/zips") | ||
| 15 | endif() | ||
| 16 | |||
| 17 | add_custom_command(TARGET addon-package PRE_BUILD | ||
| 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}) | ||
| 20 | endmacro() | ||
| 21 | |||
| 22 | # Grab the version from a given add-on's addon.xml | ||
| 23 | macro (addon_version dir prefix) | ||
| 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 | |||
| 30 | string(REGEX MATCH "<addon[^>]*version.?=.?.[0-9\\.]+" VERSION_STRING ${ADDONXML}) | ||
| 31 | string(REGEX REPLACE ".*version=.([0-9\\.]+).*" "\\1" ${prefix}_VERSION ${VERSION_STRING}) | ||
| 32 | message(STATUS ${prefix}_VERSION=${${prefix}_VERSION}) | ||
| 33 | endmacro() | ||
| 34 | |||
| 35 | # Build, link and optionally package an add-on | ||
| 36 | macro (build_addon target prefix libs) | ||
| 37 | addon_version(${target} ${prefix}) | ||
| 38 | if(${prefix}_SOURCES) | ||
| 39 | add_library(${target} ${${prefix}_SOURCES}) | ||
| 40 | target_link_libraries(${target} ${${libs}}) | ||
| 41 | set_target_properties(${target} PROPERTIES VERSION ${${prefix}_VERSION} | ||
| 42 | SOVERSION ${APP_VERSION_MAJOR}.${APP_VERSION_MINOR} | ||
| 43 | PREFIX "") | ||
| 44 | if(OS STREQUAL "android") | ||
| 45 | set_target_properties(${target} PROPERTIES PREFIX "lib") | ||
| 46 | endif() | ||
| 47 | elseif(${prefix}_CUSTOM_BINARY) | ||
| 48 | add_custom_target(${target} ALL) | ||
| 49 | endif() | ||
| 50 | |||
| 51 | # get the library's location | ||
| 52 | if(${prefix}_CUSTOM_BINARY) | ||
| 53 | list(GET ${prefix}_CUSTOM_BINARY 0 LIBRARY_LOCATION) | ||
| 54 | list(GET ${prefix}_CUSTOM_BINARY 1 LIBRARY_FILENAME) | ||
| 55 | else() | ||
| 56 | set(LIBRARY_LOCATION $<TARGET_FILE:${target}>) | ||
| 57 | # get the library's filename | ||
| 58 | if("${CORE_SYSTEM_NAME}" STREQUAL "android") | ||
| 59 | # for android we need the filename without any version numbers | ||
| 60 | set(LIBRARY_FILENAME $<TARGET_LINKER_FILE_NAME:${target}>) | ||
| 61 | else() | ||
| 62 | set(LIBRARY_FILENAME $<TARGET_FILE_NAME:${target}>) | ||
| 63 | endif() | ||
| 64 | endif() | ||
| 65 | |||
| 66 | # if there's an addon.xml.in we need to generate the addon.xml | ||
| 67 | if(EXISTS ${PROJECT_SOURCE_DIR}/${target}/addon.xml.in) | ||
| 68 | set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/${target}/addon.xml.in) | ||
| 69 | set(PLATFORM ${CORE_SYSTEM_NAME}) | ||
| 70 | |||
| 71 | file(READ ${PROJECT_SOURCE_DIR}/${target}/addon.xml.in addon_file) | ||
| 72 | string(CONFIGURE "${addon_file}" addon_file_conf @ONLY) | ||
| 73 | file(GENERATE OUTPUT ${PROJECT_SOURCE_DIR}/${target}/addon.xml CONTENT "${addon_file_conf}") | ||
| 74 | if(${APP_NAME_UC}_BUILD_DIR) | ||
| 75 | file(GENERATE OUTPUT ${${APP_NAME_UC}_BUILD_DIR}/addons/${target}/addon.xml CONTENT "${addon_file_conf}") | ||
| 76 | endif() | ||
| 77 | endif() | ||
| 78 | |||
| 79 | # if there's an settings.xml.in we need to generate the settings.xml | ||
| 80 | if(EXISTS ${PROJECT_SOURCE_DIR}/${target}/resources/settings.xml.in) | ||
| 81 | set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/${target}/resources/settings.xml.in) | ||
| 82 | set(PLATFORM ${CORE_SYSTEM_NAME}) | ||
| 83 | |||
| 84 | file(READ ${PROJECT_SOURCE_DIR}/${target}/resources/settings.xml.in settings_file) | ||
| 85 | string(CONFIGURE "${settings_file}" settings_file_conf @ONLY) | ||
| 86 | file(GENERATE OUTPUT ${PROJECT_SOURCE_DIR}/${target}/resources/settings.xml CONTENT "${settings_file_conf}") | ||
| 87 | if(${APP_NAME_UC}_BUILD_DIR) | ||
| 88 | file(GENERATE OUTPUT ${${APP_NAME_UC}_BUILD_DIR}/addons/${target}/resources/settings.xml CONTENT "${settings_file_conf}") | ||
| 89 | endif() | ||
| 90 | endif() | ||
| 91 | |||
| 92 | # set zip as default if addon-package is called without PACKAGE_XXX | ||
| 93 | set(CPACK_GENERATOR "ZIP") | ||
| 94 | set(ext "zip") | ||
| 95 | if(PACKAGE_ZIP OR PACKAGE_TGZ) | ||
| 96 | if(PACKAGE_TGZ) | ||
| 97 | set(CPACK_GENERATOR "TGZ") | ||
| 98 | set(ext "tar.gz") | ||
| 99 | endif() | ||
| 100 | set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF) | ||
| 101 | set(CPACK_PACKAGE_FILE_NAME addon) | ||
| 102 | if(CMAKE_BUILD_TYPE STREQUAL "Release") | ||
| 103 | set(CPACK_STRIP_FILES TRUE) | ||
| 104 | endif() | ||
| 105 | set(CPACK_ARCHIVE_COMPONENT_INSTALL ON) | ||
| 106 | set(CPACK_COMPONENTS_IGNORE_GROUPS 1) | ||
| 107 | list(APPEND CPACK_COMPONENTS_ALL ${target}-${${prefix}_VERSION}) | ||
| 108 | # Pack files together to create an archive | ||
| 109 | install(DIRECTORY ${target} DESTINATION ./ COMPONENT ${target}-${${prefix}_VERSION} PATTERN "xml.in" EXCLUDE) | ||
| 110 | if(WIN32) | ||
| 111 | if(NOT CPACK_PACKAGE_DIRECTORY) | ||
| 112 | # determine the temporary path | ||
| 113 | file(TO_CMAKE_PATH "$ENV{TEMP}" WIN32_TEMP_PATH) | ||
| 114 | string(LENGTH "${WIN32_TEMP_PATH}" WIN32_TEMP_PATH_LENGTH) | ||
| 115 | string(LENGTH "${PROJECT_BINARY_DIR}" PROJECT_BINARY_DIR_LENGTH) | ||
| 116 | |||
| 117 | # check if the temporary path is shorter than the default packaging directory path | ||
| 118 | if(WIN32_TEMP_PATH_LENGTH GREATER 0 AND WIN32_TEMP_PATH_LENGTH LESS PROJECT_BINARY_DIR_LENGTH) | ||
| 119 | # set the directory used by CPack for packaging to the temp directory | ||
| 120 | set(CPACK_PACKAGE_DIRECTORY ${WIN32_TEMP_PATH}) | ||
| 121 | endif() | ||
| 122 | endif() | ||
| 123 | |||
| 124 | # in case of a VC++ project the installation location contains a $(Configuration) VS variable | ||
| 125 | # we replace it with ${CMAKE_BUILD_TYPE} (which doesn't cover the case when the build configuration | ||
| 126 | # is changed within Visual Studio) | ||
| 127 | string(REPLACE "$(Configuration)" "${CMAKE_BUILD_TYPE}" LIBRARY_LOCATION "${LIBRARY_LOCATION}") | ||
| 128 | |||
| 129 | if(${prefix}_SOURCES) | ||
| 130 | # install the generated DLL file | ||
| 131 | install(PROGRAMS ${LIBRARY_LOCATION} DESTINATION ${target} | ||
| 132 | COMPONENT ${target}-${${prefix}_VERSION}) | ||
| 133 | |||
| 134 | if(CMAKE_BUILD_TYPE MATCHES Debug) | ||
| 135 | # for debug builds also install the PDB file | ||
| 136 | get_filename_component(LIBRARY_DIR ${LIBRARY_LOCATION} DIRECTORY) | ||
| 137 | install(FILES $<TARGET_PDB_FILE:${target}> DESTINATION ${target} | ||
| 138 | COMPONENT ${target}-${${prefix}_VERSION}) | ||
| 139 | endif() | ||
| 140 | endif() | ||
| 141 | if (${prefix}_CUSTOM_BINARY) | ||
| 142 | list(GET ${prefix}_CUSTOM_BINARY 0 FROM_BINARY) | ||
| 143 | list(GET ${prefix}_CUSTOM_BINARY 1 TO_BINARY) | ||
| 144 | install(FILES ${FROM_BINARY} DESTINATION ${target} RENAME ${TO_BINARY}) | ||
| 145 | endif() | ||
| 146 | if(${prefix}_CUSTOM_DATA) | ||
| 147 | install(DIRECTORY ${${prefix}_CUSTOM_DATA} DESTINATION ${target}/resources) | ||
| 148 | endif() | ||
| 149 | else() | ||
| 150 | if(NOT CPACK_PACKAGE_DIRECTORY) | ||
| 151 | set(CPACK_PACKAGE_DIRECTORY ${CMAKE_BINARY_DIR}) | ||
| 152 | endif() | ||
| 153 | if(${prefix}_SOURCES) | ||
| 154 | install(TARGETS ${target} DESTINATION ${target} | ||
| 155 | COMPONENT ${target}-${${prefix}_VERSION}) | ||
| 156 | endif() | ||
| 157 | if (${prefix}_CUSTOM_BINARY) | ||
| 158 | list(GET ${prefix}_CUSTOM_BINARY 0 FROM_BINARY) | ||
| 159 | list(GET ${prefix}_CUSTOM_BINARY 1 TO_BINARY) | ||
| 160 | if(OS STREQUAL "android") | ||
| 161 | set(TO_BINARY "lib${TO_BINARY}") | ||
| 162 | endif() | ||
| 163 | install(FILES ${FROM_BINARY} DESTINATION ${target} RENAME ${TO_BINARY} | ||
| 164 | COMPONENT ${target}-${${prefix}_VERSION}) | ||
| 165 | endif() | ||
| 166 | if(${prefix}_CUSTOM_DATA) | ||
| 167 | install(DIRECTORY ${${prefix}_CUSTOM_DATA} DESTINATION ${target}/resources) | ||
| 168 | endif() | ||
| 169 | endif() | ||
| 170 | add_cpack_workaround(${target} ${${prefix}_VERSION} ${ext}) | ||
| 171 | else() | ||
| 172 | if(CORE_SYSTEM_NAME STREQUAL linux OR CORE_SYSTEM_NAME STREQUAL rbpi OR CORE_SYSTEM_NAME STREQUAL freebsd) | ||
| 173 | if(NOT OVERRIDE_PATHS) | ||
| 174 | if(CMAKE_INSTALL_PREFIX AND NOT CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND NOT CMAKE_INSTALL_PREFIX STREQUAL "${${APP_NAME_UC}_PREFIX}") | ||
| 175 | message(WARNING "CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} differs from ${APP_NAME} prefix, changing to ${${APP_NAME_UC}_PREFIX}. Please pass -DOVERRIDE_PATHS=1 to skip this check") | ||
| 176 | endif() | ||
| 177 | if(CMAKE_INSTALL_LIBDIR AND NOT CMAKE_INSTALL_LIBDIR STREQUAL "${${APP_NAME_UC}_LIB_DIR}") | ||
| 178 | message(WARNING "CMAKE_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR} differs from ${APP_NAME} libdir, changing to ${${APP_NAME_UC}_LIB_DIR}. Please pass -DOVERRIDE_PATHS=1 to skip this check") | ||
| 179 | endif() | ||
| 180 | if(CMAKE_INSTALL_DATADIR AND NOT CMAKE_INSTALL_DATADIR STREQUAL "${${APP_NAME_UC}_DATA_DIR}") | ||
| 181 | message(WARNING "CMAKE_INSTALL_DATADIR ${CMAKE_INSTALL_DATADIR} differs from ${APP_NAME} datadir, changing to ${${APP_NAME_UC}_DATA_DIR}. Please pass -DOVERRIDE_PATHS=1 to skip this check") | ||
| 182 | endif() | ||
| 183 | set(CMAKE_INSTALL_PREFIX "${${APP_NAME_UC}_PREFIX}" CACHE PATH "${APP_NAME} install prefix" FORCE) | ||
| 184 | set(CMAKE_INSTALL_LIBDIR "${${APP_NAME_UC}_LIB_DIR}" CACHE PATH "${APP_NAME} install libdir" FORCE) | ||
| 185 | set(CMAKE_INSTALL_DATADIR "${${APP_NAME_UC}_DATA_DIR}" CACHE PATH "${APP_NAME} install datadir" FORCE) | ||
| 186 | else() | ||
| 187 | if(NOT CMAKE_INSTALL_LIBDIR) | ||
| 188 | set(CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_PREFIX}/lib/${APP_NAME_LC}") | ||
| 189 | endif() | ||
| 190 | if(NOT CMAKE_INSTALL_DATADIR) | ||
| 191 | set(CMAKE_INSTALL_DATADIR "${CMAKE_INSTALL_PREFIX}/share/${APP_NAME_LC}") | ||
| 192 | endif() | ||
| 193 | endif() | ||
| 194 | else() | ||
| 195 | set(CMAKE_INSTALL_LIBDIR "lib/${APP_NAME_LC}") | ||
| 196 | set(CMAKE_INSTALL_DATADIR "share/${APP_NAME_LC}") | ||
| 197 | endif() | ||
| 198 | if(${prefix}_SOURCES) | ||
| 199 | install(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/addons/${target}) | ||
| 200 | endif() | ||
| 201 | if (${prefix}_CUSTOM_BINARY) | ||
| 202 | list(GET ${prefix}_CUSTOM_BINARY 0 FROM_BINARY) | ||
| 203 | list(GET ${prefix}_CUSTOM_BINARY 1 TO_BINARY) | ||
| 204 | if(OS STREQUAL "android") | ||
| 205 | set(TO_BINARY "lib${TO_BINARY}") | ||
| 206 | endif() | ||
| 207 | install(FILES ${FROM_BINARY} DESTINATION ${CMAKE_INSTALL_LIBDIR}/addons/${target} RENAME ${TO_BINARY}) | ||
| 208 | endif() | ||
| 209 | install(DIRECTORY ${target} DESTINATION ${CMAKE_INSTALL_DATADIR}/addons PATTERN "xml.in" EXCLUDE) | ||
| 210 | if(${prefix}_CUSTOM_DATA) | ||
| 211 | install(DIRECTORY ${${prefix}_CUSTOM_DATA} DESTINATION ${CMAKE_INSTALL_DATADIR}/addons/${target}/resources) | ||
| 212 | endif() | ||
| 213 | endif() | ||
| 214 | if(${APP_NAME_UC}_BUILD_DIR) | ||
| 215 | file(GLOB_RECURSE files ${CMAKE_CURRENT_SOURCE_DIR}/${target}/*) | ||
| 216 | if(${prefix}_CUSTOM_DATA) | ||
| 217 | add_custom_command(TARGET ${target} POST_BUILD | ||
| 218 | COMMAND ${CMAKE_COMMAND} -E copy_directory | ||
| 219 | ${${prefix}_CUSTOM_DATA} | ||
| 220 | ${${APP_NAME_UC}_BUILD_DIR}/addons/${target}/resources) | ||
| 221 | endif() | ||
| 222 | foreach(file ${files}) | ||
| 223 | string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/${target}/" "" name "${file}") | ||
| 224 | # A good way to deal with () in filenames | ||
| 225 | if(NOT ${file} MATCHES xml.in) | ||
| 226 | configure_file(${file} ${${APP_NAME_UC}_BUILD_DIR}/addons/${target}/${name} COPYONLY) | ||
| 227 | endif() | ||
| 228 | endforeach() | ||
| 229 | add_custom_command(TARGET ${target} POST_BUILD | ||
| 230 | COMMAND ${CMAKE_COMMAND} -E copy | ||
| 231 | ${LIBRARY_LOCATION} | ||
| 232 | ${${APP_NAME_UC}_BUILD_DIR}/addons/${target}/${LIBRARY_FILENAME}) | ||
| 233 | endif() | ||
| 234 | endmacro() | ||
| 235 | |||
| 236 | # finds a path to a given file (recursive) | ||
| 237 | function (kodi_find_path var_name filename search_path strip_file) | ||
| 238 | file(GLOB_RECURSE PATH_TO_FILE ${search_path} ${filename}) | ||
| 239 | if(strip_file) | ||
| 240 | string(REPLACE ${filename} "" PATH_TO_FILE ${PATH_TO_FILE}) | ||
| 241 | endif() | ||
| 242 | set (${var_name} ${PATH_TO_FILE} PARENT_SCOPE) | ||
| 243 | endfunction() | ||
| 244 | |||
| 245 | # Cmake build options | ||
| 246 | include(AddOptions) | ||
| 247 | include(TestCXXAcceptsFlag) | ||
| 248 | option(PACKAGE_ZIP "Package Zip file?" OFF) | ||
| 249 | option(PACKAGE_TGZ "Package TGZ file?" OFF) | ||
| 250 | option(BUILD_SHARED_LIBS "Build shared libs?" ON) | ||
| 251 | |||
| 252 | # LTO support? | ||
| 253 | CHECK_CXX_ACCEPTS_FLAG("-flto" HAVE_LTO) | ||
| 254 | if(HAVE_LTO) | ||
| 255 | option(USE_LTO "use link time optimization" OFF) | ||
| 256 | if(USE_LTO) | ||
| 257 | add_options(ALL_LANGUAGES ALL_BUILDS "-flto") | ||
| 258 | endif() | ||
| 259 | endif() | ||
| 260 | |||
| 261 | # set this to try linking dependencies as static as possible | ||
| 262 | if(ADDONS_PREFER_STATIC_LIBS) | ||
| 263 | set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) | ||
| 264 | endif() | ||
| 265 | |||
| 266 | if(${APP_NAME_UC}_BUILD_DIR) | ||
| 267 | list(APPEND CMAKE_PREFIX_PATH ${${APP_NAME_UC}_BUILD_DIR}/build) | ||
| 268 | endif() | ||
diff --git a/project/cmake/scripts/common/ArchSetup.cmake b/project/cmake/scripts/common/ArchSetup.cmake deleted file mode 100644 index 538fcaf..0000000 --- a/project/cmake/scripts/common/ArchSetup.cmake +++ /dev/null | |||
| @@ -1,155 +0,0 @@ | |||
| 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 | include(CheckIncludeFile) | ||
| 18 | |||
| 19 | # Macro to check if a given type exists in a given header | ||
| 20 | # Arguments: | ||
| 21 | # header the header to check | ||
| 22 | # type the type to check for existence | ||
| 23 | # var the compiler definition to set if type exists | ||
| 24 | # On return: | ||
| 25 | # If type was found, the definition is added to SYSTEM_DEFINES | ||
| 26 | macro(check_type header type var) | ||
| 27 | check_cxx_source_compiles("#include <${header}> | ||
| 28 | int main() | ||
| 29 | { | ||
| 30 | ${type} s; | ||
| 31 | }" ${var}) | ||
| 32 | if(${var}) | ||
| 33 | list(APPEND SYSTEM_DEFINES -D${var}=1) | ||
| 34 | endif() | ||
| 35 | endmacro() | ||
| 36 | |||
| 37 | # Macro to check if a given builtin function exists | ||
| 38 | # Arguments: | ||
| 39 | # func the function to check | ||
| 40 | # var the compiler definition to set if type exists | ||
| 41 | # On return: | ||
| 42 | # If type was found, the definition is added to SYSTEM_DEFINES | ||
| 43 | macro(check_builtin func var) | ||
| 44 | check_cxx_source_compiles(" | ||
| 45 | int main() | ||
| 46 | { | ||
| 47 | ${func}; | ||
| 48 | }" ${var}) | ||
| 49 | if(${var}) | ||
| 50 | list(APPEND SYSTEM_DEFINES -D${var}=1) | ||
| 51 | endif() | ||
| 52 | endmacro() | ||
| 53 | |||
| 54 | |||
| 55 | # -------- Main script --------- | ||
| 56 | message(STATUS "System type: ${CMAKE_SYSTEM_NAME}") | ||
| 57 | if(NOT CORE_SYSTEM_NAME) | ||
| 58 | string(TOLOWER ${CMAKE_SYSTEM_NAME} CORE_SYSTEM_NAME) | ||
| 59 | endif() | ||
| 60 | |||
| 61 | if(WITH_CPU) | ||
| 62 | set(CPU ${WITH_CPU}) | ||
| 63 | elseif(NOT CMAKE_TOOLCHAIN_FILE) | ||
| 64 | set(CPU ${CMAKE_SYSTEM_PROCESSOR}) | ||
| 65 | endif() | ||
| 66 | |||
| 67 | if(CMAKE_TOOLCHAIN_FILE) | ||
| 68 | if(NOT EXISTS "${CMAKE_TOOLCHAIN_FILE}") | ||
| 69 | message(FATAL_ERROR "Toolchain file ${CMAKE_TOOLCHAIN_FILE} does not exist.") | ||
| 70 | elseif(NOT DEPENDS_PATH OR NOT NATIVEPREFIX) | ||
| 71 | message(FATAL_ERROR "Toolchain did not define DEPENDS_PATH or NATIVEPREFIX. Possibly outdated depends.") | ||
| 72 | endif() | ||
| 73 | endif() | ||
| 74 | |||
| 75 | # While CMAKE_CROSSCOMPILING is set unconditionally if there's a toolchain file, | ||
| 76 | # this variable is set if we can execute build artefacts on the host system (for example unit tests). | ||
| 77 | if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL CMAKE_SYSTEM_PROCESSOR AND | ||
| 78 | CMAKE_HOST_SYSTEM_NAME STREQUAL CMAKE_SYSTEM_NAME) | ||
| 79 | set(CORE_HOST_IS_TARGET TRUE) | ||
| 80 | else() | ||
| 81 | set(CORE_HOST_IS_TARGET FALSE) | ||
| 82 | endif() | ||
| 83 | |||
| 84 | # Main cpp | ||
| 85 | set(CORE_MAIN_SOURCE ${CORE_SOURCE_DIR}/xbmc/platform/posix/main.cpp) | ||
| 86 | |||
| 87 | # system specific arch setup | ||
| 88 | if(NOT EXISTS ${PROJECT_SOURCE_DIR}/scripts/${CORE_SYSTEM_NAME}/ArchSetup.cmake) | ||
| 89 | message(FATAL_ERROR "Couldn't find configuration for '${CORE_SYSTEM_NAME}' " | ||
| 90 | "Either the platform is not (yet) supported " | ||
| 91 | "or a toolchain file has to be specified. " | ||
| 92 | "Consult ${CMAKE_SOURCE_DIR}/README.md for instructions. " | ||
| 93 | "Note: Specifying a toolchain requires a clean build directory!") | ||
| 94 | endif() | ||
| 95 | include(${PROJECT_SOURCE_DIR}/scripts/${CORE_SYSTEM_NAME}/ArchSetup.cmake) | ||
| 96 | |||
| 97 | message(STATUS "Core system type: ${CORE_SYSTEM_NAME}") | ||
| 98 | message(STATUS "Platform: ${PLATFORM}") | ||
| 99 | message(STATUS "CPU: ${CPU}, ARCH: ${ARCH}") | ||
| 100 | message(STATUS "Cross-Compiling: ${CMAKE_CROSSCOMPILING}") | ||
| 101 | message(STATUS "Execute build artefacts on host: ${CORE_HOST_IS_TARGET}") | ||
| 102 | |||
| 103 | check_type(string std::u16string HAVE_STD__U16_STRING) | ||
| 104 | check_type(string std::u32string HAVE_STD__U32_STRING) | ||
| 105 | check_type(string char16_t HAVE_CHAR16_T) | ||
| 106 | check_type(string char32_t HAVE_CHAR32_T) | ||
| 107 | check_type(stdint.h uint_least16_t HAVE_STDINT_H) | ||
| 108 | check_symbol_exists(posix_fadvise fcntl.h HAVE_POSIX_FADVISE) | ||
| 109 | check_symbol_exists(PRIdMAX inttypes.h HAVE_INTTYPES_H) | ||
| 110 | check_builtin("long* temp=0; long ret=__sync_add_and_fetch(temp, 1)" HAS_BUILTIN_SYNC_ADD_AND_FETCH) | ||
| 111 | check_builtin("long* temp=0; long ret=__sync_sub_and_fetch(temp, 1)" HAS_BUILTIN_SYNC_SUB_AND_FETCH) | ||
| 112 | check_builtin("long* temp=0; long ret=__sync_val_compare_and_swap(temp, 1, 1)" HAS_BUILTIN_SYNC_VAL_COMPARE_AND_SWAP) | ||
| 113 | check_include_file(sys/inotify.h HAVE_INOTIFY) | ||
| 114 | if(HAVE_INOTIFY) | ||
| 115 | list(APPEND SYSTEM_DEFINES -DHAVE_INOTIFY=1) | ||
| 116 | endif() | ||
| 117 | if(HAVE_POSIX_FADVISE) | ||
| 118 | list(APPEND SYSTEM_DEFINES -DHAVE_POSIX_FADVISE=1) | ||
| 119 | endif() | ||
| 120 | check_function_exists(localtime_r HAVE_LOCALTIME_R) | ||
| 121 | if(HAVE_LOCALTIME_R) | ||
| 122 | list(APPEND SYSTEM_DEFINES -DHAVE_LOCALTIME_R=1) | ||
| 123 | endif() | ||
| 124 | if(HAVE_INTTYPES_H) | ||
| 125 | list(APPEND SYSTEM_DEFINES -DHAVE_INTTYPES_H=1) | ||
| 126 | endif() | ||
| 127 | |||
| 128 | find_package(SSE) | ||
| 129 | foreach(_sse SSE SSE2 SSE3 SSSE3 SSE4_1 SSE4_2 AVX AVX2) | ||
| 130 | if(${${_sse}_FOUND}) | ||
| 131 | # enable SSE versions up to 4.1 by default, if available | ||
| 132 | if(NOT ${_sse} MATCHES "AVX" AND NOT ${_sse} STREQUAL "SSE4_2") | ||
| 133 | option(ENABLE_${_sse} "Enable ${_sse}" ON) | ||
| 134 | else() | ||
| 135 | option(ENABLE_${_sse} "Enable ${_sse}" OFF) | ||
| 136 | endif() | ||
| 137 | endif() | ||
| 138 | if(ENABLE_${_sse}) | ||
| 139 | set(HAVE_${_sse} TRUE CACHE STRING "${_sse} enabled") | ||
| 140 | list(APPEND ARCH_DEFINES -DHAVE_${_sse}=1) | ||
| 141 | endif() | ||
| 142 | endforeach() | ||
| 143 | |||
| 144 | if(NOT DEFINED NEON OR NEON) | ||
| 145 | option(ENABLE_NEON "Enable NEON optimization" ${NEON}) | ||
| 146 | if(ENABLE_NEON) | ||
| 147 | message(STATUS "NEON optimization enabled") | ||
| 148 | add_options(CXX ALL_BUILDS "-mfpu=neon -mvectorize-with-neon-quad") | ||
| 149 | endif() | ||
| 150 | endif() | ||
| 151 | |||
| 152 | if(CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
| 153 | add_options (ALL_LANGUAGES DEBUG "-g" "-D_DEBUG" "-Wall") | ||
| 154 | endif() | ||
| 155 | |||
diff --git a/project/cmake/scripts/common/CMakeHelpers.cmake b/project/cmake/scripts/common/CMakeHelpers.cmake deleted file mode 100644 index 995c38a..0000000 --- a/project/cmake/scripts/common/CMakeHelpers.cmake +++ /dev/null | |||
| @@ -1,54 +0,0 @@ | |||
| 1 | # This file contains functions that support the debugging of the CMake files. | ||
| 2 | |||
| 3 | # This file shouldn't be included per default in any CMake file. It should be | ||
| 4 | # included and used only on demand. All functions are prefixed with "debug_". | ||
| 5 | # | ||
| 6 | # Usage: | ||
| 7 | # include(scripts/common/CMakeHelpers.cmake) | ||
| 8 | # debug_print_variables() | ||
| 9 | |||
| 10 | # Print all CMake variables. | ||
| 11 | macro(debug_print_variables) | ||
| 12 | get_cmake_property(_variableNames VARIABLES) | ||
| 13 | foreach(_variableName ${_variableNames}) | ||
| 14 | message(STATUS "${_variableName} = ${${_variableName}}") | ||
| 15 | endforeach() | ||
| 16 | endmacro() | ||
| 17 | |||
| 18 | # Get all properties that CMake supports and convert them to a list. | ||
| 19 | function(debug_get_properties VAR) | ||
| 20 | execute_process(COMMAND cmake --help-property-list | ||
| 21 | OUTPUT_VARIABLE _properties) | ||
| 22 | string(REGEX REPLACE ";" "\\\\;" _properties "${_properties}") | ||
| 23 | string(REGEX REPLACE "\n" ";" _properties "${_properties}") | ||
| 24 | list(REMOVE_DUPLICATES _properties) | ||
| 25 | list(REMOVE_ITEM _properties LOCATION) | ||
| 26 | set(${VAR} ${_properties} PARENT_SCOPE) | ||
| 27 | endfunction() | ||
| 28 | |||
| 29 | # List all properties. | ||
| 30 | function(debug_list_properties) | ||
| 31 | debug_get_properties(_properties) | ||
| 32 | message("CMake properties = ${_properties}") | ||
| 33 | endfunction() | ||
| 34 | |||
| 35 | # Print all set properties of a specified target. | ||
| 36 | function(debug_print_target_properties target) | ||
| 37 | if(NOT TARGET ${target}) | ||
| 38 | message(FATAL_ERROR "There is no target named '${target}'") | ||
| 39 | endif() | ||
| 40 | |||
| 41 | debug_get_properties(_properties) | ||
| 42 | |||
| 43 | # Reading LOCATION property is deprecated and triggers a fatal error. | ||
| 44 | string(REGEX REPLACE ";LOCATION;|LOCATION" "" _properties "${_properties}") | ||
| 45 | string(REGEX REPLACE "<CONFIG>" "${CMAKE_BUILD_TYPE}" _properties | ||
| 46 | "${_properties}") | ||
| 47 | foreach(_property ${_properties}) | ||
| 48 | get_property(_value TARGET ${target} PROPERTY ${_property} SET) | ||
| 49 | if(_value) | ||
| 50 | get_target_property(_value ${target} ${_property}) | ||
| 51 | message("${target} ${_property} = ${_value}") | ||
| 52 | endif() | ||
| 53 | endforeach() | ||
| 54 | endfunction() | ||
diff --git a/project/cmake/scripts/common/CheckCommits.cmake b/project/cmake/scripts/common/CheckCommits.cmake deleted file mode 100644 index 304e623..0000000 --- a/project/cmake/scripts/common/CheckCommits.cmake +++ /dev/null | |||
| @@ -1,75 +0,0 @@ | |||
| 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/CheckTargetPlatform.cmake b/project/cmake/scripts/common/CheckTargetPlatform.cmake deleted file mode 100644 index 82ee668..0000000 --- a/project/cmake/scripts/common/CheckTargetPlatform.cmake +++ /dev/null | |||
| @@ -1,67 +0,0 @@ | |||
| 1 | # handle target platforms | ||
| 2 | function(check_target_platform dir target_platform build) | ||
| 3 | # param[in] dir path/directory of the addon/dependency | ||
| 4 | # param[in] target_platform target platform of the build | ||
| 5 | # param[out] build Result whether the addon/dependency should be built for the specified target platform | ||
| 6 | |||
| 7 | set(${build} FALSE) | ||
| 8 | # check if the given directory exists and contains a platforms.txt | ||
| 9 | if(EXISTS ${dir} AND EXISTS ${dir}/platforms.txt) | ||
| 10 | # get all the specified platforms | ||
| 11 | file(STRINGS ${dir}/platforms.txt platforms) | ||
| 12 | |||
| 13 | list( LENGTH platforms listlen ) | ||
| 14 | if(${listlen} EQUAL 1) | ||
| 15 | string(REPLACE " " ";" platforms ${platforms}) | ||
| 16 | endif() | ||
| 17 | |||
| 18 | # check if the addon/dependency should be built for the current platform | ||
| 19 | foreach(platform ${platforms}) | ||
| 20 | if(${platform} STREQUAL "all" OR ${platform} STREQUAL ${target_platform}) | ||
| 21 | set(${build} TRUE) | ||
| 22 | else() | ||
| 23 | # check if the platform is defined as "!<platform>" | ||
| 24 | string(SUBSTRING ${platform} 0 1 platform_first) | ||
| 25 | if(${platform_first} STREQUAL "!") | ||
| 26 | # extract the platform | ||
| 27 | string(LENGTH ${platform} platform_length) | ||
| 28 | math(EXPR platform_length "${platform_length} - 1") | ||
| 29 | string(SUBSTRING ${platform} 1 ${platform_length} platform) | ||
| 30 | |||
| 31 | # check if the current platform does not match the extracted platform | ||
| 32 | if(NOT ${platform} STREQUAL ${target_platform}) | ||
| 33 | set(${build} TRUE) | ||
| 34 | endif() | ||
| 35 | endif() | ||
| 36 | endif() | ||
| 37 | endforeach() | ||
| 38 | else() | ||
| 39 | set(${build} TRUE) | ||
| 40 | endif() | ||
| 41 | |||
| 42 | # make the ${build} variable available to the calling script | ||
| 43 | set(${build} "${${build}}" PARENT_SCOPE) | ||
| 44 | endfunction() | ||
| 45 | |||
| 46 | function(check_install_permissions install_dir have_perms) | ||
| 47 | # param[in] install_dir directory to check for write permissions | ||
| 48 | # param[out] have_perms wether we have permissions to install to install_dir | ||
| 49 | |||
| 50 | set(testfile_lib ${install_dir}/lib/kodi/.cmake-inst-test) | ||
| 51 | set(testfile_share ${install_dir}/share/kodi/.cmake-inst-test) | ||
| 52 | get_filename_component(testdir_lib ${testfile_lib} DIRECTORY) | ||
| 53 | get_filename_component(testdir_share ${testfile_share} DIRECTORY) | ||
| 54 | |||
| 55 | execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${testdir_lib}) | ||
| 56 | execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${testdir_share}) | ||
| 57 | execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${testfile_lib}) | ||
| 58 | execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${testfile_share}) | ||
| 59 | |||
| 60 | if(EXISTS ${testfile_lib} AND EXISTS ${testfile_share}) | ||
| 61 | set(${have_perms} True PARENT_SCOPE) | ||
| 62 | else() | ||
| 63 | message(STATUS "check_install_permissions ${install_dir}: failed to create files") | ||
| 64 | set(${have_perms} False PARENT_SCOPE) | ||
| 65 | endif() | ||
| 66 | file(REMOVE ${testfile_lib} ${testfile_share}) | ||
| 67 | endfunction() | ||
diff --git a/project/cmake/scripts/common/GenerateVersionedFiles.cmake b/project/cmake/scripts/common/GenerateVersionedFiles.cmake deleted file mode 100644 index e105b27..0000000 --- a/project/cmake/scripts/common/GenerateVersionedFiles.cmake +++ /dev/null | |||
| @@ -1,18 +0,0 @@ | |||
| 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 | |||
| 7 | # configure_file without dependency tracking | ||
| 8 | # configure_file would register additional file dependencies that interfere | ||
| 9 | # with the ones from add_custom_command (and the generation would happen twice) | ||
| 10 | function(generate_versioned_file _SRC _DEST) | ||
| 11 | file(READ ${CORE_SOURCE_DIR}/${_SRC} file_content) | ||
| 12 | string(CONFIGURE "${file_content}" file_content @ONLY) | ||
| 13 | file(WRITE ${CMAKE_BINARY_DIR}/${_DEST} "${file_content}") | ||
| 14 | endfunction() | ||
| 15 | |||
| 16 | generate_versioned_file(addons/xbmc.addon/addon.xml.in addons/xbmc.addon/addon.xml) | ||
| 17 | generate_versioned_file(addons/kodi.guilib/addon.xml.in addons/kodi.guilib/addon.xml) | ||
| 18 | generate_versioned_file(xbmc/CompileInfo.cpp.in ${CORE_BUILD_DIR}/xbmc/CompileInfo.cpp) | ||
diff --git a/project/cmake/scripts/common/GeneratorSetup.cmake b/project/cmake/scripts/common/GeneratorSetup.cmake deleted file mode 100644 index 304b504..0000000 --- a/project/cmake/scripts/common/GeneratorSetup.cmake +++ /dev/null | |||
| @@ -1,49 +0,0 @@ | |||
| 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() | ||
| 25 | |||
| 26 | # Print CMake version | ||
| 27 | message(STATUS "CMake Version: ${CMAKE_VERSION}") | ||
| 28 | |||
| 29 | # Deal with CMake special cases | ||
| 30 | if(CMAKE_VERSION VERSION_EQUAL 3.5.1) | ||
| 31 | message(WARNING "CMake 3.5.1 introduced a crash during configuration. " | ||
| 32 | "Please consider upgrading to 3.5.2 (cmake.org/Bug/view.php?id=16044)") | ||
| 33 | endif() | ||
| 34 | |||
| 35 | # Darwin needs CMake 3.4 | ||
| 36 | if(APPLE AND CMAKE_VERSION VERSION_LESS 3.4) | ||
| 37 | message(WARNING "Build on Darwin requires CMake 3.4 or later (tdb library support) " | ||
| 38 | "or the usage of the patched version in depends.") | ||
| 39 | endif() | ||
| 40 | |||
| 41 | # Windows needs CMake 3.6 (VS_STARTUP_PROJECT) | ||
| 42 | if(WIN32 AND CMAKE_VERSION VERSION_LESS 3.6) | ||
| 43 | message(FATAL_ERROR "Build on Windows needs CMake 3.6 or later") | ||
| 44 | endif() | ||
| 45 | |||
| 46 | # Ninja needs CMake 3.2 due to ExternalProject BUILD_BYPRODUCTS usage | ||
| 47 | if(CMAKE_GENERATOR STREQUAL Ninja AND CMAKE_VERSION VERSION_LESS 3.2) | ||
| 48 | message(FATAL_ERROR "Generator: Ninja requires CMake 3.2 or later") | ||
| 49 | endif() | ||
diff --git a/project/cmake/scripts/common/HandleDepends.cmake b/project/cmake/scripts/common/HandleDepends.cmake deleted file mode 100644 index adc105b..0000000 --- a/project/cmake/scripts/common/HandleDepends.cmake +++ /dev/null | |||
| @@ -1,252 +0,0 @@ | |||
| 1 | include(${CORE_SOURCE_DIR}/project/cmake/scripts/common/CheckTargetPlatform.cmake) | ||
| 2 | |||
| 3 | # handle addon depends | ||
| 4 | function(add_addon_depends addon searchpath) | ||
| 5 | # input: string addon string searchpath | ||
| 6 | |||
| 7 | set(OUTPUT_DIR ${ADDON_DEPENDS_PATH}) | ||
| 8 | # look for platform-specific dependencies | ||
| 9 | file(GLOB_RECURSE cmake_input_files ${searchpath}/${CORE_SYSTEM_NAME}/*.txt) | ||
| 10 | file(GLOB_RECURSE cmake_input_files2 ${searchpath}/common/*.txt) | ||
| 11 | list(APPEND cmake_input_files ${cmake_input_files2}) | ||
| 12 | |||
| 13 | foreach(file ${cmake_input_files}) | ||
| 14 | set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${file}) | ||
| 15 | if(NOT (file MATCHES CMakeLists.txt OR | ||
| 16 | file MATCHES install.txt OR | ||
| 17 | file MATCHES noinstall.txt OR | ||
| 18 | file MATCHES flags.txt OR | ||
| 19 | file MATCHES deps.txt OR | ||
| 20 | file MATCHES "[a-z]+-deps[.]txt" OR | ||
| 21 | file MATCHES platforms.txt)) | ||
| 22 | message(STATUS "Processing ${file}") | ||
| 23 | file(STRINGS ${file} def) | ||
| 24 | string(REPLACE " " ";" def ${def}) | ||
| 25 | list(LENGTH def deflength) | ||
| 26 | get_filename_component(dir ${file} DIRECTORY) | ||
| 27 | |||
| 28 | # get the id of the dependency | ||
| 29 | if(NOT "${def}" STREQUAL "") | ||
| 30 | # read the id from the file | ||
| 31 | list(GET def 0 id) | ||
| 32 | else() | ||
| 33 | # read the id from the filename | ||
| 34 | get_filename_component(id ${file} NAME_WE) | ||
| 35 | endif() | ||
| 36 | |||
| 37 | # check if the dependency has a platforms.txt | ||
| 38 | set(platform_found FALSE) | ||
| 39 | check_target_platform(${dir} ${CORE_SYSTEM_NAME} platform_found) | ||
| 40 | |||
| 41 | if(${platform_found} AND NOT TARGET ${id}) | ||
| 42 | # determine the download URL of the dependency | ||
| 43 | set(url "") | ||
| 44 | if(deflength GREATER 1) | ||
| 45 | list(GET def 1 url) | ||
| 46 | message(STATUS "${id} url: ${url}") | ||
| 47 | endif() | ||
| 48 | |||
| 49 | # check if there are any library specific flags that need to be passed on | ||
| 50 | if(EXISTS ${dir}/flags.txt) | ||
| 51 | set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${dir}/flags.txt) | ||
| 52 | file(STRINGS ${dir}/flags.txt extraflags) | ||
| 53 | |||
| 54 | # replace some custom placeholders | ||
| 55 | string(REPLACE "@MINGW_TOOLCHAIN_FILE@" "${OUTPUT_DIR}/Toolchain_mingw32.cmake" extraflags "${extraflags}") | ||
| 56 | string(REPLACE " " ";" extraflags ${extraflags}) | ||
| 57 | |||
| 58 | message(STATUS "${id} extraflags: ${extraflags}") | ||
| 59 | endif() | ||
| 60 | |||
| 61 | set(BUILD_ARGS -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} | ||
| 62 | -DOUTPUT_DIR=${OUTPUT_DIR} | ||
| 63 | -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} | ||
| 64 | -DCMAKE_USER_MAKE_RULES_OVERRIDE=${CMAKE_USER_MAKE_RULES_OVERRIDE} | ||
| 65 | -DCMAKE_USER_MAKE_RULES_OVERRIDE_CXX=${CMAKE_USER_MAKE_RULES_OVERRIDE_CXX} | ||
| 66 | -DCMAKE_INSTALL_PREFIX=${OUTPUT_DIR} | ||
| 67 | -DCORE_SYSTEM_NAME=${CORE_SYSTEM_NAME} | ||
| 68 | -DENABLE_STATIC=1 | ||
| 69 | -DBUILD_SHARED_LIBS=0) | ||
| 70 | # if there are no make rules override files available take care of manually passing on ARCH_DEFINES | ||
| 71 | if(NOT CMAKE_USER_MAKE_RULES_OVERRIDE AND NOT CMAKE_USER_MAKE_RULES_OVERRIDE_CXX) | ||
| 72 | # make sure we create strings, not lists | ||
| 73 | set(TMP_C_FLAGS "${CMAKE_C_FLAGS} ${ARCH_DEFINES}") | ||
| 74 | set(TMP_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARCH_DEFINES}") | ||
| 75 | list(APPEND BUILD_ARGS -DCMAKE_C_FLAGS=${TMP_C_FLAGS} | ||
| 76 | -DCMAKE_CXX_FLAGS=${TMP_CXX_FLAGS}) | ||
| 77 | endif() | ||
| 78 | |||
| 79 | if(CMAKE_TOOLCHAIN_FILE) | ||
| 80 | list(APPEND BUILD_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) | ||
| 81 | message("toolchain specified") | ||
| 82 | message(${BUILD_ARGS}) | ||
| 83 | endif() | ||
| 84 | |||
| 85 | # prepare patchfile. ensure we have a clean file after reconfiguring | ||
| 86 | set(PATCH_FILE ${BUILD_DIR}/${id}/tmp/patch.cmake) | ||
| 87 | file(REMOVE ${PATCH_FILE}) | ||
| 88 | |||
| 89 | # if there's a CMakeLists.txt use it to prepare the build | ||
| 90 | if(EXISTS ${dir}/CMakeLists.txt) | ||
| 91 | set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${dir}/CMakeLists.txt) | ||
| 92 | file(APPEND ${PATCH_FILE} | ||
| 93 | "file(COPY ${dir}/CMakeLists.txt | ||
| 94 | DESTINATION ${BUILD_DIR}/${id}/src/${id})\n") | ||
| 95 | endif() | ||
| 96 | |||
| 97 | # check if we have patches to apply | ||
| 98 | file(GLOB patches ${dir}/*.patch) | ||
| 99 | list(SORT patches) | ||
| 100 | foreach(patch ${patches}) | ||
| 101 | if(NOT PATCH_PROGRAM OR "${PATCH_PROGRAM}" STREQUAL "") | ||
| 102 | if(NOT PATCH_EXECUTABLE) | ||
| 103 | # find the path to the patch executable | ||
| 104 | find_program(PATCH_EXECUTABLE NAMES patch) | ||
| 105 | |||
| 106 | if(NOT PATCH_EXECUTABLE) | ||
| 107 | message(FATAL_ERROR "Missing patch command (we looked in ${CMAKE_PREFIX_PATH})") | ||
| 108 | endif() | ||
| 109 | endif() | ||
| 110 | |||
| 111 | set(PATCH_PROGRAM ${PATCH_EXECUTABLE}) | ||
| 112 | |||
| 113 | # On Windows "patch.exe" can only handle CR-LF line-endings. | ||
| 114 | # Our patches have LF-only line endings - except when they | ||
| 115 | # have been checked out as part of a dependency hosted on Git | ||
| 116 | # and core.autocrlf=true. | ||
| 117 | if(WIN32) | ||
| 118 | file(READ ${patch} patch_content_hex HEX) | ||
| 119 | # Force handle LF-only line endings | ||
| 120 | if(NOT patch_content_hex MATCHES "0d0a") | ||
| 121 | set(PATCH_PROGRAM "\"${PATCH_PROGRAM}\" --binary") | ||
| 122 | endif() | ||
| 123 | endif() | ||
| 124 | endif() | ||
| 125 | |||
| 126 | set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${patch}) | ||
| 127 | file(APPEND ${PATCH_FILE} | ||
| 128 | "execute_process(COMMAND ${PATCH_PROGRAM} -p1 -i \"${patch}\")\n") | ||
| 129 | endforeach() | ||
| 130 | |||
| 131 | |||
| 132 | # if there's an install.txt use it to properly install the built files | ||
| 133 | set(INSTALL_COMMAND "") | ||
| 134 | if(EXISTS ${dir}/install.txt) | ||
| 135 | set(INSTALL_COMMAND INSTALL_COMMAND ${CMAKE_COMMAND} | ||
| 136 | -DINPUTDIR=${BUILD_DIR}/${id}/src/${id}-build/ | ||
| 137 | -DINPUTFILE=${dir}/install.txt | ||
| 138 | -DDESTDIR=${OUTPUT_DIR} | ||
| 139 | -DENABLE_STATIC=1 | ||
| 140 | "${extraflags}" | ||
| 141 | -P ${PROJECT_SOURCE_DIR}/install.cmake) | ||
| 142 | elseif(EXISTS ${dir}/noinstall.txt) | ||
| 143 | set(INSTALL_COMMAND INSTALL_COMMAND "") | ||
| 144 | endif() | ||
| 145 | |||
| 146 | # check if there's a platform-specific or generic deps.txt containing dependencies on other libraries | ||
| 147 | if(EXISTS ${dir}/${CORE_SYSTEM_NAME}-deps.txt) | ||
| 148 | file(STRINGS ${dir}/${CORE_SYSTEM_NAME}-deps.txt deps) | ||
| 149 | message(STATUS "${id} depends: ${deps}") | ||
| 150 | elseif(EXISTS ${dir}/deps.txt) | ||
| 151 | set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${dir}/deps.txt) | ||
| 152 | file(STRINGS ${dir}/deps.txt deps) | ||
| 153 | message(STATUS "${id} depends: ${deps}") | ||
| 154 | else() | ||
| 155 | set(deps) | ||
| 156 | endif() | ||
| 157 | |||
| 158 | if(CROSS_AUTOCONF AND AUTOCONF_FILES) | ||
| 159 | foreach(afile ${AUTOCONF_FILES}) | ||
| 160 | set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${afile}) | ||
| 161 | file(APPEND ${PATCH_FILE} | ||
| 162 | "message(STATUS \"AUTOCONF: copying ${afile} to ${BUILD_DIR}/${id}/src/${id}\")\n | ||
| 163 | file(COPY ${afile} DESTINATION ${BUILD_DIR}/${id}/src/${id})\n") | ||
| 164 | endforeach() | ||
| 165 | endif() | ||
| 166 | |||
| 167 | # if the patch file exists we need to set the PATCH_COMMAND | ||
| 168 | set(PATCH_COMMAND "") | ||
| 169 | if(EXISTS ${PATCH_FILE}) | ||
| 170 | set(PATCH_COMMAND ${CMAKE_COMMAND} -P ${PATCH_FILE}) | ||
| 171 | endif() | ||
| 172 | |||
| 173 | # prepare the setup of the call to externalproject_add() | ||
| 174 | set(EXTERNALPROJECT_SETUP PREFIX ${BUILD_DIR}/${id} | ||
| 175 | CMAKE_ARGS ${extraflags} ${BUILD_ARGS} | ||
| 176 | PATCH_COMMAND ${PATCH_COMMAND} | ||
| 177 | "${INSTALL_COMMAND}") | ||
| 178 | |||
| 179 | if(CMAKE_VERSION VERSION_GREATER 3.5.9) | ||
| 180 | list(APPEND EXTERNALPROJECT_SETUP GIT_SHALLOW 1) | ||
| 181 | endif() | ||
| 182 | |||
| 183 | # if there's an url defined we need to pass that to externalproject_add() | ||
| 184 | if(DEFINED url AND NOT "${url}" STREQUAL "") | ||
| 185 | # check if there's a third parameter in the file | ||
| 186 | if(deflength GREATER 2) | ||
| 187 | # the third parameter is considered as a revision of a git repository | ||
| 188 | list(GET def 2 revision) | ||
| 189 | |||
| 190 | externalproject_add(${id} | ||
| 191 | GIT_REPOSITORY ${url} | ||
| 192 | GIT_TAG ${revision} | ||
| 193 | "${EXTERNALPROJECT_SETUP}") | ||
| 194 | |||
| 195 | # For patchfiles to work, disable (users globally set) autocrlf=true | ||
| 196 | if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_GREATER 3.7) | ||
| 197 | message(AUTHOR_WARNING "Make use of GIT_CONFIG") | ||
| 198 | endif() | ||
| 199 | if(WIN32 AND patches) | ||
| 200 | externalproject_add_step(${id} gitconfig | ||
| 201 | COMMAND git config core.autocrlf false | ||
| 202 | COMMAND git rm -rf --cached . | ||
| 203 | COMMAND git reset --hard HEAD | ||
| 204 | COMMENT "Performing gitconfig step: Disabling autocrlf to enable patching for '${id}'" | ||
| 205 | DEPENDERS patch | ||
| 206 | WORKING_DIRECTORY <SOURCE_DIR>) | ||
| 207 | endif() | ||
| 208 | else() | ||
| 209 | set(CONFIGURE_COMMAND "") | ||
| 210 | if(NOT WIN32) | ||
| 211 | # manually specify the configure command to be able to pass in the custom PKG_CONFIG_PATH | ||
| 212 | set(CONFIGURE_COMMAND PKG_CONFIG_PATH=${OUTPUT_DIR}/lib/pkgconfig | ||
| 213 | ${CMAKE_COMMAND} -DCMAKE_LIBRARY_PATH=${OUTPUT_DIR}/lib ${extraflags} ${BUILD_ARGS} | ||
| 214 | ${BUILD_DIR}/${id}/src/${id} | ||
| 215 | -DPACKAGE_CONFIG_PATH=${OUTPUT_DIR}/lib/pkgconfig | ||
| 216 | -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} | ||
| 217 | -DOUTPUT_DIR=${OUTPUT_DIR} | ||
| 218 | -DCMAKE_PREFIX_PATH=${OUTPUT_DIR} | ||
| 219 | -DCMAKE_INSTALL_PREFIX=${OUTPUT_DIR} | ||
| 220 | -DCMAKE_EXE_LINKER_FLAGS=-L${OUTPUT_DIR}/lib | ||
| 221 | -DCMAKE_INCLUDE_PATH=${OUTPUT_DIR}/include) | ||
| 222 | endif() | ||
| 223 | |||
| 224 | externalproject_add(${id} | ||
| 225 | URL ${url} | ||
| 226 | DOWNLOAD_DIR ${BUILD_DIR}/download | ||
| 227 | CONFIGURE_COMMAND ${CONFIGURE_COMMAND} | ||
| 228 | "${EXTERNALPROJECT_SETUP}") | ||
| 229 | endif() | ||
| 230 | else() | ||
| 231 | externalproject_add(${id} | ||
| 232 | SOURCE_DIR ${dir} | ||
| 233 | "${EXTERNALPROJECT_SETUP}") | ||
| 234 | endif() | ||
| 235 | |||
| 236 | if(deps) | ||
| 237 | add_dependencies(${id} ${deps}) | ||
| 238 | endif() | ||
| 239 | endif() | ||
| 240 | |||
| 241 | # if the dependency is available for the target platform add it to the list of the addon's dependencies | ||
| 242 | # (even if the target already exists as it still has to be built before the addon) | ||
| 243 | if(${platform_found}) | ||
| 244 | list(APPEND ${addon}_DEPS ${id}) | ||
| 245 | endif() | ||
| 246 | endif() | ||
| 247 | endforeach() | ||
| 248 | |||
| 249 | # make the ${addon}_DEPS variable available to the calling script | ||
| 250 | set(${addon}_DEPS "${${addon}_DEPS}" PARENT_SCOPE) | ||
| 251 | endfunction() | ||
| 252 | |||
diff --git a/project/cmake/scripts/common/Macros.cmake b/project/cmake/scripts/common/Macros.cmake deleted file mode 100644 index cce3245..0000000 --- a/project/cmake/scripts/common/Macros.cmake +++ /dev/null | |||
| @@ -1,622 +0,0 @@ | |||
| 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 | # IDEs: Group source files in target in folders (file system hierarchy) | ||
| 7 | # Source: http://blog.audio-tk.com/2015/09/01/sorting-source-files-and-projects-in-folders-with-cmake-and-visual-studioxcode/ | ||
| 8 | # Arguments: | ||
| 9 | # target The target that shall be grouped by folders. | ||
| 10 | # Optional Arguments: | ||
| 11 | # RELATIVE allows to specify a different reference folder. | ||
| 12 | function(source_group_by_folder target) | ||
| 13 | if(NOT TARGET ${target}) | ||
| 14 | message(FATAL_ERROR "There is no target named '${target}'") | ||
| 15 | endif() | ||
| 16 | |||
| 17 | set(SOURCE_GROUP_DELIMITER "/") | ||
| 18 | |||
| 19 | cmake_parse_arguments(arg "" "RELATIVE" "" ${ARGN}) | ||
| 20 | if(arg_RELATIVE) | ||
| 21 | set(relative_dir ${arg_RELATIVE}) | ||
| 22 | else() | ||
| 23 | set(relative_dir ${CMAKE_CURRENT_SOURCE_DIR}) | ||
| 24 | endif() | ||
| 25 | |||
| 26 | get_property(files TARGET ${target} PROPERTY SOURCES) | ||
| 27 | if(files) | ||
| 28 | list(SORT files) | ||
| 29 | |||
| 30 | if(CMAKE_GENERATOR STREQUAL Xcode) | ||
| 31 | set_target_properties(${target} PROPERTIES SOURCES "${files}") | ||
| 32 | endif() | ||
| 33 | endif() | ||
| 34 | foreach(file ${files}) | ||
| 35 | if(NOT IS_ABSOLUTE ${file}) | ||
| 36 | set(file ${CMAKE_CURRENT_SOURCE_DIR}/${file}) | ||
| 37 | endif() | ||
| 38 | file(RELATIVE_PATH relative_file ${relative_dir} ${file}) | ||
| 39 | get_filename_component(dir "${relative_file}" DIRECTORY) | ||
| 40 | if(NOT dir STREQUAL "${last_dir}") | ||
| 41 | if(files) | ||
| 42 | source_group("${last_dir}" FILES ${files}) | ||
| 43 | endif() | ||
| 44 | set(files "") | ||
| 45 | endif() | ||
| 46 | set(files ${files} ${file}) | ||
| 47 | set(last_dir "${dir}") | ||
| 48 | endforeach(file) | ||
| 49 | if(files) | ||
| 50 | source_group("${last_dir}" FILES ${files}) | ||
| 51 | endif() | ||
| 52 | endfunction() | ||
| 53 | |||
| 54 | # Add sources to main application | ||
| 55 | # Arguments: | ||
| 56 | # name name of the library to add | ||
| 57 | # Implicit arguments: | ||
| 58 | # ENABLE_STATIC_LIBS Build static libraries per directory | ||
| 59 | # SOURCES the sources of the library | ||
| 60 | # HEADERS the headers of the library (only for IDE support) | ||
| 61 | # OTHERS other library related files (only for IDE support) | ||
| 62 | # On return: | ||
| 63 | # Library will be built, optionally added to ${core_DEPENDS} | ||
| 64 | # Sets CORE_LIBRARY for calls for setting target specific options | ||
| 65 | function(core_add_library name) | ||
| 66 | if(ENABLE_STATIC_LIBS) | ||
| 67 | add_library(${name} STATIC ${SOURCES} ${HEADERS} ${OTHERS}) | ||
| 68 | set_target_properties(${name} PROPERTIES PREFIX "") | ||
| 69 | set(core_DEPENDS ${name} ${core_DEPENDS} CACHE STRING "" FORCE) | ||
| 70 | add_dependencies(${name} libcpluff ffmpeg dvdnav crossguid) | ||
| 71 | set(CORE_LIBRARY ${name} PARENT_SCOPE) | ||
| 72 | |||
| 73 | # Add precompiled headers to Kodi main libraries | ||
| 74 | if(CORE_SYSTEM_NAME STREQUAL windows) | ||
| 75 | add_precompiled_header(${name} pch.h ${CORE_SOURCE_DIR}/xbmc/platform/win32/pch.cpp PCH_TARGET kodi) | ||
| 76 | set_language_cxx(${name}) | ||
| 77 | target_link_libraries(${name} PUBLIC effects11) | ||
| 78 | endif() | ||
| 79 | else() | ||
| 80 | foreach(src IN LISTS SOURCES HEADERS OTHERS) | ||
| 81 | get_filename_component(src_path "${src}" ABSOLUTE) | ||
| 82 | list(APPEND FILES ${src_path}) | ||
| 83 | endforeach() | ||
| 84 | target_sources(lib${APP_NAME_LC} PRIVATE ${FILES}) | ||
| 85 | set(CORE_LIBRARY lib${APP_NAME_LC} PARENT_SCOPE) | ||
| 86 | endif() | ||
| 87 | endfunction() | ||
| 88 | |||
| 89 | # Add a test library, and add sources to list for gtest integration macros | ||
| 90 | function(core_add_test_library name) | ||
| 91 | if(ENABLE_STATIC_LIBS) | ||
| 92 | add_library(${name} STATIC ${SOURCES} ${SUPPORTED_SOURCES} ${HEADERS} ${OTHERS}) | ||
| 93 | set_target_properties(${name} PROPERTIES PREFIX "" | ||
| 94 | EXCLUDE_FROM_ALL 1 | ||
| 95 | FOLDER "Build Utilities/tests") | ||
| 96 | add_dependencies(${name} libcpluff ffmpeg dvdnav crossguid) | ||
| 97 | set(test_archives ${test_archives} ${name} CACHE STRING "" FORCE) | ||
| 98 | endif() | ||
| 99 | foreach(src IN LISTS SOURCES) | ||
| 100 | get_filename_component(src_path "${src}" ABSOLUTE) | ||
| 101 | set(test_sources "${src_path}" ${test_sources} CACHE STRING "" FORCE) | ||
| 102 | endforeach() | ||
| 103 | endfunction() | ||
| 104 | |||
| 105 | # Add an addon callback library | ||
| 106 | # Arguments: | ||
| 107 | # name name of the library to add | ||
| 108 | # Implicit arguments: | ||
| 109 | # SOURCES the sources of the library | ||
| 110 | # HEADERS the headers of the library (only for IDE support) | ||
| 111 | # OTHERS other library related files (only for IDE support) | ||
| 112 | # On return: | ||
| 113 | # Library target is defined and added to LIBRARY_FILES | ||
| 114 | function(core_add_addon_library name) | ||
| 115 | get_filename_component(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} NAME) | ||
| 116 | list(APPEND SOURCES lib${name}.cpp) | ||
| 117 | core_add_shared_library(${name} OUTPUT_DIRECTORY addons/${DIRECTORY}) | ||
| 118 | set_target_properties(${name} PROPERTIES FOLDER addons) | ||
| 119 | target_include_directories(${name} PRIVATE | ||
| 120 | ${CMAKE_CURRENT_SOURCE_DIR} | ||
| 121 | ${CORE_SOURCE_DIR}/xbmc/addons/kodi-addon-dev-kit/include/kodi | ||
| 122 | ${CORE_SOURCE_DIR}/xbmc) | ||
| 123 | endfunction() | ||
| 124 | |||
| 125 | # Add an dl-loaded shared library | ||
| 126 | # Arguments: | ||
| 127 | # name name of the library to add | ||
| 128 | # Optional arguments: | ||
| 129 | # WRAPPED wrap this library on POSIX platforms to add VFS support for | ||
| 130 | # libraries that would otherwise not support it. | ||
| 131 | # OUTPUT_DIRECTORY where to create the library in the build dir | ||
| 132 | # (default: system) | ||
| 133 | # Implicit arguments: | ||
| 134 | # SOURCES the sources of the library | ||
| 135 | # HEADERS the headers of the library (only for IDE support) | ||
| 136 | # OTHERS other library related files (only for IDE support) | ||
| 137 | # On return: | ||
| 138 | # Library target is defined and added to LIBRARY_FILES | ||
| 139 | function(core_add_shared_library name) | ||
| 140 | cmake_parse_arguments(arg "WRAPPED" "OUTPUT_DIRECTORY" "" ${ARGN}) | ||
| 141 | if(arg_OUTPUT_DIRECTORY) | ||
| 142 | set(OUTPUT_DIRECTORY ${arg_OUTPUT_DIRECTORY}) | ||
| 143 | else() | ||
| 144 | if(NOT CORE_SYSTEM_NAME STREQUAL windows) | ||
| 145 | set(OUTPUT_DIRECTORY system) | ||
| 146 | endif() | ||
| 147 | endif() | ||
| 148 | if(CORE_SYSTEM_NAME STREQUAL windows) | ||
| 149 | set(OUTPUT_NAME lib${name}) | ||
| 150 | else() | ||
| 151 | set(OUTPUT_NAME lib${name}-${ARCH}) | ||
| 152 | endif() | ||
| 153 | |||
| 154 | if(NOT arg_WRAPPED OR CORE_SYSTEM_NAME STREQUAL windows) | ||
| 155 | add_library(${name} SHARED ${SOURCES} ${HEADERS} ${OTHERS}) | ||
| 156 | set_target_properties(${name} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${OUTPUT_DIRECTORY} | ||
| 157 | RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${OUTPUT_DIRECTORY} | ||
| 158 | OUTPUT_NAME ${OUTPUT_NAME} PREFIX "") | ||
| 159 | foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES}) | ||
| 160 | string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG) | ||
| 161 | set_target_properties(${name} PROPERTIES LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/${OUTPUT_DIRECTORY} | ||
| 162 | RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/${OUTPUT_DIRECTORY}) | ||
| 163 | endforeach() | ||
| 164 | |||
| 165 | set(LIBRARY_FILES ${LIBRARY_FILES} ${CMAKE_BINARY_DIR}/${OUTPUT_DIRECTORY}/${OUTPUT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX} CACHE STRING "" FORCE) | ||
| 166 | add_dependencies(${APP_NAME_LC}-libraries ${name}) | ||
| 167 | else() | ||
| 168 | add_library(${name} STATIC ${SOURCES} ${HEADERS} ${OTHERS}) | ||
| 169 | set_target_properties(${name} PROPERTIES POSITION_INDEPENDENT_CODE 1) | ||
| 170 | core_link_library(${name} ${OUTPUT_DIRECTORY}/lib${name}) | ||
| 171 | endif() | ||
| 172 | endfunction() | ||
| 173 | |||
| 174 | # Sets the compile language for all C source files in a target to CXX. | ||
| 175 | # Needs to be called from the CMakeLists.txt that defines the target. | ||
| 176 | # Arguments: | ||
| 177 | # target target | ||
| 178 | function(set_language_cxx target) | ||
| 179 | get_property(sources TARGET ${target} PROPERTY SOURCES) | ||
| 180 | foreach(file IN LISTS sources) | ||
| 181 | if(file MATCHES "\.c$") | ||
| 182 | set_source_files_properties(${file} PROPERTIES LANGUAGE CXX) | ||
| 183 | endif() | ||
| 184 | endforeach() | ||
| 185 | endfunction() | ||
| 186 | |||
| 187 | # Add a data file to installation list with a mirror in build tree | ||
| 188 | # Mirroring files in the buildtree allows to execute the app from there. | ||
| 189 | # Arguments: | ||
| 190 | # file full path to file to mirror | ||
| 191 | # Optional Arguments: | ||
| 192 | # NO_INSTALL: exclude file from installation target (only mirror) | ||
| 193 | # DIRECTORY: directory where the file should be mirrored to | ||
| 194 | # (default: preserve tree structure relative to CORE_SOURCE_DIR) | ||
| 195 | # On return: | ||
| 196 | # Files is mirrored to the build tree and added to ${install_data} | ||
| 197 | # (if NO_INSTALL is not given). | ||
| 198 | function(copy_file_to_buildtree file) | ||
| 199 | cmake_parse_arguments(arg "NO_INSTALL" "DIRECTORY" "" ${ARGN}) | ||
| 200 | if(arg_DIRECTORY) | ||
| 201 | set(outdir ${arg_DIRECTORY}) | ||
| 202 | get_filename_component(outfile ${file} NAME) | ||
| 203 | set(outfile ${outdir}/${outfile}) | ||
| 204 | else() | ||
| 205 | string(REPLACE "${CORE_SOURCE_DIR}/" "" outfile ${file}) | ||
| 206 | get_filename_component(outdir ${outfile} DIRECTORY) | ||
| 207 | endif() | ||
| 208 | |||
| 209 | if(NOT TARGET export-files) | ||
| 210 | file(REMOVE ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/ExportFiles.cmake) | ||
| 211 | add_custom_target(export-files ALL COMMENT "Copying files into build tree" | ||
| 212 | COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/ExportFiles.cmake) | ||
| 213 | set_target_properties(export-files PROPERTIES FOLDER "Build Utilities") | ||
| 214 | file(APPEND ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/ExportFiles.cmake "# Export files to build tree\n") | ||
| 215 | endif() | ||
| 216 | |||
| 217 | # Exclude autotools build artefacts and other blacklisted files in source tree. | ||
| 218 | if(file MATCHES "(Makefile|\.in|\.xbt|\.so|\.dylib|\.gitignore)$") | ||
| 219 | if(VERBOSE) | ||
| 220 | message(STATUS "copy_file_to_buildtree - ignoring file: ${file}") | ||
| 221 | endif() | ||
| 222 | return() | ||
| 223 | endif() | ||
| 224 | |||
| 225 | if(NOT file STREQUAL ${CMAKE_BINARY_DIR}/${outfile}) | ||
| 226 | if(VERBOSE) | ||
| 227 | message(STATUS "copy_file_to_buildtree - copying file: ${file} -> ${CMAKE_BINARY_DIR}/${outfile}") | ||
| 228 | endif() | ||
| 229 | file(APPEND ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/ExportFiles.cmake | ||
| 230 | "file(COPY \"${file}\" DESTINATION \"${CMAKE_BINARY_DIR}/${outdir}\")\n") | ||
| 231 | endif() | ||
| 232 | |||
| 233 | if(NOT arg_NO_INSTALL) | ||
| 234 | list(APPEND install_data ${outfile}) | ||
| 235 | set(install_data ${install_data} PARENT_SCOPE) | ||
| 236 | endif() | ||
| 237 | endfunction() | ||
| 238 | |||
| 239 | # Add data files to installation list with a mirror in build tree. | ||
| 240 | # reads list of files to install from a given list of text files. | ||
| 241 | # Arguments: | ||
| 242 | # pattern globbing pattern for text files to read | ||
| 243 | # Optional Arguments: | ||
| 244 | # NO_INSTALL: exclude files from installation target | ||
| 245 | # Implicit arguments: | ||
| 246 | # CORE_SOURCE_DIR - root of source tree | ||
| 247 | # On return: | ||
| 248 | # Files are mirrored to the build tree and added to ${install_data} | ||
| 249 | # (if NO_INSTALL is not given). | ||
| 250 | function(copy_files_from_filelist_to_buildtree pattern) | ||
| 251 | # copies files listed in text files to the buildtree | ||
| 252 | # Input: [glob pattern: filepattern] | ||
| 253 | cmake_parse_arguments(arg "NO_INSTALL" "" "" ${ARGN}) | ||
| 254 | list(APPEND pattern ${ARGN}) | ||
| 255 | list(SORT pattern) | ||
| 256 | if(VERBOSE) | ||
| 257 | message(STATUS "copy_files_from_filelist_to_buildtree - got pattern: ${pattern}") | ||
| 258 | endif() | ||
| 259 | foreach(pat ${pattern}) | ||
| 260 | file(GLOB filenames ${pat}) | ||
| 261 | foreach(filename ${filenames}) | ||
| 262 | string(STRIP ${filename} filename) | ||
| 263 | core_file_read_filtered(fstrings ${filename}) | ||
| 264 | foreach(dir ${fstrings}) | ||
| 265 | string(REPLACE " " ";" dir ${dir}) | ||
| 266 | list(GET dir 0 src) | ||
| 267 | list(LENGTH dir len) | ||
| 268 | if(len EQUAL 1) | ||
| 269 | set(dest) | ||
| 270 | else() | ||
| 271 | list(GET dir -1 dest) | ||
| 272 | endif() | ||
| 273 | |||
| 274 | # If the full path to an existing file is specified then add that single file. | ||
| 275 | # Don't recursively add all files with the given name. | ||
| 276 | if(EXISTS ${CORE_SOURCE_DIR}/${src} AND NOT IS_DIRECTORY ${CORE_SOURCE_DIR}/${src}) | ||
| 277 | set(files ${src}) | ||
| 278 | else() | ||
| 279 | file(GLOB_RECURSE files RELATIVE ${CORE_SOURCE_DIR} ${CORE_SOURCE_DIR}/${src}) | ||
| 280 | endif() | ||
| 281 | |||
| 282 | foreach(file ${files}) | ||
| 283 | if(arg_NO_INSTALL) | ||
| 284 | copy_file_to_buildtree(${CORE_SOURCE_DIR}/${file} DIRECTORY ${dest} NO_INSTALL) | ||
| 285 | else() | ||
| 286 | copy_file_to_buildtree(${CORE_SOURCE_DIR}/${file} DIRECTORY ${dest}) | ||
| 287 | endif() | ||
| 288 | endforeach() | ||
| 289 | endforeach() | ||
| 290 | endforeach() | ||
| 291 | endforeach() | ||
| 292 | set(install_data ${install_data} PARENT_SCOPE) | ||
| 293 | endfunction() | ||
| 294 | |||
| 295 | # helper macro to set modified variables in parent scope | ||
| 296 | macro(export_dep) | ||
| 297 | set(SYSTEM_INCLUDES ${SYSTEM_INCLUDES} PARENT_SCOPE) | ||
| 298 | set(DEPLIBS ${DEPLIBS} PARENT_SCOPE) | ||
| 299 | set(DEP_DEFINES ${DEP_DEFINES} PARENT_SCOPE) | ||
| 300 | set(${depup}_FOUND ${${depup}_FOUND} PARENT_SCOPE) | ||
| 301 | mark_as_advanced(${depup}_LIBRARIES) | ||
| 302 | endmacro() | ||
| 303 | |||
| 304 | # add a required dependency of main application | ||
| 305 | # Arguments: | ||
| 306 | # dep name of find rule for dependency, used uppercased for variable prefix | ||
| 307 | # On return: | ||
| 308 | # dependency added to ${SYSTEM_INCLUDES}, ${DEPLIBS} and ${DEP_DEFINES} | ||
| 309 | function(core_require_dep dep) | ||
| 310 | find_package(${dep} REQUIRED) | ||
| 311 | string(TOUPPER ${dep} depup) | ||
| 312 | list(APPEND SYSTEM_INCLUDES ${${depup}_INCLUDE_DIRS}) | ||
| 313 | list(APPEND DEPLIBS ${${depup}_LIBRARIES}) | ||
| 314 | list(APPEND DEP_DEFINES ${${depup}_DEFINITIONS}) | ||
| 315 | export_dep() | ||
| 316 | endfunction() | ||
| 317 | |||
| 318 | # add a required dyloaded dependency of main application | ||
| 319 | # Arguments: | ||
| 320 | # dep name of find rule for dependency, used uppercased for variable prefix | ||
| 321 | # On return: | ||
| 322 | # dependency added to ${SYSTEM_INCLUDES}, ${dep}_SONAME is set up | ||
| 323 | function(core_require_dyload_dep dep) | ||
| 324 | find_package(${dep} REQUIRED) | ||
| 325 | string(TOUPPER ${dep} depup) | ||
| 326 | list(APPEND SYSTEM_INCLUDES ${${depup}_INCLUDE_DIRS}) | ||
| 327 | list(APPEND DEP_DEFINES ${${depup}_DEFINITIONS}) | ||
| 328 | find_soname(${depup} REQUIRED) | ||
| 329 | export_dep() | ||
| 330 | set(${depup}_SONAME ${${depup}_SONAME} PARENT_SCOPE) | ||
| 331 | endfunction() | ||
| 332 | |||
| 333 | # helper macro for optional deps | ||
| 334 | macro(setup_enable_switch) | ||
| 335 | string(TOUPPER ${dep} depup) | ||
| 336 | if(ARGV1) | ||
| 337 | set(enable_switch ${ARGV1}) | ||
| 338 | else() | ||
| 339 | set(enable_switch ENABLE_${depup}) | ||
| 340 | endif() | ||
| 341 | # normal options are boolean, so we override set our ENABLE_FOO var to allow "auto" handling | ||
| 342 | set(${enable_switch} "AUTO" CACHE STRING "Enable ${depup} support?") | ||
| 343 | endmacro() | ||
| 344 | |||
| 345 | # add an optional dependency of main application | ||
| 346 | # Arguments: | ||
| 347 | # dep name of find rule for dependency, used uppercased for variable prefix | ||
| 348 | # On return: | ||
| 349 | # dependency optionally added to ${SYSTEM_INCLUDES}, ${DEPLIBS} and ${DEP_DEFINES} | ||
| 350 | function(core_optional_dep dep) | ||
| 351 | setup_enable_switch() | ||
| 352 | if(${enable_switch} STREQUAL AUTO) | ||
| 353 | find_package(${dep}) | ||
| 354 | elseif(${${enable_switch}}) | ||
| 355 | find_package(${dep} REQUIRED) | ||
| 356 | endif() | ||
| 357 | |||
| 358 | if(${depup}_FOUND) | ||
| 359 | list(APPEND SYSTEM_INCLUDES ${${depup}_INCLUDE_DIRS}) | ||
| 360 | list(APPEND DEPLIBS ${${depup}_LIBRARIES}) | ||
| 361 | list(APPEND DEP_DEFINES ${${depup}_DEFINITIONS}) | ||
| 362 | set(final_message ${final_message} "${depup} enabled: Yes" PARENT_SCOPE) | ||
| 363 | export_dep() | ||
| 364 | else() | ||
| 365 | set(final_message ${final_message} "${depup} enabled: No" PARENT_SCOPE) | ||
| 366 | endif() | ||
| 367 | endfunction() | ||
| 368 | |||
| 369 | # add an optional dyloaded dependency of main application | ||
| 370 | # Arguments: | ||
| 371 | # dep name of find rule for dependency, used uppercased for variable prefix | ||
| 372 | # On return: | ||
| 373 | # dependency optionally added to ${SYSTEM_INCLUDES}, ${DEP_DEFINES}, ${dep}_SONAME is set up | ||
| 374 | function(core_optional_dyload_dep dep) | ||
| 375 | setup_enable_switch() | ||
| 376 | if(${enable_switch}) | ||
| 377 | find_package(${dep}) | ||
| 378 | if(${depup}_FOUND) | ||
| 379 | list(APPEND SYSTEM_INCLUDES ${${depup}_INCLUDE_DIRS}) | ||
| 380 | find_soname(${depup} REQUIRED) | ||
| 381 | list(APPEND DEP_DEFINES ${${depup}_DEFINITIONS}) | ||
| 382 | set(final_message ${final_message} "${depup} enabled: Yes" PARENT_SCOPE) | ||
| 383 | export_dep() | ||
| 384 | set(${depup}_SONAME ${${depup}_SONAME} PARENT_SCOPE) | ||
| 385 | endif() | ||
| 386 | endif() | ||
| 387 | endfunction() | ||
| 388 | |||
| 389 | function(core_file_read_filtered result filepattern) | ||
| 390 | # Reads STRINGS from text files | ||
| 391 | # with comments filtered out | ||
| 392 | # Result: [list: result] | ||
| 393 | # Input: [glob pattern: filepattern] | ||
| 394 | file(GLOB filenames ${filepattern}) | ||
| 395 | list(SORT filenames) | ||
| 396 | foreach(filename ${filenames}) | ||
| 397 | if(VERBOSE) | ||
| 398 | message(STATUS "core_file_read_filtered - filename: ${filename}") | ||
| 399 | endif() | ||
| 400 | set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${filename}) | ||
| 401 | file(STRINGS ${filename} fstrings REGEX "^[^#//]") | ||
| 402 | foreach(fstring ${fstrings}) | ||
| 403 | string(REGEX REPLACE "^(.*)#(.*)" "\\1" fstring ${fstring}) | ||
| 404 | string(REGEX REPLACE "[ \n\r\t]//.*" "" fstring ${fstring}) | ||
| 405 | string(STRIP ${fstring} fstring) | ||
| 406 | list(APPEND filename_strings ${fstring}) | ||
| 407 | endforeach() | ||
| 408 | endforeach() | ||
| 409 | set(${result} ${filename_strings} PARENT_SCOPE) | ||
| 410 | endfunction() | ||
| 411 | |||
| 412 | function(core_add_subdirs_from_filelist files) | ||
| 413 | # Adds subdirectories from a sorted list of files | ||
| 414 | # Input: [list: filenames] [bool: sort] | ||
| 415 | foreach(arg ${ARGN}) | ||
| 416 | list(APPEND files ${arg}) | ||
| 417 | endforeach() | ||
| 418 | list(SORT files) | ||
| 419 | if(VERBOSE) | ||
| 420 | message(STATUS "core_add_subdirs_from_filelist - got pattern: ${files}") | ||
| 421 | endif() | ||
| 422 | foreach(filename ${files}) | ||
| 423 | string(STRIP ${filename} filename) | ||
| 424 | core_file_read_filtered(fstrings ${filename}) | ||
| 425 | foreach(subdir ${fstrings}) | ||
| 426 | string(REPLACE " " ";" subdir ${subdir}) | ||
| 427 | list(GET subdir 0 subdir_src) | ||
| 428 | list(GET subdir -1 subdir_dest) | ||
| 429 | if(VERBOSE) | ||
| 430 | message(STATUS " core_add_subdirs_from_filelist - adding subdir: ${CORE_SOURCE_DIR}/${subdir_src} -> ${CORE_BUILD_DIR}/${subdir_dest}") | ||
| 431 | endif() | ||
| 432 | add_subdirectory(${CORE_SOURCE_DIR}/${subdir_src} ${CORE_BUILD_DIR}/${subdir_dest}) | ||
| 433 | endforeach() | ||
| 434 | endforeach() | ||
| 435 | endfunction() | ||
| 436 | |||
| 437 | macro(core_add_optional_subdirs_from_filelist pattern) | ||
| 438 | # Adds subdirectories from text files | ||
| 439 | # if the option(s) in the 3rd field are enabled | ||
| 440 | # Input: [glob pattern: filepattern] | ||
| 441 | foreach(arg ${ARGN}) | ||
| 442 | list(APPEND pattern ${arg}) | ||
| 443 | endforeach() | ||
| 444 | foreach(elem ${pattern}) | ||
| 445 | string(STRIP ${elem} elem) | ||
| 446 | list(APPEND filepattern ${elem}) | ||
| 447 | endforeach() | ||
| 448 | |||
| 449 | file(GLOB filenames ${filepattern}) | ||
| 450 | list(SORT filenames) | ||
| 451 | if(VERBOSE) | ||
| 452 | message(STATUS "core_add_optional_subdirs_from_filelist - got pattern: ${filenames}") | ||
| 453 | endif() | ||
| 454 | |||
| 455 | foreach(filename ${filenames}) | ||
| 456 | if(VERBOSE) | ||
| 457 | message(STATUS "core_add_optional_subdirs_from_filelist - reading file: ${filename}") | ||
| 458 | endif() | ||
| 459 | set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${filename}) | ||
| 460 | file(STRINGS ${filename} fstrings REGEX "^[^#//]") | ||
| 461 | foreach(line ${fstrings}) | ||
| 462 | string(REPLACE " " ";" line "${line}") | ||
| 463 | list(GET line 0 subdir_src) | ||
| 464 | list(GET line 1 subdir_dest) | ||
| 465 | list(GET line 3 opts) | ||
| 466 | foreach(opt ${opts}) | ||
| 467 | if(ENABLE_${opt}) | ||
| 468 | if(VERBOSE) | ||
| 469 | message(STATUS " core_add_optional_subdirs_from_filelist - adding subdir: ${CORE_SOURCE_DIR}/${subdir_src} -> ${CORE_BUILD_DIR}/${subdir_dest}") | ||
| 470 | endif() | ||
| 471 | add_subdirectory(${CORE_SOURCE_DIR}/${subdir_src} ${CORE_BUILD_DIR}/${subdir_dest}) | ||
| 472 | else() | ||
| 473 | if(VERBOSE) | ||
| 474 | message(STATUS " core_add_optional_subdirs_from_filelist: OPTION ${opt} not enabled for ${subdir_src}, skipping subdir") | ||
| 475 | endif() | ||
| 476 | endif() | ||
| 477 | endforeach() | ||
| 478 | endforeach() | ||
| 479 | endforeach() | ||
| 480 | endmacro() | ||
| 481 | |||
| 482 | # Generates an RFC2822 timestamp | ||
| 483 | # | ||
| 484 | # The following variable is set: | ||
| 485 | # RFC2822_TIMESTAMP | ||
| 486 | function(rfc2822stamp) | ||
| 487 | execute_process(COMMAND date -R | ||
| 488 | OUTPUT_VARIABLE RESULT) | ||
| 489 | set(RFC2822_TIMESTAMP ${RESULT} PARENT_SCOPE) | ||
| 490 | endfunction() | ||
| 491 | |||
| 492 | # Generates an user stamp from git config info | ||
| 493 | # | ||
| 494 | # The following variable is set: | ||
| 495 | # PACKAGE_MAINTAINER - user stamp in the form of "username <username@example.com>" | ||
| 496 | # if no git tree is found, value is set to "nobody <nobody@example.com>" | ||
| 497 | function(userstamp) | ||
| 498 | find_package(Git) | ||
| 499 | if(GIT_FOUND AND EXISTS ${CORE_SOURCE_DIR}/.git) | ||
| 500 | execute_process(COMMAND ${GIT_EXECUTABLE} config user.name | ||
| 501 | OUTPUT_VARIABLE username | ||
| 502 | WORKING_DIRECTORY ${CORE_SOURCE_DIR} | ||
| 503 | OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
| 504 | execute_process(COMMAND ${GIT_EXECUTABLE} config user.email | ||
| 505 | OUTPUT_VARIABLE useremail | ||
| 506 | WORKING_DIRECTORY ${CORE_SOURCE_DIR} | ||
| 507 | OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
| 508 | set(PACKAGE_MAINTAINER "${username} <${useremail}>" PARENT_SCOPE) | ||
| 509 | else() | ||
| 510 | set(PACKAGE_MAINTAINER "nobody <nobody@example.com>" PARENT_SCOPE) | ||
| 511 | endif() | ||
| 512 | endfunction() | ||
| 513 | |||
| 514 | # Parses git info and sets variables used to identify the build | ||
| 515 | # Arguments: | ||
| 516 | # stamp variable name to return | ||
| 517 | # Optional Arguments: | ||
| 518 | # FULL: generate git HEAD commit in the form of 'YYYYMMDD-hash' | ||
| 519 | # if git tree is dirty, value is set in the form of 'YYYYMMDD-hash-dirty' | ||
| 520 | # if no git tree is found, value is set in the form of 'YYYYMMDD-nogitfound' | ||
| 521 | # if FULL is not given, stamp is generated following the same process as above | ||
| 522 | # but without 'YYYYMMDD' | ||
| 523 | # On return: | ||
| 524 | # Variable is set with generated stamp to PARENT_SCOPE | ||
| 525 | function(core_find_git_rev stamp) | ||
| 526 | # allow manual setting GIT_VERSION | ||
| 527 | if(GIT_VERSION) | ||
| 528 | set(${stamp} ${GIT_VERSION} PARENT_SCOPE) | ||
| 529 | else() | ||
| 530 | find_package(Git) | ||
| 531 | if(GIT_FOUND AND EXISTS ${CORE_SOURCE_DIR}/.git) | ||
| 532 | execute_process(COMMAND ${GIT_EXECUTABLE} diff-files --ignore-submodules --quiet -- | ||
| 533 | RESULT_VARIABLE status_code | ||
| 534 | WORKING_DIRECTORY ${CORE_SOURCE_DIR}) | ||
| 535 | if(NOT status_code) | ||
| 536 | execute_process(COMMAND ${GIT_EXECUTABLE} diff-index --ignore-submodules --quiet HEAD -- | ||
| 537 | RESULT_VARIABLE status_code | ||
| 538 | WORKING_DIRECTORY ${CORE_SOURCE_DIR}) | ||
| 539 | endif() | ||
| 540 | if(status_code) | ||
| 541 | execute_process(COMMAND ${GIT_EXECUTABLE} log -n 1 --pretty=format:"%h-dirty" HEAD | ||
| 542 | OUTPUT_VARIABLE HASH | ||
| 543 | WORKING_DIRECTORY ${CORE_SOURCE_DIR}) | ||
| 544 | string(SUBSTRING ${HASH} 1 13 HASH) | ||
| 545 | else() | ||
| 546 | execute_process(COMMAND ${GIT_EXECUTABLE} log -n 1 --pretty=format:"%h" HEAD | ||
| 547 | OUTPUT_VARIABLE HASH | ||
| 548 | WORKING_DIRECTORY ${CORE_SOURCE_DIR}) | ||
| 549 | string(SUBSTRING ${HASH} 1 7 HASH) | ||
| 550 | endif() | ||
| 551 | execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:"%cd" --date=short HEAD | ||
| 552 | OUTPUT_VARIABLE DATE | ||
| 553 | WORKING_DIRECTORY ${CORE_SOURCE_DIR}) | ||
| 554 | string(SUBSTRING ${DATE} 1 10 DATE) | ||
| 555 | string(REPLACE "-" "" DATE ${DATE}) | ||
| 556 | else() | ||
| 557 | string(TIMESTAMP DATE "%Y%m%d" UTC) | ||
| 558 | set(HASH "nogitfound") | ||
| 559 | endif() | ||
| 560 | cmake_parse_arguments(arg "FULL" "" "" ${ARGN}) | ||
| 561 | if(arg_FULL) | ||
| 562 | set(${stamp} ${DATE}-${HASH} PARENT_SCOPE) | ||
| 563 | else() | ||
| 564 | set(${stamp} ${HASH} PARENT_SCOPE) | ||
| 565 | endif() | ||
| 566 | endif() | ||
| 567 | endfunction() | ||
| 568 | |||
| 569 | # Parses version.txt and libKODI_guilib.h and sets variables | ||
| 570 | # used to construct dirs structure, file naming, API version, etc. | ||
| 571 | # | ||
| 572 | # The following variables are set from version.txt: | ||
| 573 | # APP_NAME - app name | ||
| 574 | # APP_NAME_LC - lowercased app name | ||
| 575 | # APP_NAME_UC - uppercased app name | ||
| 576 | # COMPANY_NAME - company name | ||
| 577 | # APP_VERSION_MAJOR - the app version major | ||
| 578 | # APP_VERSION_MINOR - the app version minor | ||
| 579 | # APP_VERSION_TAG - the app version tag | ||
| 580 | # APP_VERSION_TAG_LC - lowercased app version tag | ||
| 581 | # APP_VERSION - the app version (${APP_VERSION_MAJOR}.${APP_VERSION_MINOR}-${APP_VERSION_TAG}) | ||
| 582 | # APP_ADDON_API - the addon API version in the form of 16.9.702 | ||
| 583 | # FILE_VERSION - file version in the form of 16,9,702,0 - Windows only | ||
| 584 | # | ||
| 585 | # The following variables are set from libKODI_guilib.h: | ||
| 586 | # guilib_version - current ADDONGUI API version | ||
| 587 | # guilib_version_min - minimal ADDONGUI API version | ||
| 588 | macro(core_find_versions) | ||
| 589 | include(CMakeParseArguments) | ||
| 590 | core_file_read_filtered(version_list ${CORE_SOURCE_DIR}/version.txt) | ||
| 591 | string(REPLACE " " ";" version_list "${version_list}") | ||
| 592 | cmake_parse_arguments(APP "" "APP_NAME;COMPANY_NAME;WEBSITE;VERSION_MAJOR;VERSION_MINOR;VERSION_TAG;VERSION_CODE;ADDON_API" "" ${version_list}) | ||
| 593 | |||
| 594 | set(APP_NAME ${APP_APP_NAME}) # inconsistency but APP_APP_NAME looks weird | ||
| 595 | string(TOLOWER ${APP_APP_NAME} APP_NAME_LC) | ||
| 596 | string(TOUPPER ${APP_APP_NAME} APP_NAME_UC) | ||
| 597 | set(COMPANY_NAME ${APP_COMPANY_NAME}) | ||
| 598 | set(APP_VERSION ${APP_VERSION_MAJOR}.${APP_VERSION_MINOR}) | ||
| 599 | if(APP_VERSION_TAG) | ||
| 600 | set(APP_VERSION ${APP_VERSION}-${APP_VERSION_TAG}) | ||
| 601 | string(TOLOWER ${APP_VERSION_TAG} APP_VERSION_TAG_LC) | ||
| 602 | endif() | ||
| 603 | string(REPLACE "." "," FILE_VERSION ${APP_ADDON_API}.0) | ||
| 604 | file(STRINGS ${CORE_SOURCE_DIR}/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h guilib_version REGEX "^.*GUILIB_API_VERSION (.*)$") | ||
| 605 | string(REGEX REPLACE ".*\"(.*)\"" "\\1" guilib_version ${guilib_version}) | ||
| 606 | file(STRINGS ${CORE_SOURCE_DIR}/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h guilib_version_min REGEX "^.*GUILIB_MIN_API_VERSION (.*)$") | ||
| 607 | string(REGEX REPLACE ".*\"(.*)\"" "\\1" guilib_version_min ${guilib_version_min}) | ||
| 608 | # unset variables not used anywhere else | ||
| 609 | unset(version_list) | ||
| 610 | unset(APP_APP_NAME) | ||
| 611 | |||
| 612 | # bail if we can't parse version.txt | ||
| 613 | if(NOT DEFINED APP_VERSION_MAJOR OR NOT DEFINED APP_VERSION_MINOR) | ||
| 614 | message(FATAL_ERROR "Could not determine app version! Make sure that ${CORE_SOURCE_DIR}/version.txt exists") | ||
| 615 | endif() | ||
| 616 | |||
| 617 | # bail if we can't parse libKODI_guilib.h | ||
| 618 | if(NOT DEFINED guilib_version OR NOT DEFINED guilib_version_min) | ||
| 619 | message(FATAL_ERROR "Could not determine add-on API version! Make sure that ${CORE_SOURCE_DIR}/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h exists") | ||
| 620 | endif() | ||
| 621 | endmacro() | ||
| 622 | |||
diff --git a/project/cmake/scripts/common/PrepareEnv.cmake b/project/cmake/scripts/common/PrepareEnv.cmake deleted file mode 100644 index 51be739..0000000 --- a/project/cmake/scripts/common/PrepareEnv.cmake +++ /dev/null | |||
| @@ -1,64 +0,0 @@ | |||
| 1 | # parse version.txt and libKODI_guilib.h to get the version and API info | ||
| 2 | include(${CORE_SOURCE_DIR}/project/cmake/scripts/common/Macros.cmake) | ||
| 3 | core_find_versions() | ||
| 4 | |||
| 5 | # in case we need to download something, set KODI_MIRROR to the default if not alread set | ||
| 6 | if(NOT DEFINED KODI_MIRROR) | ||
| 7 | set(KODI_MIRROR "http://mirrors.kodi.tv") | ||
| 8 | endif() | ||
| 9 | |||
| 10 | ### copy all the addon binding header files to include/kodi | ||
| 11 | # make sure include/kodi exists and is empty | ||
| 12 | set(APP_LIB_DIR ${ADDON_DEPENDS_PATH}/lib/${APP_NAME_LC}) | ||
| 13 | if(NOT EXISTS "${APP_LIB_DIR}/") | ||
| 14 | file(MAKE_DIRECTORY ${APP_LIB_DIR}) | ||
| 15 | endif() | ||
| 16 | |||
| 17 | set(APP_DATA_DIR ${ADDON_DEPENDS_PATH}/share/${APP_NAME_LC}) | ||
| 18 | if(NOT EXISTS "${APP_DATA_DIR}/") | ||
| 19 | file(MAKE_DIRECTORY ${APP_DATA_DIR}) | ||
| 20 | endif() | ||
| 21 | |||
| 22 | set(APP_INCLUDE_DIR ${ADDON_DEPENDS_PATH}/include/${APP_NAME_LC}) | ||
| 23 | if(NOT EXISTS "${APP_INCLUDE_DIR}/") | ||
| 24 | file(MAKE_DIRECTORY ${APP_INCLUDE_DIR}) | ||
| 25 | endif() | ||
| 26 | |||
| 27 | # make sure C++11 is always set | ||
| 28 | if(NOT WIN32) | ||
| 29 | string(REGEX MATCH "-std=(gnu|c)\\+\\+11" cxx11flag "${CMAKE_CXX_FLAGS}") | ||
| 30 | if(NOT cxx11flag) | ||
| 31 | set(CXX11_SWITCH "-std=c++11") | ||
| 32 | endif() | ||
| 33 | endif() | ||
| 34 | |||
| 35 | # generate the proper KodiConfig.cmake file | ||
| 36 | configure_file(${CORE_SOURCE_DIR}/project/cmake/KodiConfig.cmake.in ${APP_LIB_DIR}/KodiConfig.cmake @ONLY) | ||
| 37 | |||
| 38 | # copy cmake helpers to lib/kodi | ||
| 39 | file(COPY ${CORE_SOURCE_DIR}/project/cmake/scripts/common/AddonHelpers.cmake | ||
| 40 | ${CORE_SOURCE_DIR}/project/cmake/scripts/common/AddOptions.cmake | ||
| 41 | DESTINATION ${APP_LIB_DIR}) | ||
| 42 | |||
| 43 | ### copy all the addon binding header files to include/kodi | ||
| 44 | # parse addon-bindings.mk to get the list of header files to copy | ||
| 45 | core_file_read_filtered(bindings ${CORE_SOURCE_DIR}/xbmc/addons/addon-bindings.mk) | ||
| 46 | foreach(binding ${bindings}) | ||
| 47 | string(REPLACE " =" ";" binding "${binding}") | ||
| 48 | string(REPLACE "+=" ";" binding "${binding}") | ||
| 49 | list(GET binding 1 header) | ||
| 50 | # copy the header file to include/kodi | ||
| 51 | configure_file(${CORE_SOURCE_DIR}/${header} ${APP_INCLUDE_DIR} COPYONLY) | ||
| 52 | endforeach() | ||
| 53 | |||
| 54 | ### processing additional tools required by the platform | ||
| 55 | if(EXISTS ${CORE_SOURCE_DIR}/project/cmake/scripts/${CORE_SYSTEM_NAME}/tools/) | ||
| 56 | file(GLOB platform_tools ${CORE_SOURCE_DIR}/project/cmake/scripts/${CORE_SYSTEM_NAME}/tools/*.cmake) | ||
| 57 | foreach(platform_tool ${platform_tools}) | ||
| 58 | get_filename_component(platform_tool_name ${platform_tool} NAME_WE) | ||
| 59 | message(STATUS "Processing ${CORE_SYSTEM_NAME} specific tool: ${platform_tool_name}") | ||
| 60 | |||
| 61 | # include the file | ||
| 62 | include(${platform_tool}) | ||
| 63 | endforeach() | ||
| 64 | endif() | ||
diff --git a/project/cmake/scripts/common/ProjectMacros.cmake b/project/cmake/scripts/common/ProjectMacros.cmake deleted file mode 100644 index e73ef90..0000000 --- a/project/cmake/scripts/common/ProjectMacros.cmake +++ /dev/null | |||
| @@ -1,89 +0,0 @@ | |||
| 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} DIRECTORY) | ||
| 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 | # On return: | ||
| 27 | # xbt is added to ${XBT_FILES}, data added to ${install_data}, mirror in build tree | ||
| 28 | function(copy_skin_to_buildtree skin) | ||
| 29 | file(GLOB_RECURSE FILES ${skin}/*) | ||
| 30 | file(GLOB_RECURSE MEDIA_FILES ${skin}/media/*) | ||
| 31 | list(REMOVE_ITEM FILES ${MEDIA_FILES}) | ||
| 32 | foreach(file ${FILES}) | ||
| 33 | copy_file_to_buildtree(${file}) | ||
| 34 | endforeach() | ||
| 35 | file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${dest}/media) | ||
| 36 | string(REPLACE "${CORE_SOURCE_DIR}/" "" dest ${skin}) | ||
| 37 | pack_xbt(${skin}/media ${CMAKE_BINARY_DIR}/${dest}/media/Textures.xbt) | ||
| 38 | |||
| 39 | file(GLOB THEMES RELATIVE ${skin}/themes ${skin}/themes/*) | ||
| 40 | foreach(theme ${THEMES}) | ||
| 41 | pack_xbt(${skin}/themes/${theme} ${CMAKE_BINARY_DIR}/${dest}/media/${theme}.xbt) | ||
| 42 | endforeach() | ||
| 43 | |||
| 44 | set(XBT_FILES ${XBT_FILES} PARENT_SCOPE) | ||
| 45 | set(install_data ${install_data} PARENT_SCOPE) | ||
| 46 | endfunction() | ||
| 47 | |||
| 48 | # Get GTest tests as CMake tests. | ||
| 49 | # Copied from FindGTest.cmake | ||
| 50 | # Thanks to Daniel Blezek <blezek@gmail.com> for the GTEST_ADD_TESTS code | ||
| 51 | function(GTEST_ADD_TESTS executable extra_args) | ||
| 52 | if(NOT ARGN) | ||
| 53 | message(FATAL_ERROR "Missing ARGN: Read the documentation for GTEST_ADD_TESTS") | ||
| 54 | endif() | ||
| 55 | foreach(source ${ARGN}) | ||
| 56 | # This assumes that every source file passed in exists. Consider using | ||
| 57 | # SUPPORT_SOURCES for source files which do not contain tests and might | ||
| 58 | # have to be generated. | ||
| 59 | file(READ "${source}" contents) | ||
| 60 | string(REGEX MATCHALL "TEST_?[F]?\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents}) | ||
| 61 | foreach(hit ${found_tests}) | ||
| 62 | string(REGEX REPLACE ".*\\( *([A-Za-z_0-9]+), *([A-Za-z_0-9]+) *\\).*" "\\1.\\2" test_name ${hit}) | ||
| 63 | add_test(${test_name} ${executable} --gtest_filter=${test_name} ${extra_args}) | ||
| 64 | endforeach() | ||
| 65 | # Groups parametrized tests under a single ctest entry | ||
| 66 | string(REGEX MATCHALL "INSTANTIATE_TEST_CASE_P\\(([^,]+), *([^,]+)" found_tests2 ${contents}) | ||
| 67 | foreach(hit ${found_tests2}) | ||
| 68 | string(SUBSTRING ${hit} 24 -1 test_name) | ||
| 69 | string(REPLACE "," ";" test_name "${test_name}") | ||
| 70 | list(GET test_name 0 filter_name) | ||
| 71 | list(GET test_name 1 test_prefix) | ||
| 72 | string(STRIP ${test_prefix} test_prefix) | ||
| 73 | add_test(${test_prefix}.${filter_name} ${executable} --gtest_filter=${filter_name}* ${extra_args}) | ||
| 74 | endforeach() | ||
| 75 | endforeach() | ||
| 76 | endfunction() | ||
| 77 | |||
| 78 | function(whole_archive output) | ||
| 79 | if(CMAKE_CXX_COMPILER_ID STREQUAL GNU OR CMAKE_CXX_COMPILER_ID STREQUAL Clang) | ||
| 80 | set(${output} -Wl,--whole-archive ${ARGN} -Wl,--no-whole-archive PARENT_SCOPE) | ||
| 81 | elseif(CMAKE_CXX_COMPILER_ID STREQUAL AppleClang) | ||
| 82 | foreach(library ${ARGN}) | ||
| 83 | list(APPEND ${output} -Wl,-force_load ${library}) | ||
| 84 | set(${output} ${${output}} PARENT_SCOPE) | ||
| 85 | endforeach() | ||
| 86 | else() | ||
| 87 | set(${output} ${ARGN} PARENT_SCOPE) | ||
| 88 | endif() | ||
| 89 | endfunction() | ||
diff --git a/project/cmake/scripts/common/Uninstall.cmake b/project/cmake/scripts/common/Uninstall.cmake deleted file mode 100644 index 5660e19..0000000 --- a/project/cmake/scripts/common/Uninstall.cmake +++ /dev/null | |||
| @@ -1,22 +0,0 @@ | |||
| 1 | # Uninstall target | ||
| 2 | set(MANIFEST ${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt) | ||
| 3 | if(EXISTS ${MANIFEST}) | ||
| 4 | file(STRINGS ${MANIFEST} files) | ||
| 5 | foreach(file IN LISTS files) | ||
| 6 | if(EXISTS $ENV{DESTDIR}${file}) | ||
| 7 | message(STATUS "Uninstalling: ${file}") | ||
| 8 | execute_process( | ||
| 9 | COMMAND ${CMAKE_COMMAND} -E remove $ENV{DESTDIR}${file} | ||
| 10 | OUTPUT_VARIABLE rm_out | ||
| 11 | RESULT_VARIABLE rm_retval | ||
| 12 | ) | ||
| 13 | if(NOT "${rm_retval}" STREQUAL 0) | ||
| 14 | message(FATAL_ERROR "Failed to remove file: $ENV{DESTDIR}${file}") | ||
| 15 | endif() | ||
| 16 | else() | ||
| 17 | message(STATUS "File does not exist: $ENV{DESTDIR}${file}") | ||
| 18 | endif() | ||
| 19 | endforeach(file) | ||
| 20 | else() | ||
| 21 | message(STATUS "Cannot find install manifest: '${MANIFEST}'") | ||
| 22 | endif() | ||
