diff options
Diffstat (limited to 'Modules')
24 files changed, 470 insertions, 293 deletions
diff --git a/Modules/CMakeCUDACompiler.cmake.in b/Modules/CMakeCUDACompiler.cmake.in index 7e8efa7..158d12b 100644 --- a/Modules/CMakeCUDACompiler.cmake.in +++ b/Modules/CMakeCUDACompiler.cmake.in @@ -13,7 +13,7 @@ set(CMAKE_CUDA_HOST_COMPILER_ENV_VAR "CUDAHOSTCXX") set(CMAKE_CUDA_COMPILER_ID_RUN 1) set(CMAKE_CUDA_SOURCE_FILE_EXTENSIONS cu) -set(CMAKE_CUDA_LINKER_PREFERENCE 10) +set(CMAKE_CUDA_LINKER_PREFERENCE 15) set(CMAKE_CUDA_LINKER_PREFERENCE_PROPAGATES 1) set(CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES "@CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES@") diff --git a/Modules/CPack.STGZ_Header.sh.in b/Modules/CPack.STGZ_Header.sh.in index dee576f..c615851 100755 --- a/Modules/CPack.STGZ_Header.sh.in +++ b/Modules/CPack.STGZ_Header.sh.in @@ -130,7 +130,10 @@ echo "" use_new_tail_syntax="-n" tail $use_new_tail_syntax +1 "$0" > /dev/null 2> /dev/null || use_new_tail_syntax="" -tail $use_new_tail_syntax +###CPACK_HEADER_LENGTH### "$0" | gunzip | (cd "${toplevel}" && tar xf -) || cpack_echo_exit "Problem unpacking the @CPACK_PACKAGE_FILE_NAME@" +extractor="pax -r" +command -v pax > /dev/null 2> /dev/null || extractor="tar xf -" + +tail $use_new_tail_syntax +###CPACK_HEADER_LENGTH### "$0" | gunzip | (cd "${toplevel}" && ${extractor}) || cpack_echo_exit "Problem unpacking the @CPACK_PACKAGE_FILE_NAME@" echo "Unpacking finished successfully" diff --git a/Modules/CPackIFW.cmake b/Modules/CPackIFW.cmake index ae595fb..deb724c 100644 --- a/Modules/CPackIFW.cmake +++ b/Modules/CPackIFW.cmake @@ -227,18 +227,21 @@ # :: # # cpack_ifw_configure_component(<compname> [COMMON] [ESSENTIAL] [VIRTUAL] -# [FORCED_INSTALLATION] +# [FORCED_INSTALLATION] [REQUIRES_ADMIN_RIGHTS] # [NAME <name>] # [DISPLAY_NAME <display_name>] # [DESCRIPTION <description>] +# [UPDATE_TEXT <update_text>] # [VERSION <version>] # [RELEASE_DATE <release_date>] # [SCRIPT <script>] -# [PRIORITY <priority>] -# [DEPENDS <com_id> ...] +# [PRIORITY|SORTING_PRIORITY <sorting_priority>] # Note: PRIORITY is deprecated +# [DEPENDS|DEPENDENCIES <com_id> ...] +# [AUTO_DEPEND_ON <comp_id> ...] # [LICENSES <display_name> <file_path> ...] # [DEFAULT <value>] -# [USER_INTERFACES <file_path> <file_path> ...]) +# [USER_INTERFACES <file_path> <file_path> ...] +# [TRANSLATIONS <file_path> <file_path> ...]) # # This command should be called after :command:`cpack_add_component` command. # @@ -260,6 +263,9 @@ # It is a equivalent of the ``REQUARED`` option from the # :command:`cpack_add_component` command. # +# ``REQUIRES_ADMIN_RIGHTS`` +# set it if the component needs to be installed with elevated permissions. +# # ``NAME`` # is used to create domain-like identification for this component. # By default used origin component name. @@ -272,6 +278,10 @@ # set to rewrite original description configured by # :command:`cpack_add_component` command. # +# ``UPDATE_TEXT`` +# will be added to the component description if this is an update to +# the component. +# # ``VERSION`` # is version of component. # By default used :variable:`CPACK_PACKAGE_VERSION`. @@ -283,11 +293,18 @@ # is a relative or absolute path to operations script # for this component. # -# ``PRIORITY`` +# ``PRIORITY`` | ``SORTING_PRIORITY`` # is priority of the component in the tree. +# The ``PRIORITY`` option is deprecated and will be removed in a future +# version of CMake. Please use ``SORTING_PRIORITY`` option instead. +# +# ``DEPENDS`` | ``DEPENDENCIES`` +# list of dependency component or component group identifiers in +# QtIFW_ style. # -# ``DEPENDS`` -# list of dependency component identifiers in QtIFW_ style. +# ``AUTO_DEPEND_ON`` +# list of identifiers of component or component group in QtIFW_ style +# that this component has an automatic dependency on. # # ``LICENSES`` # pair of <display_name> and <file_path> of license text for this @@ -300,7 +317,10 @@ # as a value of the ``SCRIPT`` option). # # ``USER_INTERFACES`` -# a list of <file_path> representing pages to load +# is a list of <file_path> ('.ui' files) representing pages to load. +# +# ``TRANSLATIONS`` +# is a list of <file_path> ('.qm' files) representing translations to load. # # # .. command:: cpack_ifw_configure_component_group @@ -310,17 +330,21 @@ # :: # # cpack_ifw_configure_component_group(<groupname> [VIRTUAL] -# [FORCED_INSTALLATION] +# [FORCED_INSTALLATION] [REQUIRES_ADMIN_RIGHTS] # [NAME <name>] # [DISPLAY_NAME <display_name>] # [DESCRIPTION <description>] +# [UPDATE_TEXT <update_text>] # [VERSION <version>] # [RELEASE_DATE <release_date>] # [SCRIPT <script>] -# [PRIORITY <priority>] +# [PRIORITY|SORTING_PRIORITY <sorting_priority>] # Note: PRIORITY is deprecated +# [DEPENDS|DEPENDENCIES <com_id> ...] +# [AUTO_DEPEND_ON <comp_id> ...] # [LICENSES <display_name> <file_path> ...] # [DEFAULT <value>] -# [USER_INTERFACES <file_path> <file_path> ...]) +# [USER_INTERFACES <file_path> <file_path> ...] +# [TRANSLATIONS <file_path> <file_path> ...]) # # This command should be called after :command:`cpack_add_component_group` # command. @@ -332,6 +356,10 @@ # ``FORCED_INSTALLATION`` # if set, then the group must always be installed. # +# ``REQUIRES_ADMIN_RIGHTS`` +# set it if the component group needs to be installed with elevated +# permissions. +# # ``NAME`` # is used to create domain-like identification for this component group. # By default used origin component group name. @@ -344,6 +372,10 @@ # set to rewrite original description configured by # :command:`cpack_add_component_group` command. # +# ``UPDATE_TEXT`` +# will be added to the component group description if this is an update to +# the component group. +# # ``VERSION`` # is version of component group. # By default used :variable:`CPACK_PACKAGE_VERSION`. @@ -355,8 +387,18 @@ # is a relative or absolute path to operations script # for this component group. # -# ``PRIORITY`` +# ``PRIORITY`` | ``SORTING_PRIORITY`` # is priority of the component group in the tree. +# The ``PRIORITY`` option is deprecated and will be removed in a future +# version of CMake. Please use ``SORTING_PRIORITY`` option instead. +# +# ``DEPENDS`` | ``DEPENDENCIES`` +# list of dependency component or component group identifiers in +# QtIFW_ style. +# +# ``AUTO_DEPEND_ON`` +# list of identifiers of component or component group in QtIFW_ style +# that this component group has an automatic dependency on. # # ``LICENSES`` # pair of <display_name> and <file_path> of license text for this @@ -370,7 +412,10 @@ # the script as a value of the ``SCRIPT`` option). # # ``USER_INTERFACES`` -# a list of <file_path> representing pages to load +# is a list of <file_path> ('.ui' files) representing pages to load. +# +# ``TRANSLATIONS`` +# is a list of <file_path> ('.qm' files) representing translations to load. # # # .. command:: cpack_ifw_add_repository @@ -711,14 +756,15 @@ macro(cpack_ifw_configure_component compname) string(TOUPPER ${compname} _CPACK_IFWCOMP_UNAME) - set(_IFW_OPT COMMON ESSENTIAL VIRTUAL FORCED_INSTALLATION) - set(_IFW_ARGS NAME DISPLAY_NAME DESCRIPTION VERSION RELEASE_DATE SCRIPT PRIORITY DEFAULT) - set(_IFW_MULTI_ARGS DEPENDS LICENSES USER_INTERFACES) + set(_IFW_OPT COMMON ESSENTIAL VIRTUAL FORCED_INSTALLATION REQUIRES_ADMIN_RIGHTS) + set(_IFW_ARGS NAME DISPLAY_NAME DESCRIPTION VERSION RELEASE_DATE SCRIPT PRIORITY SORTING_PRIORITY UPDATE_TEXT DEFAULT) + set(_IFW_MULTI_ARGS DEPENDS DEPENDENCIES AUTO_DEPEND_ON LICENSES USER_INTERFACES TRANSLATIONS) cmake_parse_arguments(CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME} "${_IFW_OPT}" "${_IFW_ARGS}" "${_IFW_MULTI_ARGS}" ${ARGN}) _cpack_ifw_resolve_script(CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME}_SCRIPT) _cpack_ifw_resolve_lisenses(CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME}_LICENSES) _cpack_ifw_resolve_file_list(CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME}_USER_INTERFACES) + _cpack_ifw_resolve_file_list(CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME}_TRANSLATIONS) set(_CPACK_IFWCOMP_STR "\n# Configuration for IFW component \"${compname}\"\n") @@ -751,14 +797,15 @@ macro(cpack_ifw_configure_component_group grpname) string(TOUPPER ${grpname} _CPACK_IFWGRP_UNAME) - set(_IFW_OPT VIRTUAL FORCED_INSTALLATION) - set(_IFW_ARGS NAME DISPLAY_NAME DESCRIPTION VERSION RELEASE_DATE SCRIPT PRIORITY DEFAULT) - set(_IFW_MULTI_ARGS LICENSES USER_INTERFACES) + set(_IFW_OPT VIRTUAL FORCED_INSTALLATION REQUIRES_ADMIN_RIGHTS) + set(_IFW_ARGS NAME DISPLAY_NAME DESCRIPTION VERSION RELEASE_DATE SCRIPT PRIORITY SORTING_PRIORITY UPDATE_TEXT DEFAULT) + set(_IFW_MULTI_ARGS DEPENDS DEPENDENCIES AUTO_DEPEND_ON LICENSES USER_INTERFACES TRANSLATIONS) cmake_parse_arguments(CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME} "${_IFW_OPT}" "${_IFW_ARGS}" "${_IFW_MULTI_ARGS}" ${ARGN}) _cpack_ifw_resolve_script(CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME}_SCRIPT) _cpack_ifw_resolve_lisenses(CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME}_LICENSES) _cpack_ifw_resolve_file_list(CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME}_USER_INTERFACES) + _cpack_ifw_resolve_file_list(CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME}_TRANSLATIONS) set(_CPACK_IFWGRP_STR "\n# Configuration for IFW component group \"${grpname}\"\n") diff --git a/Modules/Compiler/GNU-DetermineCompiler.cmake b/Modules/Compiler/GNU-C-DetermineCompiler.cmake index 6ddc566..6ddc566 100644 --- a/Modules/Compiler/GNU-DetermineCompiler.cmake +++ b/Modules/Compiler/GNU-C-DetermineCompiler.cmake diff --git a/Modules/Compiler/GNU-C-FeatureTests.cmake b/Modules/Compiler/GNU-C-FeatureTests.cmake index b3fe33f..0ab5265 100644 --- a/Modules/Compiler/GNU-C-FeatureTests.cmake +++ b/Modules/Compiler/GNU-C-FeatureTests.cmake @@ -1,5 +1,5 @@ -set(_cmake_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 404") +set(_cmake_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 304") # GNU 4.7 correctly sets __STDC_VERSION__ to 201112L, but GNU 4.6 sets it # to 201000L. As the former is strictly greater than the latter, test only @@ -8,10 +8,10 @@ set(_cmake_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 404") # to the distinction between __cplusplus and __GXX_EXPERIMENTAL_CXX0X__ tests. set(GNU46_C11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201000L") set(_cmake_feature_test_c_static_assert "${GNU46_C11}") -# Since 4.4 at least: -set(GNU44_C99 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L") -set(_cmake_feature_test_c_restrict "${GNU44_C99}") -set(_cmake_feature_test_c_variadic_macros "${GNU44_C99}") +# Since 3.4 at least: +set(GNU34_C99 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 304 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L") +set(_cmake_feature_test_c_restrict "${GNU34_C99}") +set(_cmake_feature_test_c_variadic_macros "${GNU34_C99}") set(GNU_C90 "${_cmake_oldestSupported}") set(_cmake_feature_test_c_function_prototypes "${GNU_C90}") diff --git a/Modules/Compiler/GNU-C.cmake b/Modules/Compiler/GNU-C.cmake index 05c3bb2..3f02618 100644 --- a/Modules/Compiler/GNU-C.cmake +++ b/Modules/Compiler/GNU-C.cmake @@ -4,12 +4,12 @@ __compiler_gnu(C) if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.5) set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90") -elseif (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4) +elseif (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4) set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c89") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu89") endif() -if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4) +if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4) set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99") set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99") endif() @@ -22,7 +22,7 @@ elseif (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6) set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu1x") endif() -if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4) +if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4) if (NOT CMAKE_C_COMPILER_FORCED) if (NOT CMAKE_C_STANDARD_COMPUTED_DEFAULT) message(FATAL_ERROR "CMAKE_C_STANDARD_COMPUTED_DEFAULT should be set for ${CMAKE_C_COMPILER_ID} (${CMAKE_C_COMPILER}) version ${CMAKE_C_COMPILER_VERSION}") @@ -38,10 +38,9 @@ if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4) endif() endif() - macro(cmake_record_c_compile_features) set(_result 0) - if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4) + if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4) if(_result EQUAL 0 AND CMAKE_C11_STANDARD_COMPILE_OPTION) _record_compiler_features_c(11) endif() diff --git a/Modules/Compiler/GNU-CXX-DetermineCompiler.cmake b/Modules/Compiler/GNU-CXX-DetermineCompiler.cmake new file mode 100644 index 0000000..c25b147 --- /dev/null +++ b/Modules/Compiler/GNU-CXX-DetermineCompiler.cmake @@ -0,0 +1,15 @@ + +set(_compiler_id_pp_test "defined(__GNUC__) || defined(__GNUG__)") + +set(_compiler_id_version_compute " +# if defined(__GNUC__) +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__GNUC__) +# else +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__GNUG__) +# endif +# if defined(__GNUC_MINOR__) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__GNUC_MINOR__) +# endif +# if defined(__GNUC_PATCHLEVEL__) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__GNUC_PATCHLEVEL__) +# endif") diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake index b04ea11..c007c98 100644 --- a/Modules/Compiler/GNU-CXX.cmake +++ b/Modules/Compiler/GNU-CXX.cmake @@ -6,7 +6,7 @@ if (WIN32) set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fno-keep-inline-dllexport") endif() else() - if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.2) + if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.0) set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") endif() endif() diff --git a/Modules/Compiler/Intel-C.cmake b/Modules/Compiler/Intel-C.cmake index 6408392..9c67fbd 100644 --- a/Modules/Compiler/Intel-C.cmake +++ b/Modules/Compiler/Intel-C.cmake @@ -10,14 +10,17 @@ set(CMAKE_DEPFILE_FLAGS_C "-MD -MT <OBJECT> -MF <DEPFILE>") if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC") set(_std -Qstd) set(_ext c) + if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 16.0.0) + set(CMAKE_C11_STANDARD_COMPILE_OPTION "-Qstd=c11") + set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-Qstd=c11") + endif() else() set(_std -std) set(_ext gnu) -endif() - -if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 15.0.0) - set(CMAKE_C11_STANDARD_COMPILE_OPTION "${_std}=c11") - set(CMAKE_C11_EXTENSION_COMPILE_OPTION "${_std}=${_ext}11") + if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 15.0.0) + set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") + set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") + endif() endif() if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 12.0) diff --git a/Modules/CompilerId/VS-10.csproj.in b/Modules/CompilerId/VS-10.csproj.in index 833dca7..ed5e847 100644 --- a/Modules/CompilerId/VS-10.csproj.in +++ b/Modules/CompilerId/VS-10.csproj.in @@ -47,9 +47,9 @@ </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <PropertyGroup> - <PostBuildEvent>cd /D "$(MSBuildToolsPath)" -if not %errorlevel%==0 exit -1 -if not exist @id_cl@ exit -2 -%40echo CMAKE_@id_lang@_COMPILER=$(MSBuildToolsPath)\@id_cl@</PostBuildEvent> + <PostBuildEvent>if not "$(RoslynTargetsPath)"=="" if exist "$(RoslynTargetsPath)\@id_cl@" set _CSC=$(RoslynTargetsPath) +if exist "$(MSBuildToolsPath)\@id_cl@" set _CSC=$(MSBuildToolsPath) +if "%_CSC%"=="" exit -1 +%40echo CMAKE_@id_lang@_COMPILER=%_CSC%\@id_cl@</PostBuildEvent> </PropertyGroup> </Project> diff --git a/Modules/FeatureSummary.cmake b/Modules/FeatureSummary.cmake index 78d9df3..8910be7 100644 --- a/Modules/FeatureSummary.cmake +++ b/Modules/FeatureSummary.cmake @@ -14,30 +14,93 @@ packages and/or feature for a build tree such as:: LibXml2 (required version >= 2.4), XML processing lib, <http://xmlsoft.org> * Enables HTML-import in MyWordProcessor * Enables odt-export in MyWordProcessor - PNG , A PNG image library. , <http://www.libpng.org/pub/png/> + PNG, A PNG image library., <http://www.libpng.org/pub/png/> * Enables saving screenshots -- The following OPTIONAL packages have not been found: - Lua51 , The Lua scripting language. , <http://www.lua.org> + Lua51, The Lua scripting language., <http://www.lua.org> * Enables macros in MyWordProcessor - Foo , Foo provides cool stuff. + Foo, Foo provides cool stuff. + +Global Properties +^^^^^^^^^^^^^^^^^ + +.. variable:: FeatureSummary_PKG_TYPES + +The global property :variable:`FeatureSummary_PKG_TYPES` defines the type of +packages used by `FeatureSummary`. + +The order in this list is important, the first package type in the list is the +least important, the last is the most important. the of a package can only be +changed to higher types. + +The default package types are , ``RUNTIME``, ``OPTIONAL``, ``RECOMMENDED`` and +``REQUIRED``, and their importance is +``RUNTIME < OPTIONAL < RECOMMENDED < REQUIRED``. + + +.. variable:: FeatureSummary_REQUIRED_PKG_TYPES + +The global property :variable:`FeatureSummary_REQUIRED_PKG_TYPES` defines which +package types are required. + +If one or more package in this categories has not been found, CMake will abort +when calling :cmd;`feature_summary` with the +'FATAL_ON_MISSING_REQUIRED_PACKAGES' option enabled. + +The default value for this global property is ``REQUIRED``. + + +.. variable:: FeatureSummary_DEFAULT_PKG_TYPE + +The global property :variable:`FeatureSummary_DEFAULT_PKG_TYPE` defines which +package type is the default one. +When calling :cmd;`feature_summary`, if the user did not set the package type +explicitly, the package will be assigned to this category. + +This value must be one of the types defined in the +:variable:`FeatureSummary_PKG_TYPES` global property unless the package type +is set for all the packages. + +The default value for this global property is ``OPTIONAL``. + +#]=======================================================================] + +get_property(_fsPkgTypeIsSet GLOBAL PROPERTY FeatureSummary_PKG_TYPES SET) +if(NOT _fsPkgTypeIsSet) + set_property(GLOBAL PROPERTY FeatureSummary_PKG_TYPES RUNTIME OPTIONAL RECOMMENDED REQUIRED) +endif() + +get_property(_fsReqPkgTypesIsSet GLOBAL PROPERTY FeatureSummary_REQUIRED_PKG_TYPES SET) +if(NOT _fsReqPkgTypesIsSet) + set_property(GLOBAL PROPERTY FeatureSummary_REQUIRED_PKG_TYPES REQUIRED) +endif() + +get_property(_fsDefaultPkgTypeIsSet GLOBAL PROPERTY FeatureSummary_DEFAULT_PKG_TYPE SET) +if(NOT _fsDefaultPkgTypeIsSet) + set_property(GLOBAL PROPERTY FeatureSummary_DEFAULT_PKG_TYPE OPTIONAL) +endif() + +#[=======================================================================[.rst: Functions ^^^^^^^^^ #]=======================================================================] +include(CMakeParseArguments) + function(_FS_GET_FEATURE_SUMMARY _property _var _includeQuiet) + get_property(_fsPkgTypes GLOBAL PROPERTY FeatureSummary_PKG_TYPES) + get_property(_fsDefaultPkgType GLOBAL PROPERTY FeatureSummary_DEFAULT_PKG_TYPE) + set(_type "ANY") - if("${_property}" MATCHES "REQUIRED_") - set(_type "REQUIRED") - elseif("${_property}" MATCHES "RECOMMENDED_") - set(_type "RECOMMENDED") - elseif("${_property}" MATCHES "RUNTIME_") - set(_type "RUNTIME") - elseif("${_property}" MATCHES "OPTIONAL_") - set(_type "OPTIONAL") - endif() + foreach(_fsPkgType ${_fsPkgTypes}) + if("${_property}" MATCHES "${_fsPkgType}_PACKAGES_(NOT_)?FOUND") + set(_type "${_fsPkgType}") + break() + endif() + endforeach() if("${_property}" MATCHES "PACKAGES_FOUND") set(_property "PACKAGES_FOUND") @@ -57,15 +120,30 @@ function(_FS_GET_FEATURE_SUMMARY _property _var _includeQuiet) # does this package belong to the type we currently want to list ? get_property(_currentType GLOBAL PROPERTY _CMAKE_${_currentFeature}_TYPE) if(NOT _currentType) - set(_currentType OPTIONAL) + list(FIND _fsPkgTypes "${_fsDefaultPkgType}" _defaultInPkgTypes) + if("${_defaultInPkgTypes}" STREQUAL "-1") + string(REGEX REPLACE ";([^;]+)$" " and \\1" _fsPkgTypes_msg "${_fsPkgTypes}") + string(REPLACE ";" ", " _fsPkgTypes_msg "${_fsPkgTypes_msg}") + message(FATAL_ERROR "Bad package property type ${_fsDefaultPkgType} used in global property FeatureSummary_DEFAULT_PKG_TYPE. " + "Valid types are ${_fsPkgTypes_msg}. " + "Either update FeatureSummary_DEFAULT_PKG_TYPE or add ${_fsDefaultPkgType} to the FeatureSummary_PKG_TYPES global property.") + endif() + set(_currentType ${_fsDefaultPkgType}) endif() if("${_type}" STREQUAL ANY OR "${_type}" STREQUAL "${_currentType}") - # check whether the current feature/package should be in the output depending on whether it was QUIET or not set(includeThisOne TRUE) + set(_required FALSE) # skip QUIET packages, except if they are REQUIRED or INCLUDE_QUIET_PACKAGES has been set - if((NOT "${_currentType}" STREQUAL "REQUIRED") AND NOT _includeQuiet) + get_property(_fsReqPkgTypes GLOBAL PROPERTY FeatureSummary_REQUIRED_PKG_TYPES) + foreach(_fsReqPkgType ${_fsReqPkgTypes}) + if("${_currentType}" STREQUAL "${_fsReqPkgType}") + set(_required TRUE) + break() + endif() + endforeach() + if(NOT _required AND NOT _includeQuiet) get_property(_isQuiet GLOBAL PROPERTY _CMAKE_${_currentFeature}_QUIET) if(_isQuiet) set(includeThisOne FALSE) @@ -87,11 +165,11 @@ function(_FS_GET_FEATURE_SUMMARY _property _var _includeQuiet) endif() get_property(_info GLOBAL PROPERTY _CMAKE_${_currentFeature}_DESCRIPTION) if(_info) - string(APPEND _currentFeatureText " , ${_info}") + string(APPEND _currentFeatureText ", ${_info}") endif() get_property(_info GLOBAL PROPERTY _CMAKE_${_currentFeature}_URL) if(_info) - string(APPEND _currentFeatureText " , <${_info}>") + string(APPEND _currentFeatureText ", <${_info}>") endif() get_property(_info GLOBAL PROPERTY _CMAKE_${_currentFeature}_PURPOSE) @@ -119,6 +197,7 @@ endfunction() [INCLUDE_QUIET_PACKAGES] [FATAL_ON_MISSING_REQUIRED_PACKAGES] [DESCRIPTION "Found packages:"] + [QUIET_ON_EMPTY] WHAT (ALL | PACKAGES_FOUND | PACKAGES_NOT_FOUND | ENABLED_FEATURES | DISABLED_FEATURES) ) @@ -143,22 +222,15 @@ endfunction() the list of all packages which have been found ``PACKAGES_NOT_FOUND`` the list of all packages which have not been found - ``OPTIONAL_PACKAGES_FOUND`` - only those packages which have been found which have the type OPTIONAL - ``OPTIONAL_PACKAGES_NOT_FOUND`` - only those packages which have not been found which have the type OPTIONAL - ``RECOMMENDED_PACKAGES_FOUND`` - only those packages which have been found which have the type RECOMMENDED - ``RECOMMENDED_PACKAGES_NOT_FOUND`` - only those packages which have not been found which have the type RECOMMENDED - ``REQUIRED_PACKAGES_FOUND`` - only those packages which have been found which have the type REQUIRED - ``REQUIRED_PACKAGES_NOT_FOUND`` - only those packages which have not been found which have the type REQUIRED - ``RUNTIME_PACKAGES_FOUND`` - only those packages which have been found which have the type RUNTIME - ``RUNTIME_PACKAGES_NOT_FOUND`` - only those packages which have not been found which have the type RUNTIME + + For each package type ``<TYPE>`` defined by the + :variable:`FeatureSummary_PKG_TYPES` global property, the following + information can also be used: + + ``<TYPE>_PACKAGES_FOUND`` + only those packages which have been found which have the type <TYPE> + ``<TYPE>_PACKAGES_NOT_FOUND`` + only those packages which have not been found which have the type <TYPE> With the exception of the ``ALL`` value, these values can be combined in order to customize the output. For example: @@ -177,7 +249,20 @@ endfunction() packages which have been searched with ``find_package(... QUIET)`` will also be listed. By default they are skipped. If ``FATAL_ON_MISSING_REQUIRED_PACKAGES`` is given, CMake will abort if a - package which is marked as ``REQUIRED`` has not been found. + package which is marked as one of the package types listed in the + :variable:`FeatureSummary_REQUIRED_PKG_TYPES` global property has not been + found. + The default value for the :variable:`FeatureSummary_REQUIRED_PKG_TYPES` global + property is ``REQUIRED``. + + The :variable:`FeatureSummary_DEFAULT_PKG_TYPE` global property can be + modified to change the default package type assigned when not explicitly + assigned by the user. + + If the ``QUIET_ON_EMPTY`` option is used, if only one type of package was + requested, and no packages belonging to that category were found, then no + output (including the ``DESCRIPTION``) is printed or added to the ``VAR`` + variable. Example 1, append everything to a file: @@ -198,11 +283,28 @@ endfunction() DESCRIPTION "Enabled Features:" VAR enabledFeaturesText) message(STATUS "${enabledFeaturesText}") + + Example 3, change default package types and print only the categories that + are not empty: + + .. code-block:: cmake + + include(FeatureSummary) + set_property(GLOBAL APPEND PROPERTY FeatureSummary_PKG_TYPES BUILD) + find_package(FOO) + set_package_properties(FOO PROPERTIES TYPE BUILD) + feature_summary(WHAT BUILD_PACKAGES_FOUND + Description "Build tools found:" + QUIET_ON_EMPTY) + feature_summary(WHAT BUILD_PACKAGES_NOT_FOUND + Description "Build tools not found:" + QUIET_ON_EMPTY) + #]=======================================================================] function(FEATURE_SUMMARY) # CMAKE_PARSE_ARGUMENTS(<prefix> <options> <one_value_keywords> <multi_value_keywords> args...) - set(options APPEND INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) + set(options APPEND INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES QUIET_ON_EMPTY) set(oneValueArgs FILENAME VAR DESCRIPTION) set(multiValueArgs WHAT) @@ -219,40 +321,42 @@ function(FEATURE_SUMMARY) set(validWhatParts "ENABLED_FEATURES" "DISABLED_FEATURES" "PACKAGES_FOUND" - "PACKAGES_NOT_FOUND" - "OPTIONAL_PACKAGES_FOUND" - "OPTIONAL_PACKAGES_NOT_FOUND" - "RECOMMENDED_PACKAGES_FOUND" - "RECOMMENDED_PACKAGES_NOT_FOUND" - "REQUIRED_PACKAGES_FOUND" - "REQUIRED_PACKAGES_NOT_FOUND" - "RUNTIME_PACKAGES_FOUND" - "RUNTIME_PACKAGES_NOT_FOUND") + "PACKAGES_NOT_FOUND") + + get_property(_fsPkgTypes GLOBAL PROPERTY FeatureSummary_PKG_TYPES) + get_property(_fsReqPkgTypes GLOBAL PROPERTY FeatureSummary_REQUIRED_PKG_TYPES) + foreach(_fsPkgType ${_fsPkgTypes}) + list(APPEND validWhatParts "${_fsPkgType}_PACKAGES_FOUND" + "${_fsPkgType}_PACKAGES_NOT_FOUND") + endforeach() list(FIND validWhatParts "${_FS_WHAT}" indexInList) if(NOT "${indexInList}" STREQUAL "-1") _FS_GET_FEATURE_SUMMARY( ${_FS_WHAT} _featureSummary ${_FS_INCLUDE_QUIET_PACKAGES} ) - set(_fullText "${_FS_DESCRIPTION}${_featureSummary}\n") - if (("${_FS_WHAT}" STREQUAL "REQUIRED_PACKAGES_NOT_FOUND") AND _featureSummary) - set(requiredPackagesNotFound TRUE) + if(_featureSummary OR NOT _FS_QUIET_ON_EMPTY) + set(_fullText "${_FS_DESCRIPTION}${_featureSummary}\n") + endif() + + if(_featureSummary) + foreach(_fsReqPkgType ${_fsReqPkgTypes}) + if("${_FS_WHAT}" STREQUAL "${_fsReqPkgType}_PACKAGES_NOT_FOUND") + set(requiredPackagesNotFound TRUE) + break() + endif() + endforeach() endif() else() if("${_FS_WHAT}" STREQUAL "ALL") - set(allWhatParts "ENABLED_FEATURES" - "RUNTIME_PACKAGES_FOUND" - "OPTIONAL_PACKAGES_FOUND" - "RECOMMENDED_PACKAGES_FOUND" - "REQUIRED_PACKAGES_FOUND" - - "DISABLED_FEATURES" - "RUNTIME_PACKAGES_NOT_FOUND" - "OPTIONAL_PACKAGES_NOT_FOUND" - "RECOMMENDED_PACKAGES_NOT_FOUND" - "REQUIRED_PACKAGES_NOT_FOUND" - ) - + set(allWhatParts "ENABLED_FEATURES") + foreach(_fsPkgType ${_fsPkgTypes}) + list(APPEND allWhatParts "${_fsPkgType}_PACKAGES_FOUND") + endforeach() + list(APPEND allWhatParts "DISABLED_FEATURES") + foreach(_fsPkgType ${_fsPkgTypes}) + list(APPEND allWhatParts "${_fsPkgType}_PACKAGES_NOT_FOUND") + endforeach() else() set(allWhatParts) foreach(part ${_FS_WHAT}) @@ -273,45 +377,49 @@ function(FEATURE_SUMMARY) set(title_DISABLED_FEATURES "The following features have been disabled:") set(title_PACKAGES_FOUND "The following packages have been found:") set(title_PACKAGES_NOT_FOUND "The following packages have not been found:") - set(title_OPTIONAL_PACKAGES_FOUND "The following OPTIONAL packages have been found:") - set(title_OPTIONAL_PACKAGES_NOT_FOUND "The following OPTIONAL packages have not been found:") - set(title_RECOMMENDED_PACKAGES_FOUND "The following RECOMMENDED packages have been found:") - set(title_RECOMMENDED_PACKAGES_NOT_FOUND "The following RECOMMENDED packages have not been found:") - set(title_REQUIRED_PACKAGES_FOUND "The following REQUIRED packages have been found:") - set(title_REQUIRED_PACKAGES_NOT_FOUND "The following REQUIRED packages have not been found:") - set(title_RUNTIME_PACKAGES_FOUND "The following RUNTIME packages have been found:") - set(title_RUNTIME_PACKAGES_NOT_FOUND "The following RUNTIME packages have not been found:") + foreach(_fsPkgType ${_fsPkgTypes}) + set(title_${_fsPkgType}_PACKAGES_FOUND "The following ${_fsPkgType} packages have been found:") + set(title_${_fsPkgType}_PACKAGES_NOT_FOUND "The following ${_fsPkgType} packages have not been found:") + endforeach() set(_fullText "${_FS_DESCRIPTION}") foreach(part ${allWhatParts}) set(_tmp) _FS_GET_FEATURE_SUMMARY( ${part} _tmp ${_FS_INCLUDE_QUIET_PACKAGES}) if(_tmp) - string(APPEND _fullText "\n-- ${title_${part}}\n${_tmp}\n") - if("${part}" STREQUAL "REQUIRED_PACKAGES_NOT_FOUND") - set(requiredPackagesNotFound TRUE) + if(_fullText) + string(APPEND _fullText "\n-- ") endif() + string(APPEND _fullText "${title_${part}}\n${_tmp}\n") + foreach(_fsReqPkgType ${_fsReqPkgTypes}) + if("${part}" STREQUAL "${_fsReqPkgType}_PACKAGES_NOT_FOUND") + set(requiredPackagesNotFound TRUE) + break() + endif() + endforeach() endif() endforeach() endif() - if(_FS_FILENAME) - if(_FS_APPEND) - file(APPEND "${_FS_FILENAME}" "${_fullText}") + if(_fullText OR NOT _FS_QUIET_ON_EMPTY) + if(_FS_FILENAME) + if(_FS_APPEND) + file(APPEND "${_FS_FILENAME}" "${_fullText}") + else() + file(WRITE "${_FS_FILENAME}" "${_fullText}") + endif() + else() - file(WRITE "${_FS_FILENAME}" "${_fullText}") + if(NOT _FS_VAR) + message(STATUS "${_fullText}") + endif() endif() - else() - if(NOT _FS_VAR) - message(STATUS "${_fullText}") + if(_FS_VAR) + set(${_FS_VAR} "${_fullText}" PARENT_SCOPE) endif() endif() - if(_FS_VAR) - set(${_FS_VAR} "${_fullText}" PARENT_SCOPE) - endif() - if(requiredPackagesNotFound AND _FS_FATAL_ON_MISSING_REQUIRED_PACKAGES) message(FATAL_ERROR "feature_summary() Error: REQUIRED package(s) are missing, aborting CMake run.") endif() @@ -362,7 +470,8 @@ endfunction() TYPEs (``RUNTIME < OPTIONAL < RECOMMENDED < REQUIRED``), lower TYPEs are ignored. The ``TYPE`` property is project-specific, so it cannot be set by the Find-module, but must be set in the project. - + Type accepted can be changed by setting the + :variable:`FeatureSummary_PKG_TYPES` global property. ``PURPOSE <purpose>`` This describes which features this package enables in the @@ -435,25 +544,28 @@ function(SET_PACKAGE_PROPERTIES _name _props) set_property(GLOBAL APPEND PROPERTY _CMAKE_${_name}_PURPOSE "${_SPP_PURPOSE}" ) endif() - # handle the TYPE - if(NOT _SPP_TYPE) - set(_SPP_TYPE OPTIONAL) - endif() + get_property(_fsPkgTypes GLOBAL PROPERTY FeatureSummary_PKG_TYPES) + get_property(_fsDefaultPkgType GLOBAL PROPERTY FeatureSummary_DEFAULT_PKG_TYPE) - # List the supported types, according to their priority - set(validTypes "RUNTIME" "OPTIONAL" "RECOMMENDED" "REQUIRED" ) - list(FIND validTypes ${_SPP_TYPE} _typeIndexInList) - if("${_typeIndexInList}" STREQUAL "-1" ) - message(FATAL_ERROR "Bad package property type ${_SPP_TYPE} used in SET_PACKAGE_PROPERTIES(). " - "Valid types are OPTIONAL, RECOMMENDED, REQUIRED and RUNTIME." ) - endif() + # handle the TYPE + if(DEFINED _SPP_TYPE) + # Supported types are listed in FeatureSummary_PKG_TYPES according to their priority + get_property(_fsPkgTypes GLOBAL PROPERTY FeatureSummary_PKG_TYPES) + list(FIND _fsPkgTypes ${_SPP_TYPE} _typeIndexInList) + if("${_typeIndexInList}" STREQUAL "-1" ) + string(REGEX REPLACE ";([^;]+)$" " and \\1" _fsPkgTypes_msg "${_fsPkgTypes}") + string(REPLACE ";" ", " _fsPkgTypes_msg "${_fsPkgTypes_msg}") + message(FATAL_ERROR "Bad package property type ${_SPP_TYPE} used in SET_PACKAGE_PROPERTIES(). " + "Valid types are ${_fsPkgTypes_msg}." ) + endif() - get_property(_previousType GLOBAL PROPERTY _CMAKE_${_name}_TYPE) - list(FIND validTypes "${_previousType}" _prevTypeIndexInList) + get_property(_previousType GLOBAL PROPERTY _CMAKE_${_name}_TYPE) + list(FIND _fsPkgTypes "${_previousType}" _prevTypeIndexInList) - # make sure a previously set TYPE is not overridden with a lower new TYPE: - if("${_typeIndexInList}" GREATER "${_prevTypeIndexInList}") - set_property(GLOBAL PROPERTY _CMAKE_${_name}_TYPE "${_SPP_TYPE}" ) + # make sure a previously set TYPE is not overridden with a lower new TYPE: + if("${_typeIndexInList}" GREATER "${_prevTypeIndexInList}") + set_property(GLOBAL PROPERTY _CMAKE_${_name}_TYPE "${_SPP_TYPE}" ) + endif() endif() endfunction() @@ -466,7 +578,8 @@ endfunction() add_feature_info(<name> <enabled> <description>) Use this macro to add information about a feature with the given ``<name>``. - ``<enabled>`` contains whether this feature is enabled or not. + ``<enabled>`` contains whether this feature is enabled or not. It can be a + variable or a list of conditions. ``<description>`` is a text describing the feature. The information can be displayed using ``feature_summary()`` for ``ENABLED_FEATURES`` and ``DISABLED_FEATURES`` respectively. @@ -478,7 +591,16 @@ endfunction() option(WITH_FOO "Help for foo" ON) add_feature_info(Foo WITH_FOO "The Foo feature provides very cool stuff.") #]=======================================================================] -function(ADD_FEATURE_INFO _name _enabled _desc) +function(ADD_FEATURE_INFO _name _depends _desc) + set(_enabled 1) + foreach(_d ${_depends}) + string(REGEX REPLACE " +" ";" _d "${_d}") + if(${_d}) + else() + set(_enabled 0) + break() + endif() + endforeach() if (${_enabled}) set_property(GLOBAL APPEND PROPERTY ENABLED_FEATURES "${_name}") else () @@ -511,6 +633,7 @@ CMake versions: can be set are added automatically by the ``find_package()`` command. #]=======================================================================] function(SET_PACKAGE_INFO _name _desc) + message(DEPRECATION "SET_PACKAGE_INFO is deprecated. Use SET_PACKAGE_PROPERTIES instead.") unset(_url) unset(_purpose) if(ARGC GREATER 2) @@ -540,6 +663,7 @@ endfunction() set_package_info(<name> <description> <url>) #]=======================================================================] function(SET_FEATURE_INFO) + message(DEPRECATION "SET_FEATURE_INFO is deprecated. Use ADD_FEATURE_INFO instead.") SET_PACKAGE_INFO(${ARGN}) endfunction() @@ -557,6 +681,8 @@ endfunction() feature_summary(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:") #]=======================================================================] function(PRINT_ENABLED_FEATURES) + message(DEPRECATION "PRINT_ENABLED_FEATURES is deprecated. Use + feature_summary(WHAT ENABLED_FEATURES DESCRIPTION \"Enabled features:\")") FEATURE_SUMMARY(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:") endfunction() @@ -574,5 +700,7 @@ endfunction() feature_summary(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:") #]=======================================================================] function(PRINT_DISABLED_FEATURES) + message(DEPRECATION "PRINT_DISABLED_FEATURES is deprecated. Use + feature_summary(WHAT DISABLED_FEATURES DESCRIPTION \"Disabled features:\")") FEATURE_SUMMARY(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:") endfunction() diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 266d135..e795aad 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -1463,7 +1463,7 @@ if(NOT _Boost_THREAD_DEPENDENCY_LIBS EQUAL -1) endif() # If the user changed any of our control inputs flush previous results. -if(_Boost_CHANGE_LIBDIR OR _Boost_CHANGE_LIBNAME) +if(_Boost_CHANGE_LIBDIR_DEBUG OR _Boost_CHANGE_LIBDIR_RELEASE OR _Boost_CHANGE_LIBNAME) foreach(COMPONENT ${_Boost_COMPONENTS_SEARCHED}) string(TOUPPER ${COMPONENT} UPPERCOMPONENT) foreach(c DEBUG RELEASE) diff --git a/Modules/FindCUDA/select_compute_arch.cmake b/Modules/FindCUDA/select_compute_arch.cmake index 5ce71a9..a96a8ca 100644 --- a/Modules/FindCUDA/select_compute_arch.cmake +++ b/Modules/FindCUDA/select_compute_arch.cmake @@ -44,9 +44,10 @@ endif () # function(CUDA_DETECT_INSTALLED_GPUS OUT_VARIABLE) if(NOT CUDA_GPU_DETECT_OUTPUT) - set(cufile ${PROJECT_BINARY_DIR}/detect_cuda_archs.cu) + set(file ${PROJECT_BINARY_DIR}/detect_cuda_compute_capabilities.cpp) - file(WRITE ${cufile} "" + file(WRITE ${file} "" + "#include <cuda_runtime.h>\n" "#include <cstdio>\n" "int main()\n" "{\n" @@ -62,14 +63,15 @@ function(CUDA_DETECT_INSTALLED_GPUS OUT_VARIABLE) " return 0;\n" "}\n") - execute_process(COMMAND "${CUDA_NVCC_EXECUTABLE}" "--run" "${cufile}" - WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/CMakeFiles/" - RESULT_VARIABLE nvcc_res OUTPUT_VARIABLE nvcc_out - ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + try_run(run_result compile_result ${PROJECT_BINARY_DIR} ${file} + CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${CUDA_INCLUDE_DIRS}" + LINK_LIBRARIES ${CUDA_LIBRARIES} + RUN_OUTPUT_VARIABLE compute_capabilities) - if(nvcc_res EQUAL 0) - string(REPLACE "2.1" "2.1(2.0)" nvcc_out "${nvcc_out}") - set(CUDA_GPU_DETECT_OUTPUT ${nvcc_out} CACHE INTERNAL "Returned GPU architetures from detect_gpus tool" FORCE) + if(run_result EQUAL 0) + string(REPLACE "2.1" "2.1(2.0)" compute_capabilities "${compute_capabilities}") + set(CUDA_GPU_DETECT_OUTPUT ${compute_capabilities} + CACHE INTERNAL "Returned GPU architectures from detect_gpus tool" FORCE) endif() endif() diff --git a/Modules/FindGSL.cmake b/Modules/FindGSL.cmake index 446c3a8..76059b3 100644 --- a/Modules/FindGSL.cmake +++ b/Modules/FindGSL.cmake @@ -135,7 +135,7 @@ if( NOT GSL_VERSION ) # 2. If gsl-config is not available, try looking in gsl/gsl_version.h if( NOT GSL_VERSION AND EXISTS "${GSL_INCLUDE_DIRS}/gsl/gsl_version.h" ) file( STRINGS "${GSL_INCLUDE_DIRS}/gsl/gsl_version.h" gsl_version_h_contents REGEX "define GSL_VERSION" ) - string( REGEX REPLACE ".*([0-9].[0-9][0-9]).*" "\\1" GSL_VERSION ${gsl_version_h_contents} ) + string( REGEX REPLACE ".*([0-9]\\.[0-9][0-9]?).*" "\\1" GSL_VERSION ${gsl_version_h_contents} ) endif() # might also try scraping the directory name for a regex match "gsl-X.X" diff --git a/Modules/FindGTK2.cmake b/Modules/FindGTK2.cmake index e1b22b6..6747be5 100644 --- a/Modules/FindGTK2.cmake +++ b/Modules/FindGTK2.cmake @@ -529,52 +529,54 @@ function(_GTK2_ADD_TARGET _var) cmake_parse_arguments(_${_var} "" "" "GTK2_DEPENDS;GTK2_OPTIONAL_DEPENDS;OPTIONAL_INCLUDES" ${ARGN}) - if(GTK2_${_var}_FOUND AND NOT TARGET GTK2::${_basename}) - # Do not create the target if dependencies are missing - foreach(_dep ${_${_var}_GTK2_DEPENDS}) - if(NOT TARGET GTK2::${_dep}) - return() - endif() - endforeach() + if(GTK2_${_var}_FOUND) + if(NOT TARGET GTK2::${_basename}) + # Do not create the target if dependencies are missing + foreach(_dep ${_${_var}_GTK2_DEPENDS}) + if(NOT TARGET GTK2::${_dep}) + return() + endif() + endforeach() - add_library(GTK2::${_basename} UNKNOWN IMPORTED) + add_library(GTK2::${_basename} UNKNOWN IMPORTED) - set(GTK2_TARGETS ${GTK2_TARGETS} GTK2::${_basename}) - set(GTK2_TARGETS ${GTK2_TARGETS} PARENT_SCOPE) + if(GTK2_${_var}_LIBRARY_RELEASE) + set_property(TARGET GTK2::${_basename} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) + set_property(TARGET GTK2::${_basename} PROPERTY IMPORTED_LOCATION_RELEASE "${GTK2_${_var}_LIBRARY_RELEASE}" ) + endif() - if(GTK2_${_var}_LIBRARY_RELEASE) - set_property(TARGET GTK2::${_basename} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) - set_property(TARGET GTK2::${_basename} PROPERTY IMPORTED_LOCATION_RELEASE "${GTK2_${_var}_LIBRARY_RELEASE}" ) - endif() + if(GTK2_${_var}_LIBRARY_DEBUG) + set_property(TARGET GTK2::${_basename} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) + set_property(TARGET GTK2::${_basename} PROPERTY IMPORTED_LOCATION_DEBUG "${GTK2_${_var}_LIBRARY_DEBUG}" ) + endif() - if(GTK2_${_var}_LIBRARY_DEBUG) - set_property(TARGET GTK2::${_basename} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) - set_property(TARGET GTK2::${_basename} PROPERTY IMPORTED_LOCATION_DEBUG "${GTK2_${_var}_LIBRARY_DEBUG}" ) - endif() + if(GTK2_${_var}_INCLUDE_DIR) + set_property(TARGET GTK2::${_basename} APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${GTK2_${_var}_INCLUDE_DIR}") + endif() - if(GTK2_${_var}_INCLUDE_DIR) - set_property(TARGET GTK2::${_basename} APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${GTK2_${_var}_INCLUDE_DIR}") - endif() + if(GTK2_${_var}CONFIG_INCLUDE_DIR AND NOT "x${GTK2_${_var}CONFIG_INCLUDE_DIR}" STREQUAL "x${GTK2_${_var}_INCLUDE_DIR}") + set_property(TARGET GTK2::${_basename} APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${GTK2_${_var}CONFIG_INCLUDE_DIR}") + endif() - if(GTK2_${_var}CONFIG_INCLUDE_DIR AND NOT "x${GTK2_${_var}CONFIG_INCLUDE_DIR}" STREQUAL "x${GTK2_${_var}_INCLUDE_DIR}") - set_property(TARGET GTK2::${_basename} APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${GTK2_${_var}CONFIG_INCLUDE_DIR}") - endif() + if(GTK2_DEFINITIONS) + set_property(TARGET GTK2::${_basename} PROPERTY INTERFACE_COMPILE_DEFINITIONS "${GTK2_DEFINITIONS}") + endif() - if(GTK2_DEFINITIONS) - set_property(TARGET GTK2::${_basename} PROPERTY INTERFACE_COMPILE_DEFINITIONS "${GTK2_DEFINITIONS}") - endif() + if(_${_var}_GTK2_DEPENDS) + _GTK2_ADD_TARGET_DEPENDS(${_var} ${_${_var}_GTK2_DEPENDS} ${_${_var}_GTK2_OPTIONAL_DEPENDS}) + endif() - if(_${_var}_GTK2_DEPENDS) - _GTK2_ADD_TARGET_DEPENDS(${_var} ${_${_var}_GTK2_DEPENDS} ${_${_var}_GTK2_OPTIONAL_DEPENDS}) + if(_${_var}_OPTIONAL_INCLUDES) + foreach(_D ${_${_var}_OPTIONAL_INCLUDES}) + if(_D) + _GTK2_ADD_TARGET_INCLUDE_DIRS(${_var} ${_D}) + endif() + endforeach() + endif() endif() - if(_${_var}_OPTIONAL_INCLUDES) - foreach(_D ${_${_var}_OPTIONAL_INCLUDES}) - if(_D) - _GTK2_ADD_TARGET_INCLUDE_DIRS(${_var} ${_D}) - endif() - endforeach() - endif() + set(GTK2_TARGETS ${GTK2_TARGETS} GTK2::${_basename}) + set(GTK2_TARGETS ${GTK2_TARGETS} PARENT_SCOPE) if(GTK2_USE_IMPORTED_TARGETS) set(GTK2_${_var}_LIBRARY GTK2::${_basename} PARENT_SCOPE) @@ -735,9 +737,7 @@ foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) if(APPLE) _GTK2_FIND_LIBRARY (GDK gdk-quartz false true) endif() - if(NOT GTK2_GDK_FOUND) - _GTK2_FIND_LIBRARY (GDK gdk-x11 false true) - endif() + _GTK2_FIND_LIBRARY (GDK gdk-x11 false true) else() _GTK2_FIND_LIBRARY (GDK gdk-win32 false true) endif() @@ -749,9 +749,7 @@ foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) if(APPLE) _GTK2_FIND_LIBRARY (GTK gtk-quartz false true) endif() - if(NOT GTK2_GTK_FOUND) - _GTK2_FIND_LIBRARY (GTK gtk-x11 false true) - endif() + _GTK2_FIND_LIBRARY (GTK gtk-x11 false true) else() _GTK2_FIND_LIBRARY (GTK gtk-win32 false true) endif() diff --git a/Modules/FindLua.cmake b/Modules/FindLua.cmake index c777970..b59b9b3 100644 --- a/Modules/FindLua.cmake +++ b/Modules/FindLua.cmake @@ -75,16 +75,9 @@ function(_lua_set_version_vars) include/lua${CMAKE_MATCH_1}.${CMAKE_MATCH_2} include/lua-${CMAKE_MATCH_1}.${CMAKE_MATCH_2} ) - list(APPEND _lua_library_names - lua${CMAKE_MATCH_1}${CMAKE_MATCH_2} - lua${CMAKE_MATCH_1}.${CMAKE_MATCH_2} - lua-${CMAKE_MATCH_1}.${CMAKE_MATCH_2} - lua.${CMAKE_MATCH_1}.${CMAKE_MATCH_2} - ) endforeach () set(_lua_include_subdirs "${_lua_include_subdirs}" PARENT_SCOPE) - set(_lua_library_names "${_lua_library_names}" PARENT_SCOPE) set(_lua_append_versions "${_lua_append_versions}" PARENT_SCOPE) endfunction(_lua_set_version_vars) @@ -152,6 +145,15 @@ endif () unset(_lua_include_subdirs) unset(_lua_append_versions) +if (LUA_VERSION_STRING) + set(_lua_library_names + lua${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR} + lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR} + lua-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR} + lua.${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR} + ) +endif () + find_library(LUA_LIBRARY NAMES ${_lua_library_names} lua HINTS diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index dd700e3..ff2c4de 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -113,9 +113,10 @@ include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) # # Start out with the generic MPI compiler names, as these are most commonly used. -set(_MPI_C_COMPILER_NAMES mpicc mpcc mpicc_r mpcc_r) +set(_MPI_C_COMPILER_NAMES mpicc mpcc mpicc_r mpcc_r mpicc.bat) set(_MPI_CXX_COMPILER_NAMES mpicxx mpiCC mpcxx mpCC mpic++ mpc++ - mpicxx_r mpiCC_r mpcxx_r mpCC_r mpic++_r mpc++_r) + mpicxx_r mpiCC_r mpcxx_r mpCC_r mpic++_r mpc++_r + mpicxx.bat) set(_MPI_Fortran_COMPILER_NAMES mpif95 mpif95_r mpf95 mpf95_r mpif90 mpif90_r mpf90 mpf90_r mpif77 mpif77_r mpf77 mpf77_r) @@ -127,9 +128,9 @@ set(_MPI_GNU_Fortran_COMPILER_NAMES mpigfortran mpgfortran mpigfortran_r mpig77 mpig77_r mpg77 mpg77_r) # Intel MPI compiler names -set(_MPI_Intel_C_COMPILER_NAMES mpiicc) -set(_MPI_Intel_CXX_COMPILER_NAMES mpiicpc mpiicxx mpiic++ mpiiCC) -set(_MPI_Intel_Fortran_COMPILER_NAMES mpiifort mpiif95 mpiif90 mpiif77) +set(_MPI_Intel_C_COMPILER_NAMES mpiicc mpiicc.bat) +set(_MPI_Intel_CXX_COMPILER_NAMES mpiicpc mpiicxx mpiic++ mpiiCC mpiicpc.bat) +set(_MPI_Intel_Fortran_COMPILER_NAMES mpiifort mpiif95 mpiif90 mpiif77 mpiifort.bat) # PGI compiler names set(_MPI_PGI_C_COMPILER_NAMES mpipgcc mppgcc) @@ -328,6 +329,8 @@ function (interrogate_mpi_compiler lang try_libs) foreach(IPATH ${MPI_ALL_INCLUDE_PATHS}) string(REGEX REPLACE "^ ?-I" "" IPATH ${IPATH}) string(REPLACE "//" "/" IPATH ${IPATH}) + string(REPLACE "\"" "" IPATH ${IPATH}) + file(TO_CMAKE_PATH "${IPATH}" IPATH) list(APPEND MPI_INCLUDE_PATH_WORK ${IPATH}) endforeach() diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index 8b7131b..1958f4b 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -585,10 +585,13 @@ endmacro() macro(pkg_check_modules _prefix _module0) _pkgconfig_parse_options(_pkg_modules _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path _imp_target "${_module0}" ${ARGN}) # check cached value - if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) + if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND OR NOT "${__pkg_config_arguments_${_prefix}}" STREQUAL "${_module0};${ARGN}") _pkg_check_modules_internal("${_pkg_is_required}" "${_pkg_is_silent}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} "${_prefix}" ${_pkg_modules}) _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION}) + if (${_prefix}_FOUND) + _pkgconfig_set(__pkg_config_arguments_${_prefix} "${_module0};${ARGN}") + endif() elseif (${_prefix}_FOUND AND ${_imp_target}) _pkg_create_imp_target("${_prefix}" _no_cmake_path _no_cmake_environment_path) endif() diff --git a/Modules/FortranCInterface.cmake b/Modules/FortranCInterface.cmake index 3899a2d..893a96f 100644 --- a/Modules/FortranCInterface.cmake +++ b/Modules/FortranCInterface.cmake @@ -348,7 +348,8 @@ function(FortranCInterface_VERIFY) try_compile(FortranCInterface_VERIFY_${lang}_COMPILED ${FortranCInterface_BINARY_DIR}/Verify${lang} ${FortranCInterface_SOURCE_DIR}/Verify - VerifyFortranC + VerifyFortranC # project name + VerifyFortranC # target name CMAKE_FLAGS -DVERIFY_CXX=${verify_cxx} -DCMAKE_VERBOSE_MAKEFILE=ON "-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS}" diff --git a/Modules/FortranCInterface/Detect.cmake b/Modules/FortranCInterface/Detect.cmake index 9984efd..7612890 100644 --- a/Modules/FortranCInterface/Detect.cmake +++ b/Modules/FortranCInterface/Detect.cmake @@ -30,7 +30,8 @@ set(_result) try_compile(FortranCInterface_COMPILED ${FortranCInterface_BINARY_DIR} ${FortranCInterface_SOURCE_DIR} - FortranCInterface + FortranCInterface # project name + FortranCInterface # target name CMAKE_FLAGS "-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS}" "-DCMAKE_Fortran_FLAGS:STRING=${CMAKE_Fortran_FLAGS}" diff --git a/Modules/Platform/Android-Common.cmake b/Modules/Platform/Android-Common.cmake index 8755d4f..cf2785a 100644 --- a/Modules/Platform/Android-Common.cmake +++ b/Modules/Platform/Android-Common.cmake @@ -149,4 +149,13 @@ macro(__android_compiler_common lang) if("x${lang}" STREQUAL "xCXX") __android_stl(CXX) endif() + + # <ndk>/build/core/definitions.mk appends the sysroot's include directory + # explicitly at the end of the command-line include path so that it + # precedes the toolchain's builtin include directories. This is + # necessary so that Android API-version-specific headers are preferred + # over those in the toolchain's `include-fixed` directory (which cannot + # possibly match all versions). + list(APPEND CMAKE_${lang}_STANDARD_INCLUDE_DIRECTORIES "${CMAKE_SYSROOT}/usr/include") + list(REMOVE_ITEM CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES "/usr/include") endmacro() diff --git a/Modules/Platform/Android/ndk-stl-c++.cmake b/Modules/Platform/Android/ndk-stl-c++.cmake index b27015d..a12411c 100644 --- a/Modules/Platform/Android/ndk-stl-c++.cmake +++ b/Modules/Platform/Android/ndk-stl-c++.cmake @@ -6,16 +6,15 @@ macro(__android_stl_cxx lang filename) if(EXISTS "${CMAKE_ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libcxx/include/cstddef") # r12 and below __android_stl_inc(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libcxx/include" 1) + __android_stl_inc(${lang} "${CMAKE_ANDROID_NDK}/sources/android/support/include" 0) __android_stl_inc(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/llvm-libc++abi/libcxxabi/include" 1) else() # r13 and above __android_stl_inc(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/llvm-libc++/include" 1) + __android_stl_inc(${lang} "${CMAKE_ANDROID_NDK}/sources/android/support/include" 0) __android_stl_inc(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/llvm-libc++abi/include" 1) endif() - # Add a secondary include directory if it exists. - __android_stl_inc(${lang} "${CMAKE_ANDROID_NDK}/sources/android/support/include" 0) - # Add the library file. __android_stl_lib(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libs/${CMAKE_ANDROID_ARCH_ABI}/${filename}" 1) endmacro() diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake index 0279d1c..0478918 100644 --- a/Modules/Qt4Macros.cmake +++ b/Modules/Qt4Macros.cmake @@ -439,7 +439,7 @@ macro(QT4_CREATE_TRANSLATION _qm_files) get_filename_component(_abs_include "${_pro_include}" ABSOLUTE) string(APPEND _pro_includes " \\\n \"${_abs_include}\"") endforeach() - file(WRITE ${_ts_pro} "SOURCES =${_pro_srcs}\nINCLUDEPATH =${_pro_includes}\n") + file(GENERATE OUTPUT ${_ts_pro} CONTENT "SOURCES =${_pro_srcs}\nINCLUDEPATH =${_pro_includes}\n") endif() add_custom_command(OUTPUT ${_ts_file} COMMAND Qt4::lupdate diff --git a/Modules/WriteCompilerDetectionHeader.cmake b/Modules/WriteCompilerDetectionHeader.cmake index ba249e1..0b16aa4 100644 --- a/Modules/WriteCompilerDetectionHeader.cmake +++ b/Modules/WriteCompilerDetectionHeader.cmake @@ -20,6 +20,8 @@ # [VERSION <version>] # [PROLOG <prolog>] # [EPILOG <epilog>] +# [ALLOW_UNKNOWN_COMPILERS] +# [ALLOW_UNKNOWN_COMPILER_VERSIONS] # ) # # The ``write_compiler_detection_header`` function generates the @@ -81,6 +83,11 @@ # See the :manual:`cmake-compile-features(7)` manual for information on # compile features. # +# ``ALLOW_UNKNOWN_COMPILERS`` and ``ALLOW_UNKNOWN_COMPILER_VERSIONS`` cause +# the module to generate conditions that treat unknown compilers as simply +# lacking all features. Without these options the default behavior is to +# generate a ``#error`` for unknown compilers. +# # Feature Test Macros # =================== # @@ -232,6 +239,19 @@ function(_load_compiler_variables CompilerId lang) set(_compiler_id_version_compute_${CompilerId} ${_compiler_id_version_compute} PARENT_SCOPE) endfunction() +macro(_simpledefine FEATURE_NAME FEATURE_TESTNAME FEATURE_STRING FEATURE_DEFAULT_STRING) + if (feature STREQUAL "${FEATURE_NAME}") + set(def_value "${prefix_arg}_${FEATURE_TESTNAME}") + string(APPEND file_content " +# if defined(${def_name}) && ${def_name} +# define ${def_value} ${FEATURE_STRING} +# else +# define ${def_value} ${FEATURE_DEFAULT_STRING} +# endif +\n") + endif() +endmacro() + function(write_compiler_detection_header file_keyword file_arg prefix_keyword prefix_arg @@ -242,7 +262,7 @@ function(write_compiler_detection_header if (NOT "x${prefix_keyword}" STREQUAL "xPREFIX") message(FATAL_ERROR "write_compiler_detection_header: PREFIX parameter missing.") endif() - set(options) + set(options ALLOW_UNKNOWN_COMPILERS ALLOW_UNKNOWN_COMPILER_VERSIONS) set(oneValueArgs VERSION EPILOG PROLOG OUTPUT_FILES_VAR OUTPUT_DIR) set(multiValueArgs COMPILERS FEATURES) cmake_parse_arguments(_WCD "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) @@ -426,10 +446,12 @@ function(write_compiler_detection_header set(compiler_file_content file_content) endif() - set(${compiler_file_content} "${${compiler_file_content}} + if(NOT _WCD_ALLOW_UNKNOWN_COMPILER_VERSIONS) + set(${compiler_file_content} "${${compiler_file_content}} # if !(${_cmake_oldestSupported_${compiler}}) # error Unsupported compiler version # endif\n") + endif() set(PREFIX ${prefix_arg}_) if (_need_hex_conversion) @@ -460,67 +482,36 @@ function(write_compiler_detection_header endforeach() endforeach() if(pp_if STREQUAL "elif") - string(APPEND file_content " + if(_WCD_ALLOW_UNKNOWN_COMPILERS) + string(APPEND file_content " +# endif\n") + else() + string(APPEND file_content " # else # error Unsupported compiler # endif\n") + endif() endif() foreach(feature ${${_lang}_features}) string(TOUPPER ${feature} feature_upper) set(feature_PP "COMPILER_${feature_upper}") set(def_name ${prefix_arg}_${feature_PP}) - if (feature STREQUAL c_restrict) - set(def_value "${prefix_arg}_RESTRICT") - string(APPEND file_content " -# if ${def_name} -# define ${def_value} restrict -# else -# define ${def_value} -# endif -\n") - endif() - if (feature STREQUAL cxx_constexpr) - set(def_value "${prefix_arg}_CONSTEXPR") - string(APPEND file_content " -# if ${def_name} -# define ${def_value} constexpr -# else -# define ${def_value} -# endif -\n") - endif() - if (feature STREQUAL cxx_final) - set(def_value "${prefix_arg}_FINAL") - string(APPEND file_content " -# if ${def_name} -# define ${def_value} final -# else -# define ${def_value} -# endif -\n") - endif() - if (feature STREQUAL cxx_override) - set(def_value "${prefix_arg}_OVERRIDE") - string(APPEND file_content " -# if ${def_name} -# define ${def_value} override -# else -# define ${def_value} -# endif -\n") - endif() + _simpledefine(c_restrict RESTRICT restrict "") + _simpledefine(cxx_constexpr CONSTEXPR constexpr "") + _simpledefine(cxx_final FINAL final "") + _simpledefine(cxx_override OVERRIDE override "") if (feature STREQUAL cxx_static_assert) set(def_value "${prefix_arg}_STATIC_ASSERT(X)") set(def_value_msg "${prefix_arg}_STATIC_ASSERT_MSG(X, MSG)") set(static_assert_struct "template<bool> struct ${prefix_arg}StaticAssert;\ntemplate<> struct ${prefix_arg}StaticAssert<true>{};\n") set(def_standard "# define ${def_value} static_assert(X, #X)\n# define ${def_value_msg} static_assert(X, MSG)") set(def_alternative "${static_assert_struct}# define ${def_value} sizeof(${prefix_arg}StaticAssert<X>)\n# define ${def_value_msg} sizeof(${prefix_arg}StaticAssert<X>)") - string(APPEND file_content "# if ${def_name}\n${def_standard}\n# else\n${def_alternative}\n# endif\n\n") + string(APPEND file_content "# if defined(${def_name}) && ${def_name}\n${def_standard}\n# else\n${def_alternative}\n# endif\n\n") endif() if (feature STREQUAL cxx_alignas) set(def_value "${prefix_arg}_ALIGNAS(X)") string(APPEND file_content " -# if ${def_name} +# if defined(${def_name}) && ${def_name} # define ${def_value} alignas(X) # elif ${prefix_arg}_COMPILER_IS_GNU || ${prefix_arg}_COMPILER_IS_Clang || ${prefix_arg}_COMPILER_IS_AppleClang # define ${def_value} __attribute__ ((__aligned__(X))) @@ -534,7 +525,7 @@ function(write_compiler_detection_header if (feature STREQUAL cxx_alignof) set(def_value "${prefix_arg}_ALIGNOF(X)") string(APPEND file_content " -# if ${def_name} +# if defined(${def_name}) && ${def_name} # define ${def_value} alignof(X) # elif ${prefix_arg}_COMPILER_IS_GNU || ${prefix_arg}_COMPILER_IS_Clang || ${prefix_arg}_COMPILER_IS_AppleClang # define ${def_value} __alignof__(X) @@ -543,30 +534,12 @@ function(write_compiler_detection_header # endif \n") endif() - if (feature STREQUAL cxx_deleted_functions) - set(def_value "${prefix_arg}_DELETED_FUNCTION") - string(APPEND file_content " -# if ${def_name} -# define ${def_value} = delete -# else -# define ${def_value} -# endif -\n") - endif() - if (feature STREQUAL cxx_extern_templates) - set(def_value "${prefix_arg}_EXTERN_TEMPLATE") - string(APPEND file_content " -# if ${def_name} -# define ${def_value} extern -# else -# define ${def_value} -# endif -\n") - endif() + _simpledefine(cxx_deleted_functions DELETED_FUNCTION "= delete" "") + _simpledefine(cxx_extern_templates EXTERN_TEMPLATE extern "") if (feature STREQUAL cxx_noexcept) set(def_value "${prefix_arg}_NOEXCEPT") string(APPEND file_content " -# if ${def_name} +# if defined(${def_name}) && ${def_name} # define ${def_value} noexcept # define ${def_value}_EXPR(X) noexcept(X) # else @@ -575,20 +548,11 @@ function(write_compiler_detection_header # endif \n") endif() - if (feature STREQUAL cxx_nullptr) - set(def_value "${prefix_arg}_NULLPTR") - string(APPEND file_content " -# if ${def_name} -# define ${def_value} nullptr -# else -# define ${def_value} 0 -# endif -\n") - endif() + _simpledefine(cxx_nullptr NULLPTR nullptr 0) if (feature STREQUAL cxx_thread_local) set(def_value "${prefix_arg}_THREAD_LOCAL") string(APPEND file_content " -# if ${def_name} +# if defined(${def_name}) && ${def_name} # define ${def_value} thread_local # elif ${prefix_arg}_COMPILER_IS_GNU || ${prefix_arg}_COMPILER_IS_Clang || ${prefix_arg}_COMPILER_IS_AppleClang # define ${def_value} __thread @@ -604,7 +568,7 @@ function(write_compiler_detection_header set(def_value "${prefix_arg}_DEPRECATED") string(APPEND file_content " # ifndef ${def_value} -# if ${def_name} +# if defined(${def_name}) && ${def_name} # define ${def_value} [[deprecated]] # define ${def_value}_MSG(MSG) [[deprecated(MSG)]] # elif ${prefix_arg}_COMPILER_IS_GNU || ${prefix_arg}_COMPILER_IS_Clang |