diff options
| author | manuel <manuel@mausz.at> | 2018-04-17 00:15:38 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2018-04-17 00:15:38 +0200 |
| commit | b3d195f0188758a14875a5a2f270e4fd190a679f (patch) | |
| tree | cbe6a2d51afd7be095e29fd612107044cf1f391e /cmake/scripts/common | |
| parent | a51f51db67e3eab80ac2ed28d403a6d77f7acc45 (diff) | |
| download | kodi-pvr-build-b3d195f0188758a14875a5a2f270e4fd190a679f.tar.gz kodi-pvr-build-b3d195f0188758a14875a5a2f270e4fd190a679f.tar.bz2 kodi-pvr-build-b3d195f0188758a14875a5a2f270e4fd190a679f.zip | |
sync with upstream
Diffstat (limited to 'cmake/scripts/common')
| -rw-r--r-- | cmake/scripts/common/AddonHelpers.cmake | 33 | ||||
| -rw-r--r-- | cmake/scripts/common/ArchSetup.cmake | 4 | ||||
| -rw-r--r-- | cmake/scripts/common/HandleDepends.cmake | 3 | ||||
| -rw-r--r-- | cmake/scripts/common/Macros.cmake | 111 | ||||
| -rw-r--r-- | cmake/scripts/common/Uninstall.cmake | 36 |
5 files changed, 133 insertions, 54 deletions
diff --git a/cmake/scripts/common/AddonHelpers.cmake b/cmake/scripts/common/AddonHelpers.cmake index c11923e..5470940 100644 --- a/cmake/scripts/common/AddonHelpers.cmake +++ b/cmake/scripts/common/AddonHelpers.cmake | |||
| @@ -6,15 +6,20 @@ | |||
| 6 | # Sadly we cannot extend the 'package' target, as it is a builtin target, see | 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 | 7 | # http://public.kitware.com/Bug/view.php?id=8438 |
| 8 | # Thus, we have to add an 'addon-package' target. | 8 | # Thus, we have to add an 'addon-package' target. |
| 9 | add_custom_target(addon-package | 9 | get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) |
| 10 | COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target package) | 10 | if(_isMultiConfig) |
| 11 | add_custom_target(addon-package DEPENDS PACKAGE) | ||
| 12 | else() | ||
| 13 | add_custom_target(addon-package | ||
| 14 | COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target package) | ||
| 15 | endif() | ||
| 11 | 16 | ||
| 12 | macro(add_cpack_workaround target version ext) | 17 | macro(add_cpack_workaround target version ext) |
| 13 | if(NOT PACKAGE_DIR) | 18 | if(NOT PACKAGE_DIR) |
| 14 | set(PACKAGE_DIR "${CMAKE_INSTALL_PREFIX}/zips") | 19 | set(PACKAGE_DIR "${CMAKE_INSTALL_PREFIX}/zips") |
| 15 | endif() | 20 | endif() |
| 16 | 21 | ||
| 17 | add_custom_command(TARGET addon-package PRE_BUILD | 22 | add_custom_command(TARGET addon-package POST_BUILD |
| 18 | COMMAND ${CMAKE_COMMAND} -E make_directory ${PACKAGE_DIR} | 23 | 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}) | 24 | COMMAND ${CMAKE_COMMAND} -E copy ${CPACK_PACKAGE_DIRECTORY}/addon-${target}-${version}.${ext} ${PACKAGE_DIR}/${target}-${version}.${ext}) |
| 20 | endmacro() | 25 | endmacro() |
| @@ -194,7 +199,7 @@ macro (build_addon target prefix libs) | |||
| 194 | endif() | 199 | endif() |
| 195 | 200 | ||
| 196 | string(CONFIGURE "${addon_file}" addon_file_conf @ONLY) | 201 | string(CONFIGURE "${addon_file}" addon_file_conf @ONLY) |
| 197 | file(GENERATE OUTPUT ${PROJECT_SOURCE_DIR}/${target}/addon.xml CONTENT "${addon_file_conf}") | 202 | file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${target}/addon.xml CONTENT "${addon_file_conf}") |
| 198 | if(${APP_NAME_UC}_BUILD_DIR) | 203 | if(${APP_NAME_UC}_BUILD_DIR) |
| 199 | file(GENERATE OUTPUT ${${APP_NAME_UC}_BUILD_DIR}/addons/${target}/addon.xml CONTENT "${addon_file_conf}") | 204 | file(GENERATE OUTPUT ${${APP_NAME_UC}_BUILD_DIR}/addons/${target}/addon.xml CONTENT "${addon_file_conf}") |
| 200 | endif() | 205 | endif() |
| @@ -207,7 +212,7 @@ macro (build_addon target prefix libs) | |||
| 207 | 212 | ||
| 208 | file(READ ${PROJECT_SOURCE_DIR}/${target}/resources/settings.xml.in settings_file) | 213 | file(READ ${PROJECT_SOURCE_DIR}/${target}/resources/settings.xml.in settings_file) |
| 209 | string(CONFIGURE "${settings_file}" settings_file_conf @ONLY) | 214 | string(CONFIGURE "${settings_file}" settings_file_conf @ONLY) |
| 210 | file(GENERATE OUTPUT ${PROJECT_SOURCE_DIR}/${target}/resources/settings.xml CONTENT "${settings_file_conf}") | 215 | file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${target}/resources/settings.xml CONTENT "${settings_file_conf}") |
| 211 | if(${APP_NAME_UC}_BUILD_DIR) | 216 | if(${APP_NAME_UC}_BUILD_DIR) |
| 212 | file(GENERATE OUTPUT ${${APP_NAME_UC}_BUILD_DIR}/addons/${target}/resources/settings.xml CONTENT "${settings_file_conf}") | 217 | file(GENERATE OUTPUT ${${APP_NAME_UC}_BUILD_DIR}/addons/${target}/resources/settings.xml CONTENT "${settings_file_conf}") |
| 213 | endif() | 218 | endif() |
| @@ -230,7 +235,7 @@ macro (build_addon target prefix libs) | |||
| 230 | set(CPACK_COMPONENTS_IGNORE_GROUPS 1) | 235 | set(CPACK_COMPONENTS_IGNORE_GROUPS 1) |
| 231 | list(APPEND CPACK_COMPONENTS_ALL ${target}-${${prefix}_VERSION}) | 236 | list(APPEND CPACK_COMPONENTS_ALL ${target}-${${prefix}_VERSION}) |
| 232 | # Pack files together to create an archive | 237 | # Pack files together to create an archive |
| 233 | install(DIRECTORY ${target} DESTINATION ./ | 238 | install(DIRECTORY ${target} ${CMAKE_CURRENT_BINARY_DIR}/${target} DESTINATION ./ |
| 234 | COMPONENT ${target}-${${prefix}_VERSION} | 239 | COMPONENT ${target}-${${prefix}_VERSION} |
| 235 | REGEX ".+\\.xml\\.in(clude)?$" EXCLUDE) | 240 | REGEX ".+\\.xml\\.in(clude)?$" EXCLUDE) |
| 236 | if(WIN32) | 241 | if(WIN32) |
| @@ -247,21 +252,15 @@ macro (build_addon target prefix libs) | |||
| 247 | endif() | 252 | endif() |
| 248 | endif() | 253 | endif() |
| 249 | 254 | ||
| 250 | # in case of a VC++ project the installation location contains a $(Configuration) VS variable | ||
| 251 | # we replace it with ${CMAKE_BUILD_TYPE} (which doesn't cover the case when the build configuration | ||
| 252 | # is changed within Visual Studio) | ||
| 253 | string(REPLACE "$(Configuration)" "${CMAKE_BUILD_TYPE}" LIBRARY_LOCATION "${LIBRARY_LOCATION}") | ||
| 254 | |||
| 255 | if(${prefix}_SOURCES) | 255 | if(${prefix}_SOURCES) |
| 256 | # install the generated DLL file | 256 | # install the generated DLL file |
| 257 | install(PROGRAMS ${LIBRARY_LOCATION} DESTINATION ${target} | 257 | install(PROGRAMS ${LIBRARY_LOCATION} DESTINATION ${target} |
| 258 | COMPONENT ${target}-${${prefix}_VERSION}) | 258 | COMPONENT ${target}-${${prefix}_VERSION}) |
| 259 | 259 | ||
| 260 | if(CMAKE_BUILD_TYPE MATCHES Debug) | 260 | # for debug builds also install the PDB file |
| 261 | # for debug builds also install the PDB file | 261 | install(FILES $<TARGET_PDB_FILE:${target}> DESTINATION ${target} |
| 262 | install(FILES $<TARGET_PDB_FILE:${target}> DESTINATION ${target} | 262 | CONFIGURATIONS Debug RelWithDebInfo |
| 263 | COMPONENT ${target}-${${prefix}_VERSION}) | 263 | COMPONENT ${target}-${${prefix}_VERSION}) |
| 264 | endif() | ||
| 265 | endif() | 264 | endif() |
| 266 | if(${prefix}_CUSTOM_BINARY) | 265 | if(${prefix}_CUSTOM_BINARY) |
| 267 | install(FILES ${LIBRARY_LOCATION} DESTINATION ${target} RENAME ${LIBRARY_FILENAME}) | 266 | install(FILES ${LIBRARY_LOCATION} DESTINATION ${target} RENAME ${LIBRARY_FILENAME}) |
| @@ -325,7 +324,7 @@ macro (build_addon target prefix libs) | |||
| 325 | if (${prefix}_CUSTOM_BINARY) | 324 | if (${prefix}_CUSTOM_BINARY) |
| 326 | install(FILES ${LIBRARY_LOCATION} DESTINATION ${CMAKE_INSTALL_LIBDIR}/addons/${target} RENAME ${LIBRARY_FILENAME}) | 325 | install(FILES ${LIBRARY_LOCATION} DESTINATION ${CMAKE_INSTALL_LIBDIR}/addons/${target} RENAME ${LIBRARY_FILENAME}) |
| 327 | endif() | 326 | endif() |
| 328 | install(DIRECTORY ${target} DESTINATION ${CMAKE_INSTALL_DATADIR}/addons | 327 | install(DIRECTORY ${target} ${CMAKE_CURRENT_BINARY_DIR}/${target} DESTINATION ${CMAKE_INSTALL_DATADIR}/addons |
| 329 | REGEX ".+\\.xml\\.in(clude)?$" EXCLUDE) | 328 | REGEX ".+\\.xml\\.in(clude)?$" EXCLUDE) |
| 330 | if(${prefix}_CUSTOM_DATA) | 329 | if(${prefix}_CUSTOM_DATA) |
| 331 | install(DIRECTORY ${${prefix}_CUSTOM_DATA} DESTINATION ${CMAKE_INSTALL_DATADIR}/addons/${target}/resources) | 330 | install(DIRECTORY ${${prefix}_CUSTOM_DATA} DESTINATION ${CMAKE_INSTALL_DATADIR}/addons/${target}/resources) |
diff --git a/cmake/scripts/common/ArchSetup.cmake b/cmake/scripts/common/ArchSetup.cmake index 3b81533..c97929e 100644 --- a/cmake/scripts/common/ArchSetup.cmake +++ b/cmake/scripts/common/ArchSetup.cmake | |||
| @@ -153,6 +153,10 @@ if(NOT DEFINED NEON OR NEON) | |||
| 153 | endif() | 153 | endif() |
| 154 | endif() | 154 | endif() |
| 155 | 155 | ||
| 156 | if(PLATFORM_DEFINES) | ||
| 157 | add_options(ALL_LANGUAGES ALL_BUILDS ${PLATFORM_DEFINES}) | ||
| 158 | endif() | ||
| 159 | |||
| 156 | if(CMAKE_BUILD_TYPE STREQUAL "Debug") | 160 | if(CMAKE_BUILD_TYPE STREQUAL "Debug") |
| 157 | add_options (ALL_LANGUAGES DEBUG "-g" "-D_DEBUG" "-Wall") | 161 | add_options (ALL_LANGUAGES DEBUG "-g" "-D_DEBUG" "-Wall") |
| 158 | endif() | 162 | endif() |
diff --git a/cmake/scripts/common/HandleDepends.cmake b/cmake/scripts/common/HandleDepends.cmake index 49e5ac8..fb110d6 100644 --- a/cmake/scripts/common/HandleDepends.cmake +++ b/cmake/scripts/common/HandleDepends.cmake | |||
| @@ -54,9 +54,6 @@ function(add_addon_depends addon searchpath) | |||
| 54 | if(EXISTS ${dir}/flags.txt) | 54 | if(EXISTS ${dir}/flags.txt) |
| 55 | set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${dir}/flags.txt) | 55 | set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${dir}/flags.txt) |
| 56 | file(STRINGS ${dir}/flags.txt extraflags) | 56 | file(STRINGS ${dir}/flags.txt extraflags) |
| 57 | |||
| 58 | # replace some custom placeholders | ||
| 59 | string(REPLACE "@MINGW_TOOLCHAIN_FILE@" "${OUTPUT_DIR}/Toolchain_mingw32.cmake" extraflags "${extraflags}") | ||
| 60 | string(REPLACE " " ";" extraflags ${extraflags}) | 57 | string(REPLACE " " ";" extraflags ${extraflags}) |
| 61 | 58 | ||
| 62 | message(STATUS "${id} extraflags: ${extraflags}") | 59 | message(STATUS "${id} extraflags: ${extraflags}") |
diff --git a/cmake/scripts/common/Macros.cmake b/cmake/scripts/common/Macros.cmake index d508f87..c21069d 100644 --- a/cmake/scripts/common/Macros.cmake +++ b/cmake/scripts/common/Macros.cmake | |||
| @@ -338,15 +338,54 @@ macro(export_dep) | |||
| 338 | mark_as_advanced(${depup}_LIBRARIES) | 338 | mark_as_advanced(${depup}_LIBRARIES) |
| 339 | endmacro() | 339 | endmacro() |
| 340 | 340 | ||
| 341 | # add a required dependency of main application | 341 | # split dependency specification to name and version |
| 342 | # Arguments: | 342 | # Arguments: |
| 343 | # dep_list name of find rule for dependency, used uppercased for variable prefix | 343 | # depspec dependency specification that can optionally include a required |
| 344 | # also accepts a list of multiple dependencies | 344 | # package version |
| 345 | # syntax: [package name], [package name]>=[version] (minimum version), | ||
| 346 | # or [package name]=[version] (exact version) | ||
| 347 | # name_outvar variable that should receive the package name | ||
| 348 | # version_outvar variable that should receive the package version part (>=[version]) | ||
| 345 | # On return: | 349 | # On return: |
| 346 | # dependency added to ${SYSTEM_INCLUDES}, ${DEPLIBS} and ${DEP_DEFINES} | 350 | # ${name_outvar} and ${version_outvar} in caller scope are set to respective values. |
| 351 | # ${version_outvar} may be unset if there is no specific version requested. | ||
| 352 | function(split_dependency_specification depspec name_outvar version_outvar) | ||
| 353 | if(${depspec} MATCHES "^([^>]*)(>?=[0-9.]+)$") | ||
| 354 | set(${name_outvar} ${CMAKE_MATCH_1} PARENT_SCOPE) | ||
| 355 | set(${version_outvar} ${CMAKE_MATCH_2} PARENT_SCOPE) | ||
| 356 | else() | ||
| 357 | set(${name_outvar} ${depspec} PARENT_SCOPE) | ||
| 358 | unset(${version_outvar} PARENT_SCOPE) | ||
| 359 | endif() | ||
| 360 | endfunction() | ||
| 361 | |||
| 362 | # helper macro to split version info from req and call find_package | ||
| 363 | macro(find_package_with_ver package) | ||
| 364 | set(_find_arguments "${ARGN}") | ||
| 365 | if("${ARGV1}" MATCHES "^(>)?=([0-9.]+)$") | ||
| 366 | # We have a version spec, parse it | ||
| 367 | list(REMOVE_AT _find_arguments 0) | ||
| 368 | # ">" not present? -> exact match | ||
| 369 | if(NOT CMAKE_MATCH_1) | ||
| 370 | list(INSERT _find_arguments 0 "EXACT") | ||
| 371 | endif() | ||
| 372 | find_package(${package} ${CMAKE_MATCH_2} ${_find_arguments}) | ||
| 373 | else() | ||
| 374 | find_package(${package} ${_find_arguments}) | ||
| 375 | endif() | ||
| 376 | unset(_find_arguments) | ||
| 377 | endmacro() | ||
| 378 | |||
| 379 | # add required dependencies of main application | ||
| 380 | # Arguments: | ||
| 381 | # dep_list One or many dependency specifications (see split_dependency_specification) | ||
| 382 | # for syntax). The dependency name is used uppercased as variable prefix. | ||
| 383 | # On return: | ||
| 384 | # dependencies added to ${SYSTEM_INCLUDES}, ${DEPLIBS} and ${DEP_DEFINES} | ||
| 347 | function(core_require_dep) | 385 | function(core_require_dep) |
| 348 | foreach(dep ${ARGN}) | 386 | foreach(depspec ${ARGN}) |
| 349 | find_package(${dep} REQUIRED) | 387 | split_dependency_specification(${depspec} dep version) |
| 388 | find_package_with_ver(${dep} ${version} REQUIRED) | ||
| 350 | string(TOUPPER ${dep} depup) | 389 | string(TOUPPER ${dep} depup) |
| 351 | list(APPEND SYSTEM_INCLUDES ${${depup}_INCLUDE_DIRS}) | 390 | list(APPEND SYSTEM_INCLUDES ${${depup}_INCLUDE_DIRS}) |
| 352 | list(APPEND DEPLIBS ${${depup}_LIBRARIES}) | 391 | list(APPEND DEPLIBS ${${depup}_LIBRARIES}) |
| @@ -355,15 +394,16 @@ function(core_require_dep) | |||
| 355 | endforeach() | 394 | endforeach() |
| 356 | endfunction() | 395 | endfunction() |
| 357 | 396 | ||
| 358 | # add a required dyloaded dependency of main application | 397 | # add required dyloaded dependencies of main application |
| 359 | # Arguments: | 398 | # Arguments: |
| 360 | # dep_list name of find rule for dependency, used uppercased for variable prefix | 399 | # dep_list One or many dependency specifications (see split_dependency_specification) |
| 361 | # also accepts a list of multiple dependencies | 400 | # for syntax). The dependency name is used uppercased as variable prefix. |
| 362 | # On return: | 401 | # On return: |
| 363 | # dependency added to ${SYSTEM_INCLUDES}, ${dep}_SONAME is set up | 402 | # dependency added to ${SYSTEM_INCLUDES}, ${dep}_SONAME is set up |
| 364 | function(core_require_dyload_dep) | 403 | function(core_require_dyload_dep) |
| 365 | foreach(dep ${ARGN}) | 404 | foreach(depspec ${ARGN}) |
| 366 | find_package(${dep} REQUIRED) | 405 | split_dependency_specification(${depspec} dep version) |
| 406 | find_package_with_ver(${dep} ${version} REQUIRED) | ||
| 367 | string(TOUPPER ${dep} depup) | 407 | string(TOUPPER ${dep} depup) |
| 368 | list(APPEND SYSTEM_INCLUDES ${${depup}_INCLUDE_DIRS}) | 408 | list(APPEND SYSTEM_INCLUDES ${${depup}_INCLUDE_DIRS}) |
| 369 | list(APPEND DEP_DEFINES ${${depup}_DEFINITIONS}) | 409 | list(APPEND DEP_DEFINES ${${depup}_DEFINITIONS}) |
| @@ -385,20 +425,21 @@ macro(setup_enable_switch) | |||
| 385 | set(${enable_switch} "AUTO" CACHE STRING "Enable ${depup} support?") | 425 | set(${enable_switch} "AUTO" CACHE STRING "Enable ${depup} support?") |
| 386 | endmacro() | 426 | endmacro() |
| 387 | 427 | ||
| 388 | # add an optional dependency of main application | 428 | # add optional dependencies of main application |
| 389 | # Arguments: | 429 | # Arguments: |
| 390 | # dep_list name of find rule for dependency, used uppercased for variable prefix | 430 | # dep_list One or many dependency specifications (see split_dependency_specification) |
| 391 | # also accepts a list of multiple dependencies | 431 | # for syntax). The dependency name is used uppercased as variable prefix. |
| 392 | # On return: | 432 | # On return: |
| 393 | # dependency optionally added to ${SYSTEM_INCLUDES}, ${DEPLIBS} and ${DEP_DEFINES} | 433 | # dependency optionally added to ${SYSTEM_INCLUDES}, ${DEPLIBS} and ${DEP_DEFINES} |
| 394 | function(core_optional_dep) | 434 | function(core_optional_dep) |
| 395 | foreach(dep ${ARGN}) | 435 | foreach(depspec ${ARGN}) |
| 396 | set(_required False) | 436 | set(_required False) |
| 437 | split_dependency_specification(${depspec} dep version) | ||
| 397 | setup_enable_switch() | 438 | setup_enable_switch() |
| 398 | if(${enable_switch} STREQUAL AUTO) | 439 | if(${enable_switch} STREQUAL AUTO) |
| 399 | find_package(${dep}) | 440 | find_package_with_ver(${dep} ${version}) |
| 400 | elseif(${${enable_switch}}) | 441 | elseif(${${enable_switch}}) |
| 401 | find_package(${dep} REQUIRED) | 442 | find_package_with_ver(${dep} ${version} REQUIRED) |
| 402 | set(_required True) | 443 | set(_required True) |
| 403 | endif() | 444 | endif() |
| 404 | 445 | ||
| @@ -417,20 +458,21 @@ function(core_optional_dep) | |||
| 417 | set(final_message ${final_message} PARENT_SCOPE) | 458 | set(final_message ${final_message} PARENT_SCOPE) |
| 418 | endfunction() | 459 | endfunction() |
| 419 | 460 | ||
| 420 | # add an optional dyloaded dependency of main application | 461 | # add optional dyloaded dependencies of main application |
| 421 | # Arguments: | 462 | # Arguments: |
| 422 | # dep_list name of find rule for dependency, used uppercased for variable prefix | 463 | # dep_list One or many dependency specifications (see split_dependency_specification) |
| 423 | # also accepts a list of multiple dependencies | 464 | # for syntax). The dependency name is used uppercased as variable prefix. |
| 424 | # On return: | 465 | # On return: |
| 425 | # dependency optionally added to ${SYSTEM_INCLUDES}, ${DEP_DEFINES}, ${dep}_SONAME is set up | 466 | # dependency optionally added to ${SYSTEM_INCLUDES}, ${DEP_DEFINES}, ${dep}_SONAME is set up |
| 426 | function(core_optional_dyload_dep) | 467 | function(core_optional_dyload_dep) |
| 427 | foreach(dep ${ARGN}) | 468 | foreach(depspec ${ARGN}) |
| 428 | set(_required False) | 469 | set(_required False) |
| 429 | setup_enable_switch() | 470 | split_dependency_specification(${depspec} dep version) |
| 471 | setup_enable_switch() | ||
| 430 | if(${enable_switch} STREQUAL AUTO) | 472 | if(${enable_switch} STREQUAL AUTO) |
| 431 | find_package(${dep}) | 473 | find_package_with_ver(${dep} ${version}) |
| 432 | elseif(${${enable_switch}}) | 474 | elseif(${${enable_switch}}) |
| 433 | find_package(${dep} REQUIRED) | 475 | find_package_with_ver(${dep} ${version} REQUIRED) |
| 434 | set(_required True) | 476 | set(_required True) |
| 435 | endif() | 477 | endif() |
| 436 | 478 | ||
| @@ -592,6 +634,7 @@ function(core_find_git_rev stamp) | |||
| 592 | else() | 634 | else() |
| 593 | find_package(Git) | 635 | find_package(Git) |
| 594 | if(GIT_FOUND AND EXISTS ${CMAKE_SOURCE_DIR}/.git) | 636 | if(GIT_FOUND AND EXISTS ${CMAKE_SOURCE_DIR}/.git) |
| 637 | # get tree status i.e. clean working tree vs dirty (uncommited or unstashed changes, etc.) | ||
| 595 | execute_process(COMMAND ${GIT_EXECUTABLE} update-index --ignore-submodules -q --refresh | 638 | execute_process(COMMAND ${GIT_EXECUTABLE} update-index --ignore-submodules -q --refresh |
| 596 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) | 639 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) |
| 597 | execute_process(COMMAND ${GIT_EXECUTABLE} diff-files --ignore-submodules --quiet -- | 640 | execute_process(COMMAND ${GIT_EXECUTABLE} diff-files --ignore-submodules --quiet -- |
| @@ -602,21 +645,21 @@ function(core_find_git_rev stamp) | |||
| 602 | RESULT_VARIABLE status_code | 645 | RESULT_VARIABLE status_code |
| 603 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) | 646 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) |
| 604 | endif() | 647 | endif() |
| 648 | # get HEAD commit SHA-1 | ||
| 649 | execute_process(COMMAND ${GIT_EXECUTABLE} log -n 1 --pretty=format:"%h" HEAD | ||
| 650 | OUTPUT_VARIABLE HASH | ||
| 651 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) | ||
| 652 | string(REPLACE "\"" "" HASH ${HASH}) | ||
| 653 | |||
| 605 | if(status_code) | 654 | if(status_code) |
| 606 | execute_process(COMMAND ${GIT_EXECUTABLE} log -n 1 --pretty=format:"%h-dirty" HEAD | 655 | string(CONCAT HASH ${HASH} "-dirty") |
| 607 | OUTPUT_VARIABLE HASH | ||
| 608 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) | ||
| 609 | string(SUBSTRING ${HASH} 1 13 HASH) | ||
| 610 | else() | ||
| 611 | execute_process(COMMAND ${GIT_EXECUTABLE} log -n 1 --pretty=format:"%h" HEAD | ||
| 612 | OUTPUT_VARIABLE HASH | ||
| 613 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) | ||
| 614 | string(SUBSTRING ${HASH} 1 7 HASH) | ||
| 615 | endif() | 656 | endif() |
| 657 | |||
| 658 | # get HEAD commit date | ||
| 616 | execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:"%cd" --date=short HEAD | 659 | execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:"%cd" --date=short HEAD |
| 617 | OUTPUT_VARIABLE DATE | 660 | OUTPUT_VARIABLE DATE |
| 618 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) | 661 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) |
| 619 | string(SUBSTRING ${DATE} 1 10 DATE) | 662 | string(REPLACE "\"" "" DATE ${DATE}) |
| 620 | string(REPLACE "-" "" DATE ${DATE}) | 663 | string(REPLACE "-" "" DATE ${DATE}) |
| 621 | else() | 664 | else() |
| 622 | string(TIMESTAMP DATE "%Y%m%d" UTC) | 665 | string(TIMESTAMP DATE "%Y%m%d" UTC) |
diff --git a/cmake/scripts/common/Uninstall.cmake b/cmake/scripts/common/Uninstall.cmake index 5660e19..5753857 100644 --- a/cmake/scripts/common/Uninstall.cmake +++ b/cmake/scripts/common/Uninstall.cmake | |||
| @@ -1,9 +1,40 @@ | |||
| 1 | macro(remove_empty_dirs) | ||
| 2 | list(REMOVE_DUPLICATES DIRECTORIES) | ||
| 3 | unset(PDIRECTORIES) | ||
| 4 | foreach(dir IN LISTS DIRECTORIES) | ||
| 5 | if(EXISTS $ENV{DESTDIR}${dir}) | ||
| 6 | file(GLOB _res $ENV{DESTDIR}${dir}/*) | ||
| 7 | list(LENGTH _res _len) | ||
| 8 | if(_len EQUAL 0 AND EXISTS $ENV{DESTDIR}${dir}) | ||
| 9 | message(STATUS "Removing empty dir: ${dir}") | ||
| 10 | execute_process( | ||
| 11 | COMMAND ${CMAKE_COMMAND} -E remove_directory $ENV{DESTDIR}${dir} | ||
| 12 | OUTPUT_VARIABLE rm_out | ||
| 13 | RESULT_VARIABLE rm_retval | ||
| 14 | ) | ||
| 15 | if(NOT "${rm_retval}" STREQUAL 0) | ||
| 16 | message(FATAL_ERROR "Failed to remove directory: $ENV{DESTDIR}${dir}") | ||
| 17 | endif() | ||
| 18 | get_filename_component(_pdir $ENV{DESTDIR}${dir} DIRECTORY) | ||
| 19 | list(APPEND PDIRECTORIES ${_pdir}) | ||
| 20 | endif() | ||
| 21 | endif() | ||
| 22 | endforeach() | ||
| 23 | list(LENGTH PDIRECTORIES _plen) | ||
| 24 | if(_plen GREATER 0) | ||
| 25 | set(DIRECTORIES ${PDIRECTORIES}) | ||
| 26 | remove_empty_dirs() | ||
| 27 | endif() | ||
| 28 | endmacro() | ||
| 29 | |||
| 1 | # Uninstall target | 30 | # Uninstall target |
| 2 | set(MANIFEST ${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt) | 31 | set(MANIFEST ${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt) |
| 3 | if(EXISTS ${MANIFEST}) | 32 | if(EXISTS ${MANIFEST}) |
| 4 | file(STRINGS ${MANIFEST} files) | 33 | file(STRINGS ${MANIFEST} files) |
| 5 | foreach(file IN LISTS files) | 34 | foreach(file IN LISTS files) |
| 6 | if(EXISTS $ENV{DESTDIR}${file}) | 35 | if(EXISTS $ENV{DESTDIR}${file}) |
| 36 | get_filename_component(_dir $ENV{DESTDIR}${file} DIRECTORY) | ||
| 37 | list(APPEND DIRECTORIES $ENV{DESTDIR}${_dir}) | ||
| 7 | message(STATUS "Uninstalling: ${file}") | 38 | message(STATUS "Uninstalling: ${file}") |
| 8 | execute_process( | 39 | execute_process( |
| 9 | COMMAND ${CMAKE_COMMAND} -E remove $ENV{DESTDIR}${file} | 40 | COMMAND ${CMAKE_COMMAND} -E remove $ENV{DESTDIR}${file} |
| @@ -17,6 +48,11 @@ if(EXISTS ${MANIFEST}) | |||
| 17 | message(STATUS "File does not exist: $ENV{DESTDIR}${file}") | 48 | message(STATUS "File does not exist: $ENV{DESTDIR}${file}") |
| 18 | endif() | 49 | endif() |
| 19 | endforeach(file) | 50 | endforeach(file) |
| 51 | |||
| 52 | # delete empty dirs | ||
| 53 | if(DIRECTORIES) | ||
| 54 | remove_empty_dirs() | ||
| 55 | endif() | ||
| 20 | else() | 56 | else() |
| 21 | message(STATUS "Cannot find install manifest: '${MANIFEST}'") | 57 | message(STATUS "Cannot find install manifest: '${MANIFEST}'") |
| 22 | endif() | 58 | endif() |
