diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CPackDeb.cmake | 43 | ||||
-rw-r--r-- | Modules/ExternalData.cmake | 76 | ||||
-rw-r--r-- | Modules/FindMatlab.cmake | 8 | ||||
-rw-r--r-- | Modules/GNUInstallDirs.cmake | 81 |
4 files changed, 126 insertions, 82 deletions
diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake index 1a7b923..423bb00 100644 --- a/Modules/CPackDeb.cmake +++ b/Modules/CPackDeb.cmake @@ -156,16 +156,18 @@ # * Default : :code:`CPACK_PACKAGE_CONTACT` # # .. variable:: CPACK_DEBIAN_PACKAGE_DESCRIPTION -# CPACK_COMPONENT_<COMPONENT>_DESCRIPTION +# CPACK_DEBIAN_<COMPONENT>_PACKAGE_DESCRIPTION # # The Debian package description # # * Mandatory : YES # * Default : # -# - :variable:`CPACK_DEBIAN_PACKAGE_DESCRIPTION` if set or -# - :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY` -# +# - :variable:`CPACK_COMPONENT_<compName>_DESCRIPTION` (component based installers only) if set, +# - :variable:`CPACK_PACKAGE_DESCRIPTION_FILE` if set to non default location, +# - :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY` if set, +# - :variable:`CPACK_PACKAGE_DESCRIPTION_FILE` default value if set, +# - or "no package description available" # # .. variable:: CPACK_DEBIAN_PACKAGE_SECTION # CPACK_DEBIAN_<COMPONENT>_PACKAGE_SECTION @@ -829,24 +831,23 @@ function(cpack_deb_prepare_package_vars) endif() # Description: (mandatory) - if(NOT CPACK_DEB_PACKAGE_COMPONENT) - if(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION) - if(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY) - message(FATAL_ERROR "CPackDeb: Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or CPACK_DEBIAN_PACKAGE_DESCRIPTION") - endif() - set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) + if(CPACK_DEB_PACKAGE_COMPONENT) + if(CPACK_DEBIAN_${_local_component_name}_PACKAGE_DESCRIPTION) + set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "${CPACK_DEBIAN_${_local_component_name}_PACKAGE_DESCRIPTION}") + elseif(CPACK_COMPONENT_${_local_component_name}_DESCRIPTION) + set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "${CPACK_COMPONENT_${_local_component_name}_DESCRIPTION}") endif() - else() - set(component_description_var CPACK_COMPONENT_${_local_component_name}_DESCRIPTION) - - # component description overrides package description - if(${component_description_var}) - set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${${component_description_var}}) - elseif(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION) - if(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY) - message(FATAL_ERROR "CPackDeb: Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or CPACK_DEBIAN_PACKAGE_DESCRIPTION or ${component_description_var}") - endif() - set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) + endif() + + if(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION) + if(CPACK_PACKAGE_DESCRIPTION_FILE AND NOT "${CPACK_PACKAGE_DESCRIPTION_FILE}" STREQUAL "${CMAKE_ROOT}/Templates/CPack.GenericDescription.txt") + file(READ "${CPACK_PACKAGE_DESCRIPTION_FILE}" CPACK_DEBIAN_PACKAGE_DESCRIPTION) + elseif(CPACK_PACKAGE_DESCRIPTION_SUMMARY) + set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}") + elseif(CPACK_PACKAGE_DESCRIPTION_FILE) # use default package description file content + file(READ "${CPACK_PACKAGE_DESCRIPTION_FILE}" CPACK_DEBIAN_PACKAGE_DESCRIPTION) + else() + set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "no package description available") endif() endif() diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake index a0bffe7..e7f8408 100644 --- a/Modules/ExternalData.cmake +++ b/Modules/ExternalData.cmake @@ -86,6 +86,10 @@ Module Functions in one of the paths specified in the ``ExternalData_OBJECT_STORES`` variable. + Typically only one target is needed to manage all external data within + a project. Call this function once at the end of configuration after + all data references have been processed. + Module Variables ^^^^^^^^^^^^^^^^ @@ -394,8 +398,14 @@ function(ExternalData_add_target target) set(files "") - # Set "_ExternalData_FILE_${file}" for each output file to avoid duplicate - # rules. Use local data first to prefer real files over content links. + # Set a "_ExternalData_FILE_${file}" variable for each output file to avoid + # duplicate entries within this target. Set a directory property of the same + # name to avoid repeating custom commands with the same output in this directory. + # Repeating custom commands with the same output across directories or across + # targets in the same directory may be a race, but this is likely okay because + # we use atomic replacement of output files. + # + # Use local data first to prefer real files over content links. # Custom commands to copy or link local data. get_property(data_local GLOBAL PROPERTY _ExternalData_${target}_LOCAL) @@ -405,16 +415,20 @@ function(ExternalData_add_target target) list(GET tuple 1 name) if(NOT DEFINED "_ExternalData_FILE_${file}") set("_ExternalData_FILE_${file}" 1) - add_custom_command( - COMMENT "Generating ${file}" - OUTPUT "${file}" - COMMAND ${CMAKE_COMMAND} -Drelative_top=${CMAKE_BINARY_DIR} - -Dfile=${file} -Dname=${name} - -DExternalData_ACTION=local - -DExternalData_CONFIG=${config} - -P ${_ExternalData_SELF} - MAIN_DEPENDENCY "${name}" - ) + get_property(added DIRECTORY PROPERTY "_ExternalData_FILE_${file}") + if(NOT added) + set_property(DIRECTORY PROPERTY "_ExternalData_FILE_${file}" 1) + add_custom_command( + COMMENT "Generating ${file}" + OUTPUT "${file}" + COMMAND ${CMAKE_COMMAND} -Drelative_top=${CMAKE_BINARY_DIR} + -Dfile=${file} -Dname=${name} + -DExternalData_ACTION=local + -DExternalData_CONFIG=${config} + -P ${_ExternalData_SELF} + MAIN_DEPENDENCY "${name}" + ) + endif() list(APPEND files "${file}") endif() endforeach() @@ -429,23 +443,27 @@ function(ExternalData_add_target target) set(stamp "${ext}-stamp") if(NOT DEFINED "_ExternalData_FILE_${file}") set("_ExternalData_FILE_${file}" 1) - add_custom_command( - # Users care about the data file, so hide the hash/timestamp file. - COMMENT "Generating ${file}" - # The hash/timestamp file is the output from the build perspective. - # List the real file as a second output in case it is a broken link. - # The files must be listed in this order so CMake can hide from the - # make tool that a symlink target may not be newer than the input. - OUTPUT "${file}${stamp}" "${file}" - # Run the data fetch/update script. - COMMAND ${CMAKE_COMMAND} -Drelative_top=${CMAKE_BINARY_DIR} - -Dfile=${file} -Dname=${name} -Dext=${ext} - -DExternalData_ACTION=fetch - -DExternalData_CONFIG=${config} - -P ${_ExternalData_SELF} - # Update whenever the object hash changes. - MAIN_DEPENDENCY "${name}${ext}" - ) + get_property(added DIRECTORY PROPERTY "_ExternalData_FILE_${file}") + if(NOT added) + set_property(DIRECTORY PROPERTY "_ExternalData_FILE_${file}" 1) + add_custom_command( + # Users care about the data file, so hide the hash/timestamp file. + COMMENT "Generating ${file}" + # The hash/timestamp file is the output from the build perspective. + # List the real file as a second output in case it is a broken link. + # The files must be listed in this order so CMake can hide from the + # make tool that a symlink target may not be newer than the input. + OUTPUT "${file}${stamp}" "${file}" + # Run the data fetch/update script. + COMMAND ${CMAKE_COMMAND} -Drelative_top=${CMAKE_BINARY_DIR} + -Dfile=${file} -Dname=${name} -Dext=${ext} + -DExternalData_ACTION=fetch + -DExternalData_CONFIG=${config} + -P ${_ExternalData_SELF} + # Update whenever the object hash changes. + MAIN_DEPENDENCY "${name}${ext}" + ) + endif() list(APPEND files "${file}${stamp}") endif() endforeach() diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake index 9f96fe6..b501599 100644 --- a/Modules/FindMatlab.cmake +++ b/Modules/FindMatlab.cmake @@ -1030,13 +1030,17 @@ function(_Matlab_get_version_from_root matlab_root matlab_known_version matlab_f set(matlab_list_of_all_versions) matlab_get_version_from_matlab_run("${Matlab_PROG_VERSION_STRING_AUTO_DETECT}" matlab_list_of_all_versions) - list(GET matlab_list_of_all_versions 0 _matlab_version_tmp) + list(LENGTH matlab_list_of_all_versions list_of_all_versions_length) + if(${list_of_all_versions_length} GREATER 0) + list(GET matlab_list_of_all_versions 0 _matlab_version_tmp) + else() + set(_matlab_version_tmp "") + endif() # set the version into the cache set(Matlab_VERSION_STRING_INTERNAL ${_matlab_version_tmp} CACHE INTERNAL "Matlab version (automatically determined)" FORCE) # warning, just in case several versions found (should not happen) - list(LENGTH matlab_list_of_all_versions list_of_all_versions_length) if((${list_of_all_versions_length} GREATER 1) AND MATLAB_FIND_DEBUG) message(WARNING "[MATLAB] Found several versions, taking the first one (versions found ${matlab_list_of_all_versions})") endif() diff --git a/Modules/GNUInstallDirs.cmake b/Modules/GNUInstallDirs.cmake index b42084e..0c80b8a 100644 --- a/Modules/GNUInstallDirs.cmake +++ b/Modules/GNUInstallDirs.cmake @@ -99,6 +99,23 @@ # `Filesystem Hierarchy Standard`_. # # .. _`Filesystem Hierarchy Standard`: https://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html +# +# Macros +# ^^^^^^ +# +# .. command:: GNUInstallDirs_get_absolute_install_dir +# +# :: +# +# GNUInstallDirs_get_absolute_install_dir(absvar var) +# +# Set the given variable ``absvar`` to the absolute path contained +# within the variable ``var``. This is to allow the computation of an +# absolute path, accounting for all the special cases documented +# above. While this macro is used to compute the various +# ``CMAKE_INSTALL_FULL_<dir>`` variables, it is exposed publicly to +# allow users who create additional path variables to also compute +# absolute paths where necessary, using the same logic. #============================================================================= # Copyright 2015 Alex Turbov <i.zaufi@gmail.com> @@ -300,55 +317,59 @@ mark_as_advanced( CMAKE_INSTALL_DOCDIR ) -# Result directories -# -foreach(dir - BINDIR - SBINDIR - LIBEXECDIR - SYSCONFDIR - SHAREDSTATEDIR - LOCALSTATEDIR - LIBDIR - INCLUDEDIR - OLDINCLUDEDIR - DATAROOTDIR - DATADIR - INFODIR - LOCALEDIR - MANDIR - DOCDIR - ) - if(NOT IS_ABSOLUTE "${CMAKE_INSTALL_${dir}}") +macro(GNUInstallDirs_get_absolute_install_dir absvar var) + if(NOT IS_ABSOLUTE "${${var}}") # Handle special cases: # - CMAKE_INSTALL_PREFIX == / # - CMAKE_INSTALL_PREFIX == /usr # - CMAKE_INSTALL_PREFIX == /opt/... if("${CMAKE_INSTALL_PREFIX}" STREQUAL "/") if("${dir}" STREQUAL "SYSCONFDIR" OR "${dir}" STREQUAL "LOCALSTATEDIR") - set(CMAKE_INSTALL_FULL_${dir} "/${CMAKE_INSTALL_${dir}}") + set(${absvar} "/${${var}}") else() - if (NOT "${CMAKE_INSTALL_${dir}}" MATCHES "^usr/") - set(CMAKE_INSTALL_${dir} "usr/${CMAKE_INSTALL_${dir}}") + if (NOT "${${var}}" MATCHES "^usr/") + set(${var} "usr/${${var}}") endif() - set(CMAKE_INSTALL_FULL_${dir} "/${CMAKE_INSTALL_${dir}}") + set(${absvar} "/${${var}}") endif() elseif("${CMAKE_INSTALL_PREFIX}" MATCHES "^/usr/?$") if("${dir}" STREQUAL "SYSCONFDIR" OR "${dir}" STREQUAL "LOCALSTATEDIR") - set(CMAKE_INSTALL_FULL_${dir} "/${CMAKE_INSTALL_${dir}}") + set(${absvar} "/${${var}}") else() - set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_${dir}}") + set(${absvar} "${CMAKE_INSTALL_PREFIX}/${${var}}") endif() elseif("${CMAKE_INSTALL_PREFIX}" MATCHES "^/opt/.*") if("${dir}" STREQUAL "SYSCONFDIR" OR "${dir}" STREQUAL "LOCALSTATEDIR") - set(CMAKE_INSTALL_FULL_${dir} "/${CMAKE_INSTALL_${dir}}${CMAKE_INSTALL_PREFIX}") + set(${absvar} "/${${var}}${CMAKE_INSTALL_PREFIX}") else() - set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_${dir}}") + set(${absvar} "${CMAKE_INSTALL_PREFIX}/${${var}}") endif() else() - set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_${dir}}") + set(${absvar} "${CMAKE_INSTALL_PREFIX}/${${var}}") endif() else() - set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_${dir}}") + set(${absvar} "${${var}}") endif() +endmacro() + +# Result directories +# +foreach(dir + BINDIR + SBINDIR + LIBEXECDIR + SYSCONFDIR + SHAREDSTATEDIR + LOCALSTATEDIR + LIBDIR + INCLUDEDIR + OLDINCLUDEDIR + DATAROOTDIR + DATADIR + INFODIR + LOCALEDIR + MANDIR + DOCDIR + ) + GNUInstallDirs_get_absolute_install_dir(CMAKE_INSTALL_FULL_${dir} CMAKE_INSTALL_${dir}) endforeach() |