diff options
author | JinWang An <jinwang.an@samsung.com> | 2022-12-27 17:20:04 +0900 |
---|---|---|
committer | JinWang An <jinwang.an@samsung.com> | 2022-12-27 17:20:04 +0900 |
commit | ee94ded5e1f6585451d7376f711dc12cb3d92a01 (patch) | |
tree | 4f02ee3ee8746576052abd0ec3a746631dfa96e2 /Modules | |
parent | e502e056ca86a2eea429e09cd2f5d9c14105ee90 (diff) | |
download | cmake-ee94ded5e1f6585451d7376f711dc12cb3d92a01.tar.gz cmake-ee94ded5e1f6585451d7376f711dc12cb3d92a01.tar.bz2 cmake-ee94ded5e1f6585451d7376f711dc12cb3d92a01.zip |
Imported Upstream version 3.22.0upstream/3.22.0
Diffstat (limited to 'Modules')
97 files changed, 2044 insertions, 939 deletions
diff --git a/Modules/CMakeASM_MASMInformation.cmake b/Modules/CMakeASM_MASMInformation.cmake index 6d1e174e3..656b75e7d 100644 --- a/Modules/CMakeASM_MASMInformation.cmake +++ b/Modules/CMakeASM_MASMInformation.cmake @@ -8,7 +8,7 @@ set(ASM_DIALECT "_MASM") set(CMAKE_ASM${ASM_DIALECT}_SOURCE_FILE_EXTENSIONS asm) -set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT "<CMAKE_ASM${ASM_DIALECT}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> /c /Fo <OBJECT> <SOURCE>") +set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT "<CMAKE_ASM${ASM_DIALECT}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -c -Fo <OBJECT> <SOURCE>") # The ASM_MASM compiler id for this compiler is "MSVC", so fill out the runtime library table. set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded "") diff --git a/Modules/CMakeASM_NASMInformation.cmake b/Modules/CMakeASM_NASMInformation.cmake index dad2750e8..a72575b4a 100644 --- a/Modules/CMakeASM_NASMInformation.cmake +++ b/Modules/CMakeASM_NASMInformation.cmake @@ -35,7 +35,7 @@ if(NOT CMAKE_ASM_NASM_OBJECT_FORMAT) endif() if(NOT CMAKE_ASM_NASM_COMPILE_OBJECT) - set(CMAKE_ASM_NASM_COMPILE_OBJECT "<CMAKE_ASM_NASM_COMPILER> <INCLUDES> <FLAGS> -f ${CMAKE_ASM_NASM_OBJECT_FORMAT} -o <OBJECT> <SOURCE>") + set(CMAKE_ASM_NASM_COMPILE_OBJECT "<CMAKE_ASM_NASM_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -f ${CMAKE_ASM_NASM_OBJECT_FORMAT} -o <OBJECT> <SOURCE>") endif() if(CMAKE_ASM_NASM_COMPILER_ID STREQUAL "NASM") diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in index 754f235ba..2b24ff2aa 100644 --- a/Modules/CMakeCCompiler.cmake.in +++ b/Modules/CMakeCCompiler.cmake.in @@ -5,6 +5,7 @@ set(CMAKE_C_COMPILER_VERSION "@CMAKE_C_COMPILER_VERSION@") set(CMAKE_C_COMPILER_VERSION_INTERNAL "@CMAKE_C_COMPILER_VERSION_INTERNAL@") set(CMAKE_C_COMPILER_WRAPPER "@CMAKE_C_COMPILER_WRAPPER@") set(CMAKE_C_STANDARD_COMPUTED_DEFAULT "@CMAKE_C_STANDARD_COMPUTED_DEFAULT@") +set(CMAKE_C_EXTENSIONS_COMPUTED_DEFAULT "@CMAKE_C_EXTENSIONS_COMPUTED_DEFAULT@") set(CMAKE_C_COMPILE_FEATURES "@CMAKE_C_COMPILE_FEATURES@") set(CMAKE_C90_COMPILE_FEATURES "@CMAKE_C90_COMPILE_FEATURES@") set(CMAKE_C99_COMPILE_FEATURES "@CMAKE_C99_COMPILE_FEATURES@") @@ -30,18 +31,9 @@ set(CMAKE_COMPILER_IS_GNUCC @CMAKE_COMPILER_IS_GNUCC@) set(CMAKE_C_COMPILER_LOADED 1) set(CMAKE_C_COMPILER_WORKS @CMAKE_C_COMPILER_WORKS@) set(CMAKE_C_ABI_COMPILED @CMAKE_C_ABI_COMPILED@) -set(CMAKE_COMPILER_IS_MINGW @CMAKE_COMPILER_IS_MINGW@) -set(CMAKE_COMPILER_IS_CYGWIN @CMAKE_COMPILER_IS_CYGWIN@) -if(CMAKE_COMPILER_IS_CYGWIN) - set(CYGWIN 1) - set(UNIX 1) -endif() set(CMAKE_C_COMPILER_ENV_VAR "CC") -if(CMAKE_COMPILER_IS_MINGW) - set(MINGW 1) -endif() set(CMAKE_C_COMPILER_ID_RUN 1) set(CMAKE_C_SOURCE_FILE_EXTENSIONS c;m) set(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC) diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in index 1f19c00e2..43ede3e8a 100644 --- a/Modules/CMakeCCompilerId.c.in +++ b/Modules/CMakeCCompilerId.c.in @@ -41,23 +41,34 @@ char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]"; #if !defined(__STDC__) && !defined(__clang__) # if defined(_MSC_VER) || defined(__ibmxl__) || defined(__IBMC__) -# define C_DIALECT "90" +# define C_VERSION "90" # else -# define C_DIALECT +# define C_VERSION # endif #elif __STDC_VERSION__ > 201710L -# define C_DIALECT "23" +# define C_VERSION "23" #elif __STDC_VERSION__ >= 201710L -# define C_DIALECT "17" +# define C_VERSION "17" #elif __STDC_VERSION__ >= 201000L -# define C_DIALECT "11" +# define C_VERSION "11" #elif __STDC_VERSION__ >= 199901L -# define C_DIALECT "99" +# define C_VERSION "99" #else -# define C_DIALECT "90" +# define C_VERSION "90" #endif -const char* info_language_dialect_default = - "INFO" ":" "dialect_default[" C_DIALECT "]"; +const char* info_language_standard_default = + "INFO" ":" "standard_default[" C_VERSION "]"; + +const char* info_language_extensions_default = "INFO" ":" "extensions_default[" +// !defined(_MSC_VER) to exclude Clang's MSVC compatibility mode. +#if (defined(__clang__) || defined(__GNUC__) || \ + defined(__TI_COMPILER_VERSION__)) && \ + !defined(__STRICT_ANSI__) && !defined(_MSC_VER) + "ON" +#else + "OFF" +#endif +"]"; /*--------------------------------------------------------------------------*/ @@ -89,7 +100,8 @@ int main(int argc, char* argv[]) #if defined(__CRAYXT_COMPUTE_LINUX_TARGET) require += info_cray[argc]; #endif - require += info_language_dialect_default[argc]; + require += info_language_standard_default[argc]; + require += info_language_extensions_default[argc]; (void)argv; return require; } diff --git a/Modules/CMakeCInformation.cmake b/Modules/CMakeCInformation.cmake index 6be186575..665f30927 100644 --- a/Modules/CMakeCInformation.cmake +++ b/Modules/CMakeCInformation.cmake @@ -91,6 +91,14 @@ if(CMAKE_USER_MAKE_RULES_OVERRIDE_C) set(CMAKE_USER_MAKE_RULES_OVERRIDE_C "${_override}") endif() +if(CMAKE_EXECUTABLE_FORMAT STREQUAL "ELF") + if(NOT DEFINED CMAKE_C_LINK_WHAT_YOU_USE_FLAG) + set(CMAKE_C_LINK_WHAT_YOU_USE_FLAG "LINKER:--no-as-needed") + endif() + if(NOT DEFINED CMAKE_LINK_WHAT_YOU_USE_CHECK) + set(CMAKE_LINK_WHAT_YOU_USE_CHECK ldd -u -r) + endif() +endif() # for most systems a module is the same as a shared library # so unless the variable CMAKE_MODULE_EXISTS is set just @@ -196,5 +204,3 @@ if(NOT CMAKE_EXECUTABLE_RPATH_LINK_C_FLAG) endif() set(CMAKE_C_INFORMATION_LOADED 1) - - diff --git a/Modules/CMakeCUDACompiler.cmake.in b/Modules/CMakeCUDACompiler.cmake.in index 56ae7324b..2f3e9a8ce 100644 --- a/Modules/CMakeCUDACompiler.cmake.in +++ b/Modules/CMakeCUDACompiler.cmake.in @@ -6,6 +6,7 @@ set(CMAKE_CUDA_COMPILER_VERSION "@CMAKE_CUDA_COMPILER_VERSION@") set(CMAKE_CUDA_DEVICE_LINKER "@CMAKE_CUDA_DEVICE_LINKER@") set(CMAKE_CUDA_FATBINARY "@CMAKE_CUDA_FATBINARY@") set(CMAKE_CUDA_STANDARD_COMPUTED_DEFAULT "@CMAKE_CUDA_STANDARD_COMPUTED_DEFAULT@") +set(CMAKE_CUDA_EXTENSIONS_COMPUTED_DEFAULT "@CMAKE_CUDA_EXTENSIONS_COMPUTED_DEFAULT@") set(CMAKE_CUDA_COMPILE_FEATURES "@CMAKE_CUDA_COMPILE_FEATURES@") set(CMAKE_CUDA03_COMPILE_FEATURES "@CMAKE_CUDA03_COMPILE_FEATURES@") set(CMAKE_CUDA11_COMPILE_FEATURES "@CMAKE_CUDA11_COMPILE_FEATURES@") diff --git a/Modules/CMakeCUDACompilerId.cu.in b/Modules/CMakeCUDACompilerId.cu.in index 91039e5ae..bc685a7eb 100644 --- a/Modules/CMakeCUDACompilerId.cu.in +++ b/Modules/CMakeCUDACompilerId.cu.in @@ -16,7 +16,7 @@ char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; @CMAKE_CUDA_COMPILER_ID_PLATFORM_CONTENT@ @CMAKE_CUDA_COMPILER_ID_ERROR_FOR_TEST@ -const char* info_language_dialect_default = "INFO" ":" "dialect_default[" +const char* info_language_standard_default = "INFO" ":" "standard_default[" #if __cplusplus > 202002L "23" #elif __cplusplus > 201703L @@ -32,6 +32,16 @@ const char* info_language_dialect_default = "INFO" ":" "dialect_default[" #endif "]"; +const char* info_language_extensions_default = "INFO" ":" "extensions_default[" +// !defined(_MSC_VER) to exclude Clang's MSVC compatibility mode. +#if (defined(__clang__) || defined(__GNUC__)) && !defined(__STRICT_ANSI__) && \ + !defined(_MSC_VER) + "ON" +#else + "OFF" +#endif +"]"; + /*--------------------------------------------------------------------------*/ int main(int argc, char* argv[]) @@ -48,7 +58,8 @@ int main(int argc, char* argv[]) #ifdef SIMULATE_VERSION_MAJOR require += info_simulate_version[argc]; #endif - require += info_language_dialect_default[argc]; + require += info_language_standard_default[argc]; + require += info_language_extensions_default[argc]; (void)argv; return require; } diff --git a/Modules/CMakeCUDAInformation.cmake b/Modules/CMakeCUDAInformation.cmake index a2946f458..e9cfed607 100644 --- a/Modules/CMakeCUDAInformation.cmake +++ b/Modules/CMakeCUDAInformation.cmake @@ -100,6 +100,15 @@ if(NOT CMAKE_MODULE_EXISTS) set(CMAKE_SHARED_MODULE_CREATE_CUDA_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_CUDA_FLAGS}) endif() +if(CMAKE_EXECUTABLE_FORMAT STREQUAL "ELF") + if(NOT DEFINED CMAKE_CUDA_LINK_WHAT_YOU_USE_FLAG) + set(CMAKE_CUDA_LINK_WHAT_YOU_USE_FLAG "LINKER:--no-as-needed") + endif() + if(NOT DEFINED CMAKE_LINK_WHAT_YOU_USE_CHECK) + set(CMAKE_LINK_WHAT_YOU_USE_CHECK ldd -u -r) + endif() +endif() + # add the flags to the cache based # on the initial values computed in the platform/*.cmake files # use _INIT variables so that this only happens the first time diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index d0ce77a7e..534e96055 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -5,6 +5,7 @@ set(CMAKE_CXX_COMPILER_VERSION "@CMAKE_CXX_COMPILER_VERSION@") set(CMAKE_CXX_COMPILER_VERSION_INTERNAL "@CMAKE_CXX_COMPILER_VERSION_INTERNAL@") set(CMAKE_CXX_COMPILER_WRAPPER "@CMAKE_CXX_COMPILER_WRAPPER@") set(CMAKE_CXX_STANDARD_COMPUTED_DEFAULT "@CMAKE_CXX_STANDARD_COMPUTED_DEFAULT@") +set(CMAKE_CXX_EXTENSIONS_COMPUTED_DEFAULT "@CMAKE_CXX_EXTENSIONS_COMPUTED_DEFAULT@") set(CMAKE_CXX_COMPILE_FEATURES "@CMAKE_CXX_COMPILE_FEATURES@") set(CMAKE_CXX98_COMPILE_FEATURES "@CMAKE_CXX98_COMPILE_FEATURES@") set(CMAKE_CXX11_COMPILE_FEATURES "@CMAKE_CXX11_COMPILE_FEATURES@") @@ -31,18 +32,9 @@ set(CMAKE_COMPILER_IS_GNUCXX @CMAKE_COMPILER_IS_GNUCXX@) set(CMAKE_CXX_COMPILER_LOADED 1) set(CMAKE_CXX_COMPILER_WORKS @CMAKE_CXX_COMPILER_WORKS@) set(CMAKE_CXX_ABI_COMPILED @CMAKE_CXX_ABI_COMPILED@) -set(CMAKE_COMPILER_IS_MINGW @CMAKE_COMPILER_IS_MINGW@) -set(CMAKE_COMPILER_IS_CYGWIN @CMAKE_COMPILER_IS_CYGWIN@) -if(CMAKE_COMPILER_IS_CYGWIN) - set(CYGWIN 1) - set(UNIX 1) -endif() set(CMAKE_CXX_COMPILER_ENV_VAR "CXX") -if(CMAKE_COMPILER_IS_MINGW) - set(MINGW 1) -endif() set(CMAKE_CXX_COMPILER_ID_RUN 1) set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;m;mm;mpp;CPP;ixx;cppm) set(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC) diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in index 7362a0837..cdf9c1828 100644 --- a/Modules/CMakeCXXCompilerId.cpp.in +++ b/Modules/CMakeCXXCompilerId.cpp.in @@ -49,7 +49,7 @@ char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]"; # define CXX_STD __cplusplus #endif -const char* info_language_dialect_default = "INFO" ":" "dialect_default[" +const char* info_language_standard_default = "INFO" ":" "standard_default[" #if CXX_STD > 202002L "23" #elif CXX_STD > 201703L @@ -65,6 +65,17 @@ const char* info_language_dialect_default = "INFO" ":" "dialect_default[" #endif "]"; +const char* info_language_extensions_default = "INFO" ":" "extensions_default[" +// !defined(_MSC_VER) to exclude Clang's MSVC compatibility mode. +#if (defined(__clang__) || defined(__GNUC__) || \ + defined(__TI_COMPILER_VERSION__)) && \ + !defined(__STRICT_ANSI__) && !defined(_MSC_VER) + "ON" +#else + "OFF" +#endif +"]"; + /*--------------------------------------------------------------------------*/ int main(int argc, char* argv[]) @@ -87,7 +98,8 @@ int main(int argc, char* argv[]) #if defined(__CRAYXT_COMPUTE_LINUX_TARGET) require += info_cray[argc]; #endif - require += info_language_dialect_default[argc]; + require += info_language_standard_default[argc]; + require += info_language_extensions_default[argc]; (void)argv; return require; } diff --git a/Modules/CMakeCXXInformation.cmake b/Modules/CMakeCXXInformation.cmake index 944d23609..53abf378d 100644 --- a/Modules/CMakeCXXInformation.cmake +++ b/Modules/CMakeCXXInformation.cmake @@ -193,6 +193,15 @@ foreach(type SHARED_LIBRARY SHARED_MODULE EXE) endif() endforeach() +if(CMAKE_EXECUTABLE_FORMAT STREQUAL "ELF") + if(NOT DEFINED CMAKE_CXX_LINK_WHAT_YOU_USE_FLAG) + set(CMAKE_CXX_LINK_WHAT_YOU_USE_FLAG "LINKER:--no-as-needed") + endif() + if(NOT DEFINED CMAKE_LINK_WHAT_YOU_USE_CHECK) + set(CMAKE_LINK_WHAT_YOU_USE_CHECK ldd -u -r) + endif() +endif() + # add the flags to the cache based # on the initial values computed in the platform/*.cmake files # use _INIT variables so that this only happens the first time diff --git a/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake b/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake index 05174de83..bda1d7111 100644 --- a/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake +++ b/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake @@ -32,5 +32,6 @@ macro (CHECK_COMPILER_FLAG_COMMON_PATTERNS _VAR) FAIL_REGEX "Warning: illegal option" # SunStudio 12 FAIL_REGEX "[Ww]arning: Invalid suboption" # Fujitsu FAIL_REGEX "An invalid option .* appears on the command line" # Cray + FAIL_REGEX "WARNING: invalid compiler option" # TI armcl ) endmacro () diff --git a/Modules/CMakeDependentOption.cmake b/Modules/CMakeDependentOption.cmake index 96855d28f..b7c478f64 100644 --- a/Modules/CMakeDependentOption.cmake +++ b/Modules/CMakeDependentOption.cmake @@ -10,44 +10,62 @@ Macro to provide an option dependent on other options. This macro presents an option to the user only if a set of other conditions are true. -Usage: +.. command:: cmake_dependent_option -.. code-block:: cmake + .. code-block:: cmake - cmake_dependent_option(<option> "<help_text>" <value> <depends> <force>) + cmake_dependent_option(<option> "<help_text>" <value> <depends> <force>) -Where ``<option>`` is available to the user if ``<depends>`` is true. When -``<option>`` is available, the given ``<help_text>`` and initial ``<value>`` -are used. If the ``<depends>`` condition is not true, ``<option>`` will not be -presented and will always have the value given by ``<force>``. Any value set by -the user is preserved for when the option is presented again. Each element in -the fourth parameter is evaluated as an if-condition, so -:ref:`Condition Syntax` can be used. + Makes ``<option>`` available to the user if ``<depends>`` is true. When + ``<option>`` is available, the given ``<help_text>`` and initial ``<value>`` + are used. If the ``<depends>`` condition is not true, ``<option>`` will not be + presented and will always have the value given by ``<force>``. Any value set by + the user is preserved for when the option is presented again. In case ``<depends>`` + is a :ref:`semicolon-separated list <CMake Language Lists>`, all elements must + be true in order to initialize ``<option>`` with ``<value>``. Example invocation: .. code-block:: cmake - cmake_dependent_option(USE_FOO "Use Foo" ON - "USE_BAR;NOT USE_ZOT" OFF) + cmake_dependent_option(USE_FOO "Use Foo" ON "USE_BAR;NOT USE_ZOT" OFF) If ``USE_BAR`` is true and ``USE_ZOT`` is false, this provides an option called ``USE_FOO`` that defaults to ON. Otherwise, it sets ``USE_FOO`` to OFF and hides the option from the user. If the status of ``USE_BAR`` or ``USE_ZOT`` ever changes, any value for the ``USE_FOO`` option is saved so that when the option is re-enabled it retains its old value. + +.. versionadded:: 3.22 + + Full :ref:`Condition Syntax` is now supported. See policy :policy:`CMP0127`. + #]=======================================================================] macro(CMAKE_DEPENDENT_OPTION option doc default depends force) + cmake_policy(GET CMP0127 _CDO_CMP0127 + PARENT_SCOPE # undocumented, do not use outside of CMake + ) if(${option}_ISSET MATCHES "^${option}_ISSET$") set(${option}_AVAILABLE 1) - foreach(d ${depends}) - string(REGEX REPLACE " +" ";" CMAKE_DEPENDENT_OPTION_DEP "${d}") - if(${CMAKE_DEPENDENT_OPTION_DEP}) - else() - set(${option}_AVAILABLE 0) - endif() - endforeach() + if("x${_CDO_CMP0127}x" STREQUAL "xNEWx") + foreach(d ${depends}) + cmake_language(EVAL CODE " + if (${d}) + else() + set(${option}_AVAILABLE 0) + endif()" + ) + endforeach() + else() + foreach(d ${depends}) + string(REGEX REPLACE " +" ";" CMAKE_DEPENDENT_OPTION_DEP "${d}") + if(${CMAKE_DEPENDENT_OPTION_DEP}) + else() + set(${option}_AVAILABLE 0) + endif() + endforeach() + endif() if(${option}_AVAILABLE) option(${option} "${doc}" "${default}") set(${option} "${${option}}" CACHE BOOL "${doc}" FORCE) @@ -61,4 +79,9 @@ macro(CMAKE_DEPENDENT_OPTION option doc default depends force) else() set(${option} "${${option}_ISSET}") endif() + if("x${_CDO_CMP0127}x" STREQUAL "xx" AND "x${depends}x" MATCHES "[^A-Za-z0-9_; ]") + cmake_policy(GET_WARNING CMP0127 _CDO_CMP0127_WARNING) + message(AUTHOR_WARNING "${_CDO_CMP0127_WARNING}") + endif() + unset(_CDO_CMP0127) endmacro() diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake index e8b9db797..a1814b7dd 100644 --- a/Modules/CMakeDetermineASMCompiler.cmake +++ b/Modules/CMakeDetermineASMCompiler.cmake @@ -125,6 +125,7 @@ if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) include(CMakeDetermineCompilerId) set(userflags) CMAKE_DETERMINE_COMPILER_ID_VENDOR(ASM${ASM_DIALECT} "${userflags}") + set(_variant "") if("x${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}" STREQUAL "xIAR") # primary necessary to detect architecture, so the right archiver and linker can be picked # eg. "IAR Assembler V8.10.1.12857/W32 for ARM" or "IAR Assembler V4.11.1.4666 for Renesas RX" @@ -137,6 +138,19 @@ if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) if(_all_compileid_matches) list(GET _all_compileid_matches "-1" CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID) endif() + elseif("x${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}" STREQUAL "xClang") + # Test whether an MSVC-like command-line option works. + execute_process(COMMAND ${CMAKE_ASM${ASM_DIALECT}_COMPILER} -? + OUTPUT_VARIABLE _clang_output + ERROR_VARIABLE _clang_output + RESULT_VARIABLE _clang_result) + if(_clang_result EQUAL 0) + set(CMAKE_ASM${ASM_DIALECT}_COMPILER_FRONTEND_VARIANT "MSVC") + set(CMAKE_ASM${ASM_DIALECT}_SIMULATE_ID MSVC) + else() + set(CMAKE_ASM${ASM_DIALECT}_COMPILER_FRONTEND_VARIANT "GNU") + endif() + set(_variant " with ${CMAKE_ASM${ASM_DIALECT}_COMPILER_FRONTEND_VARIANT}-like command-line") endif() _cmake_find_compiler_sysroot(ASM${ASM_DIALECT}) @@ -144,6 +158,8 @@ if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) unset(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_OUTPUT) unset(_all_compileid_matches) unset(_compileid) + unset(_clang_result) + unset(_clang_output) endif() if(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) @@ -157,9 +173,10 @@ if(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) else() set(_archid "") endif() - message(STATUS "The ASM${ASM_DIALECT} compiler identification is ${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}${_archid}${_version}") + message(STATUS "The ASM${ASM_DIALECT} compiler identification is ${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}${_archid}${_version}${_variant}") unset(_archid) unset(_version) + unset(_variant) else() message(STATUS "The ASM${ASM_DIALECT} compiler identification is unknown") endif() diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 0f80f9cff..15eab0f5e 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -128,11 +128,6 @@ if(NOT CMAKE_C_COMPILER_ID_RUN) if(CMAKE_C_COMPILER_ID STREQUAL "GNU") set(CMAKE_COMPILER_IS_GNUCC 1) endif() - if(CMAKE_C_PLATFORM_ID MATCHES "MinGW") - set(CMAKE_COMPILER_IS_MINGW 1) - elseif(CMAKE_C_PLATFORM_ID MATCHES "Cygwin") - set(CMAKE_COMPILER_IS_CYGWIN 1) - endif() else() if(NOT DEFINED CMAKE_C_COMPILER_FRONTEND_VARIANT) # Some toolchain files set our internal CMAKE_C_COMPILER_ID_RUN diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake index e360d3127..d06315e47 100644 --- a/Modules/CMakeDetermineCUDACompiler.cmake +++ b/Modules/CMakeDetermineCUDACompiler.cmake @@ -192,17 +192,31 @@ if(NOT CMAKE_CUDA_COMPILER_ID_RUN) get_filename_component(CMAKE_CUDA_COMPILER_TOOLKIT_ROOT "${_CUDA_NVCC_EXECUTABLE}" DIRECTORY) get_filename_component(CMAKE_CUDA_COMPILER_TOOLKIT_ROOT "${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}" DIRECTORY) endif() + + if(_CUDA_NVCC_OUT MATCHES "\\#\\$ NVVMIR_LIBRARY_DIR=([^\r\n]*)") + get_filename_component(_CUDA_NVVMIR_LIBRARY_DIR "${CMAKE_MATCH_1}" ABSOLUTE) + + #We require the path to end in `/nvvm/libdevice' + if(_CUDA_NVVMIR_LIBRARY_DIR MATCHES "nvvm/libdevice$") + get_filename_component(_CUDA_NVVMIR_LIBRARY_DIR "${_CUDA_NVVMIR_LIBRARY_DIR}/../.." ABSOLUTE) + set(CMAKE_CUDA_COMPILER_LIBRARY_ROOT_FROM_NVVMIR_LIBRARY_DIR "${_CUDA_NVVMIR_LIBRARY_DIR}") + endif() + + unset(_CUDA_NVVMIR_LIBRARY_DIR) + unset(_cuda_nvvmir_dir_name) + endif() unset(_CUDA_NVCC_OUT) set(CMAKE_CUDA_DEVICE_LINKER "${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}/bin/nvlink${CMAKE_EXECUTABLE_SUFFIX}") set(CMAKE_CUDA_FATBINARY "${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}/bin/fatbinary${CMAKE_EXECUTABLE_SUFFIX}") - # In a non-scattered installation the following are equivalent to CMAKE_CUDA_COMPILER_TOOLKIT_ROOT. # We first check for a non-scattered installation to prefer it over a scattered installation. # CMAKE_CUDA_COMPILER_LIBRARY_ROOT contains the device library. - if(EXISTS "${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}/nvvm/libdevice") + if(DEFINED CMAKE_CUDA_COMPILER_LIBRARY_ROOT_FROM_NVVMIR_LIBRARY_DIR) + set(CMAKE_CUDA_COMPILER_LIBRARY_ROOT "${CMAKE_CUDA_COMPILER_LIBRARY_ROOT_FROM_NVVMIR_LIBRARY_DIR}") + elseif(EXISTS "${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}/nvvm/libdevice") set(CMAKE_CUDA_COMPILER_LIBRARY_ROOT "${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}") elseif(CMAKE_SYSROOT_LINK AND EXISTS "${CMAKE_SYSROOT_LINK}/usr/lib/cuda/nvvm/libdevice") set(CMAKE_CUDA_COMPILER_LIBRARY_ROOT "${CMAKE_SYSROOT_LINK}/usr/lib/cuda") @@ -211,6 +225,7 @@ if(NOT CMAKE_CUDA_COMPILER_ID_RUN) else() message(FATAL_ERROR "Couldn't find CUDA library root.") endif() + unset(CMAKE_CUDA_COMPILER_LIBRARY_ROOT_FROM_NVVMIR_LIBRARY_DIR) # CMAKE_CUDA_COMPILER_TOOLKIT_LIBRARY_ROOT contains the linking stubs necessary for device linking and other low-level library files. if(CMAKE_SYSROOT_LINK AND EXISTS "${CMAKE_SYSROOT_LINK}/usr/lib/nvidia-cuda-toolkit/bin/crt/link.stub") @@ -426,9 +441,10 @@ elseif(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA") if("${_nvcc_output_line}" MATCHES "^ *nvlink") string(APPEND _nvcc_log " ignoring nvlink line\n") elseif(_nvcc_libraries) - if("${_nvcc_output_line}" MATCHES "(@\"?tmp/a\\.exe\\.res\"?)") + if("${_nvcc_output_line}" MATCHES "(@\"?((tmp/)?a\\.exe\\.res)\"?)") set(_nvcc_link_res_arg "${CMAKE_MATCH_1}") - set(_nvcc_link_res "${CMAKE_PLATFORM_INFO_DIR}/CompilerIdCUDA/tmp/a.exe.res") + set(_nvcc_link_res_file "${CMAKE_MATCH_2}") + set(_nvcc_link_res "${CMAKE_PLATFORM_INFO_DIR}/CompilerIdCUDA/${_nvcc_link_res_file}") if(EXISTS "${_nvcc_link_res}") file(READ "${_nvcc_link_res}" _nvcc_link_res_content) string(REPLACE "${_nvcc_link_res_arg}" "${_nvcc_link_res_content}" _nvcc_output_line "${_nvcc_output_line}") diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index 556518f49..72dc8d3d5 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -125,11 +125,6 @@ if(NOT CMAKE_CXX_COMPILER_ID_RUN) if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(CMAKE_COMPILER_IS_GNUCXX 1) endif() - if(CMAKE_CXX_PLATFORM_ID MATCHES "MinGW") - set(CMAKE_COMPILER_IS_MINGW 1) - elseif(CMAKE_CXX_PLATFORM_ID MATCHES "Cygwin") - set(CMAKE_COMPILER_IS_CYGWIN 1) - endif() else() if(NOT DEFINED CMAKE_CXX_COMPILER_FRONTEND_VARIANT) # Some toolchain files set our internal CMAKE_CXX_COMPILER_ID_RUN diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index e564517c0..c62cb7d24 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -267,6 +267,7 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) set(CMAKE_${lang}_SIMULATE_ID "${CMAKE_${lang}_SIMULATE_ID}" PARENT_SCOPE) set(CMAKE_${lang}_SIMULATE_VERSION "${CMAKE_${lang}_SIMULATE_VERSION}" PARENT_SCOPE) set(CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT "${CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT}" PARENT_SCOPE) + set(CMAKE_${lang}_EXTENSIONS_COMPUTED_DEFAULT "${CMAKE_${lang}_EXTENSIONS_COMPUTED_DEFAULT}" PARENT_SCOPE) set(CMAKE_${lang}_COMPILER_PRODUCED_OUTPUT "${COMPILER_${lang}_PRODUCED_OUTPUT}" PARENT_SCOPE) set(CMAKE_${lang}_COMPILER_PRODUCED_FILES "${COMPILER_${lang}_PRODUCED_FILES}" PARENT_SCOPE) endfunction() @@ -319,13 +320,15 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} set(id_cl "$(CLToolExe)") elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "v[0-9]+_clang_.*") set(id_cl clang.exe) + # Executable names have been chosen according documentation + # URL: (https://software.intel.com/content/www/us/en/develop/documentation/get-started-with-dpcpp-compiler/top.html#top_GUID-A9B4C91D-97AC-450D-9742-9D895BC8AEE1) elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "Intel") if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "DPC\\+\\+ Compiler") set(id_cl dpcpp.exe) - elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "C\\+\\+ Compiler ([8-9]\\.|1[0-9]\\.|XE)") - set(id_cl icl.exe) - elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "C\\+\\+ Compiler") + elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "C\\+\\+ Compiler 2021") set(id_cl icx.exe) + elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "C\\+\\+ Compiler") + set(id_cl icl.exe) endif() else() set(id_cl cl.exe) @@ -418,6 +421,15 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} if(CMAKE_VS_PLATFORM_TOOLSET_VCTARGETS_CUSTOM_DIR) set(id_ToolsetVCTargetsDir "<VCTargetsPath>${CMAKE_VS_PLATFORM_TOOLSET_VCTARGETS_CUSTOM_DIR}</VCTargetsPath>") endif() + if(CMAKE_VS_TARGET_FRAMEWORK_VERSION) + set(id_TargetFrameworkVersion "<TargetFrameworkVersion>${CMAKE_VS_TARGET_FRAMEWORK_VERSION}</TargetFrameworkVersion>") + endif() + if(CMAKE_VS_TARGET_FRAMEWORK_IDENTIFIER) + set(id_TargetFrameworkIdentifier "<TargetFrameworkIdentifier>${CMAKE_VS_TARGET_FRAMEWORK_IDENTIFIER}</TargetFrameworkIdentifier>") + endif() + if(CMAKE_VS_TARGET_FRAMEWORK_TARGETS_VERSION) + set(id_TargetFrameworkTargetsVersion "<TargetFrameworkTargetsVersion>${CMAKE_VS_TARGET_FRAMEWORK_TARGETS_VERSION}</TargetFrameworkTargetsVersion>") + endif() set(id_CustomGlobals "") foreach(pair IN LISTS CMAKE_VS_GLOBALS) if("${pair}" MATCHES "([^=]+)=(.*)$") @@ -536,7 +548,8 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} else() set(id_toolset "") endif() - if("${lang}" STREQUAL "Swift") + set(id_lang_version "") + if("x${lang}" STREQUAL "xSwift") if(CMAKE_Swift_LANGUAGE_VERSION) set(id_lang_version "SWIFT_VERSION = ${CMAKE_Swift_LANGUAGE_VERSION};") elseif(XCODE_VERSION VERSION_GREATER_EQUAL 10.2) @@ -546,8 +559,14 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} else() set(id_lang_version "SWIFT_VERSION = 2.3;") endif() - else() - set(id_lang_version "") + elseif("x${lang}" STREQUAL "xC" OR "x${lang}" STREQUAL "xOBJC") + if(CMAKE_${lang}_COMPILER_ID_FLAGS MATCHES "(^| )(-std=[^ ]+)( |$)") + set(id_lang_version "OTHER_CFLAGS = \"${CMAKE_MATCH_2}\";") + endif() + elseif("x${lang}" STREQUAL "xCXX" OR "x${lang}" STREQUAL "xOBJCXX") + if(CMAKE_${lang}_COMPILER_ID_FLAGS MATCHES "(^| )(-std=[^ ]+)( |$)") + set(id_lang_version "OTHER_CPLUSPLUSFLAGS = \"${CMAKE_MATCH_2}\";") + endif() endif() if(CMAKE_OSX_DEPLOYMENT_TARGET) set(id_deployment_target @@ -685,7 +704,7 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} # Check the result of compilation. if(CMAKE_${lang}_COMPILER_ID_RESULT # Intel Fortran warns and ignores preprocessor lines without /fpp - OR CMAKE_${lang}_COMPILER_ID_OUTPUT MATCHES "Bad # preprocessor line" + OR CMAKE_${lang}_COMPILER_ID_OUTPUT MATCHES "warning #5117: Bad # preprocessor line" ) # Compilation failed. set(MSG @@ -696,7 +715,10 @@ ${CMAKE_${lang}_COMPILER_ID_RESULT} ${CMAKE_${lang}_COMPILER_ID_OUTPUT} ") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "${MSG}") + # Log the output unless we recognize it as a known-bad case. + if(NOT CMAKE_${lang}_COMPILER_ID_OUTPUT MATCHES "warning #5117: Bad # preprocessor line") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "${MSG}") + endif() # Some languages may know the correct/desired set of flags and want to fail right away if they don't work. # This is currently only used by CUDA. @@ -876,9 +898,12 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) if("${info}" MATCHES "INFO:qnxnto\\[\\]") set(COMPILER_QNXNTO 1) endif() - if("${info}" MATCHES "INFO:dialect_default\\[([^]\"]*)\\]") + if("${info}" MATCHES "INFO:standard_default\\[([^]\"]*)\\]") set(CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT "${CMAKE_MATCH_1}") endif() + if("${info}" MATCHES "INFO:extensions_default\\[([^]\"]*)\\]") + set(CMAKE_${lang}_EXTENSIONS_COMPUTED_DEFAULT "${CMAKE_MATCH_1}") + endif() endforeach() # Construct compiler version from components if needed. @@ -988,6 +1013,7 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) set(CMAKE_${lang}_SIMULATE_VERSION "${CMAKE_${lang}_SIMULATE_VERSION}" PARENT_SCOPE) set(COMPILER_QNXNTO "${COMPILER_QNXNTO}" PARENT_SCOPE) set(CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT "${CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT}" PARENT_SCOPE) + set(CMAKE_${lang}_EXTENSIONS_COMPUTED_DEFAULT "${CMAKE_${lang}_EXTENSIONS_COMPUTED_DEFAULT}" PARENT_SCOPE) endfunction() #----------------------------------------------------------------------------- diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake index d7d032c01..6a8984b2b 100644 --- a/Modules/CMakeDetermineFortranCompiler.cmake +++ b/Modules/CMakeDetermineFortranCompiler.cmake @@ -235,11 +235,6 @@ if(NOT CMAKE_Fortran_COMPILER_ID_RUN) if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") set(CMAKE_COMPILER_IS_GNUG77 1) endif() - if(CMAKE_Fortran_PLATFORM_ID MATCHES "MinGW") - set(CMAKE_COMPILER_IS_MINGW 1) - elseif(CMAKE_Fortran_PLATFORM_ID MATCHES "Cygwin") - set(CMAKE_COMPILER_IS_CYGWIN 1) - endif() endif() if (NOT _CMAKE_TOOLCHAIN_LOCATION) diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index 84fde49ce..6c81754d3 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -82,8 +82,7 @@ if(("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC" AND if("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xClang") set(_CMAKE_NM_NAMES "llvm-nm" "nm") list(PREPEND _CMAKE_AR_NAMES "llvm-lib") - # llvm-mt does not support all flags we need in vs_link_exe - # list(PREPEND _CMAKE_MT_NAMES "llvm-mt") + list(PREPEND _CMAKE_MT_NAMES "llvm-mt") list(PREPEND _CMAKE_LINKER_NAMES "lld-link") list(APPEND _CMAKE_TOOL_VARS NM) elseif("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xIntel") @@ -118,7 +117,7 @@ elseif("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" MATCHES "^xIAR$") endfunction() __resolve_IAR_hints("${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER}" _CMAKE_TOOLCHAIN_LOCATION) - set(_CMAKE_IAR_ITOOLS "ARM" "RX" "RH850" "RL78" "RISCV" "STM8") + set(_CMAKE_IAR_ITOOLS "ARM" "RX" "RH850" "RL78" "RISCV" "RISC-V" "STM8") set(_CMAKE_IAR_XTOOLS "AVR" "MSP430" "V850" "8051") if("${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" IN_LIST _CMAKE_IAR_ITOOLS) @@ -173,15 +172,7 @@ else() else() list(PREPEND _CMAKE_LINKER_NAMES "ld.lld") endif() - if(APPLE) - # llvm-ar does not generate a symbol table that the Apple ld64 linker accepts. - # FIXME(#23333): We still need to consider 'llvm-ar' as a fallback because - # the 'APPLE' definition may be based on the host in this context, and a - # cross-compiling toolchain may not have 'ar'. - list(APPEND _CMAKE_AR_NAMES "llvm-ar") - else() - list(PREPEND _CMAKE_AR_NAMES "llvm-ar") - endif() + list(PREPEND _CMAKE_AR_NAMES "llvm-ar") list(PREPEND _CMAKE_RANLIB_NAMES "llvm-ranlib") if("${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_VERSION}" VERSION_GREATER_EQUAL 11) # llvm-strip versions prior to 11 require additional flags we do not yet add. diff --git a/Modules/CMakeFindPackageMode.cmake b/Modules/CMakeFindPackageMode.cmake index 815dfc90d..726e2a292 100644 --- a/Modules/CMakeFindPackageMode.cmake +++ b/Modules/CMakeFindPackageMode.cmake @@ -78,7 +78,7 @@ if(UNIX) # from the outside if(NOT CMAKE_SIZEOF_VOID_P) set(CMAKE_SIZEOF_VOID_P 4) - if(EXISTS /usr/lib64) + if(EXISTS ${CMAKE_SYSROOT}/usr/lib64) set(CMAKE_SIZEOF_VOID_P 8) else() # use the file utility to check whether itself is 64 bit: diff --git a/Modules/CMakeFortranCompiler.cmake.in b/Modules/CMakeFortranCompiler.cmake.in index d474f9644..97f891e19 100644 --- a/Modules/CMakeFortranCompiler.cmake.in +++ b/Modules/CMakeFortranCompiler.cmake.in @@ -19,20 +19,11 @@ set(CMAKE_COMPILER_IS_GNUG77 @CMAKE_COMPILER_IS_GNUG77@) set(CMAKE_Fortran_COMPILER_LOADED 1) set(CMAKE_Fortran_COMPILER_WORKS @CMAKE_Fortran_COMPILER_WORKS@) set(CMAKE_Fortran_ABI_COMPILED @CMAKE_Fortran_ABI_COMPILED@) -set(CMAKE_COMPILER_IS_MINGW @CMAKE_COMPILER_IS_MINGW@) -set(CMAKE_COMPILER_IS_CYGWIN @CMAKE_COMPILER_IS_CYGWIN@) -if(CMAKE_COMPILER_IS_CYGWIN) - set(CYGWIN 1) - set(UNIX 1) -endif() set(CMAKE_Fortran_COMPILER_ENV_VAR "FC") set(CMAKE_Fortran_COMPILER_SUPPORTS_F90 @CMAKE_Fortran_COMPILER_SUPPORTS_F90@) -if(CMAKE_COMPILER_IS_MINGW) - set(MINGW 1) -endif() set(CMAKE_Fortran_COMPILER_ID_RUN 1) set(CMAKE_Fortran_SOURCE_FILE_EXTENSIONS f;F;fpp;FPP;f77;F77;f90;F90;for;For;FOR;f95;F95) set(CMAKE_Fortran_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC) diff --git a/Modules/CMakeFortranCompilerABI.F90 b/Modules/CMakeFortranCompilerABI.F90 new file mode 100644 index 000000000..4a1715331 --- /dev/null +++ b/Modules/CMakeFortranCompilerABI.F90 @@ -0,0 +1,48 @@ +program CMakeFortranCompilerABI + +implicit none + +integer :: i(1) = 0 +where (i==0) i=1 +if (any(i/=1)) stop 1 +! showing Fortran 90 syntax is OK + +#if 0 +! Address Size +#endif +#if defined(_LP64) +PRINT *, 'INFO:sizeof_dptr[8]' +#elif defined(_M_IA64) +PRINT *, 'INFO:sizeof_dptr[8]' +#elif defined(_M_X64) +PRINT *, 'INFO:sizeof_dptr[8]' +#elif defined(_M_AMD64) +PRINT *, 'INFO:sizeof_dptr[8]' +#elif defined(__x86_64__) +PRINT *, 'INFO:sizeof_dptr[8]' + +#elif defined(_ILP32) +PRINT *, 'INFO:sizeof_dptr[4]' +#elif defined(_M_IX86) +PRINT *, 'INFO:sizeof_dptr[4]' +#elif defined(__i386__) +PRINT *, 'INFO:sizeof_dptr[4]' + +#elif defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ == 8 +PRINT *, 'INFO:sizeof_dptr[8]' +#elif defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ == 4 +PRINT *, 'INFO:sizeof_dptr[4]' +#elif defined(__SIZEOF_SIZE_T__) && __SIZEOF_SIZE_T__ == 8 +PRINT *, 'INFO:sizeof_dptr[8]' +#elif defined(__SIZEOF_SIZE_T__) && __SIZEOF_SIZE_T__ == 4 +PRINT *, 'INFO:sizeof_dptr[4]' +#endif + +#if 0 +! Application Binary Interface +#endif +#if defined(__ELF__) +PRINT *, 'INFO:abi[ELF]' +#endif +PRINT *, 'ABI Detection' +end program diff --git a/Modules/CMakeFortranInformation.cmake b/Modules/CMakeFortranInformation.cmake index 9a4ce6357..0f71c6f04 100644 --- a/Modules/CMakeFortranInformation.cmake +++ b/Modules/CMakeFortranInformation.cmake @@ -157,6 +157,15 @@ if(NOT CMAKE_INCLUDE_FLAG_Fortran) set(CMAKE_INCLUDE_FLAG_Fortran ${CMAKE_INCLUDE_FLAG_C}) endif() +if(CMAKE_EXECUTABLE_FORMAT STREQUAL "ELF") + if(NOT DEFINED CMAKE_Fortran_LINK_WHAT_YOU_USE_FLAG) + set(CMAKE_Fortran_LINK_WHAT_YOU_USE_FLAG "LINKER:--no-as-needed") + endif() + if(NOT DEFINED CMAKE_LINK_WHAT_YOU_USE_CHECK) + set(CMAKE_LINK_WHAT_YOU_USE_CHECK ldd -u -r) + endif() +endif() + set(CMAKE_VERBOSE_MAKEFILE FALSE CACHE BOOL "If this value is on, makefiles will be generated without the .SILENT directive, and all commands will be echoed to the console during the make. This is useful for debugging only. With Visual Studio IDE projects all commands are done without /nologo.") set(CMAKE_Fortran_FLAGS_INIT "$ENV{FFLAGS} ${CMAKE_Fortran_FLAGS_INIT}") diff --git a/Modules/CMakeHIPCompiler.cmake.in b/Modules/CMakeHIPCompiler.cmake.in index 17633a86c..ce4e2cf65 100644 --- a/Modules/CMakeHIPCompiler.cmake.in +++ b/Modules/CMakeHIPCompiler.cmake.in @@ -2,6 +2,7 @@ set(CMAKE_HIP_COMPILER "@CMAKE_HIP_COMPILER@") set(CMAKE_HIP_COMPILER_ID "@CMAKE_HIP_COMPILER_ID@") set(CMAKE_HIP_COMPILER_VERSION "@CMAKE_HIP_COMPILER_VERSION@") set(CMAKE_HIP_STANDARD_COMPUTED_DEFAULT "@CMAKE_HIP_STANDARD_COMPUTED_DEFAULT@") +set(CMAKE_HIP_EXTENSIONS_COMPUTED_DEFAULT "@CMAKE_HIP_EXTENSIONS_COMPUTED_DEFAULT@") set(CMAKE_HIP_COMPILE_FEATURES "@CMAKE_HIP_COMPILE_FEATURES@") set(CMAKE_HIP98_COMPILE_FEATURES "@CMAKE_HIP03_COMPILE_FEATURES@") set(CMAKE_HIP11_COMPILE_FEATURES "@CMAKE_HIP11_COMPILE_FEATURES@") diff --git a/Modules/CMakeHIPCompilerId.hip.in b/Modules/CMakeHIPCompilerId.hip.in index 5258efba0..3c4a1d4be 100644 --- a/Modules/CMakeHIPCompilerId.hip.in +++ b/Modules/CMakeHIPCompilerId.hip.in @@ -16,7 +16,7 @@ char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; @CMAKE_HIP_COMPILER_ID_PLATFORM_CONTENT@ @CMAKE_HIP_COMPILER_ID_ERROR_FOR_TEST@ -const char* info_language_dialect_default = "INFO" ":" "dialect_default[" +const char* info_language_standard_default = "INFO" ":" "standard_default[" #if __cplusplus > 202002L "23" #elif __cplusplus > 201703L @@ -32,6 +32,14 @@ const char* info_language_dialect_default = "INFO" ":" "dialect_default[" #endif "]"; +const char* info_language_extensions_default = "INFO" ":" "extensions_default[" +#if (defined(__clang__) || defined(__GNUC__)) && !defined(__STRICT_ANSI__) + "ON" +#else + "OFF" +#endif +"]"; + /*--------------------------------------------------------------------------*/ int main(int argc, char* argv[]) @@ -48,7 +56,8 @@ int main(int argc, char* argv[]) #ifdef SIMULATE_VERSION_MAJOR require += info_simulate_version[argc]; #endif - require += info_language_dialect_default[argc]; + require += info_language_standard_default[argc]; + require += info_language_extensions_default[argc]; (void)argv; return require; } diff --git a/Modules/CMakeHIPInformation.cmake b/Modules/CMakeHIPInformation.cmake index 28c5f184a..4c5767767 100644 --- a/Modules/CMakeHIPInformation.cmake +++ b/Modules/CMakeHIPInformation.cmake @@ -68,6 +68,15 @@ if(NOT CMAKE_MODULE_EXISTS) set(CMAKE_SHARED_MODULE_CREATE_HIP_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_HIP_FLAGS}) endif() +if(CMAKE_EXECUTABLE_FORMAT STREQUAL "ELF") + if(NOT DEFINED CMAKE_HIP_LINK_WHAT_YOU_USE_FLAG) + set(CMAKE_HIP_LINK_WHAT_YOU_USE_FLAG "LINKER:--no-as-needed") + endif() + if(NOT DEFINED CMAKE_LINK_WHAT_YOU_USE_CHECK) + set(CMAKE_LINK_WHAT_YOU_USE_CHECK ldd -u -r) + endif() +endif() + # add the flags to the cache based # on the initial values computed in the platform/*.cmake files # use _INIT variables so that this only happens the first time diff --git a/Modules/CMakeOBJCCompiler.cmake.in b/Modules/CMakeOBJCCompiler.cmake.in index ab67bf396..36f6ec150 100644 --- a/Modules/CMakeOBJCCompiler.cmake.in +++ b/Modules/CMakeOBJCCompiler.cmake.in @@ -5,6 +5,7 @@ set(CMAKE_OBJC_COMPILER_VERSION "@CMAKE_OBJC_COMPILER_VERSION@") set(CMAKE_OBJC_COMPILER_VERSION_INTERNAL "@CMAKE_OBJC_COMPILER_VERSION_INTERNAL@") set(CMAKE_OBJC_COMPILER_WRAPPER "@CMAKE_OBJC_COMPILER_WRAPPER@") set(CMAKE_OBJC_STANDARD_COMPUTED_DEFAULT "@CMAKE_OBJC_STANDARD_COMPUTED_DEFAULT@") +set(CMAKE_OBJC_EXTENSIONS_COMPUTED_DEFAULT "@CMAKE_OBJC_EXTENSIONS_COMPUTED_DEFAULT@") set(CMAKE_OBJC_COMPILE_FEATURES "@CMAKE_OBJC_COMPILE_FEATURES@") set(CMAKE_OBJC90_COMPILE_FEATURES "@CMAKE_OBJC90_COMPILE_FEATURES@") set(CMAKE_OBJC99_COMPILE_FEATURES "@CMAKE_OBJC99_COMPILE_FEATURES@") diff --git a/Modules/CMakeOBJCCompilerId.m.in b/Modules/CMakeOBJCCompilerId.m.in index 418fd4852..89bfe02e6 100644 --- a/Modules/CMakeOBJCCompilerId.m.in +++ b/Modules/CMakeOBJCCompilerId.m.in @@ -23,23 +23,31 @@ char const* qnxnto = "INFO" ":" "qnxnto[]"; #if !defined(__STDC__) # if (defined(_MSC_VER) && !defined(__clang__)) \ || (defined(__ibmxl__) || defined(__IBMC__)) -# define C_DIALECT "90" +# define C_VERSION "90" # else -# define C_DIALECT +# define C_VERSION # endif #elif __STDC_VERSION__ > 201710L -# define C_DIALECT "23" +# define C_VERSION "23" #elif __STDC_VERSION__ >= 201710L -# define C_DIALECT "17" +# define C_VERSION "17" #elif __STDC_VERSION__ >= 201000L -# define C_DIALECT "11" +# define C_VERSION "11" #elif __STDC_VERSION__ >= 199901L -# define C_DIALECT "99" +# define C_VERSION "99" #else -# define C_DIALECT "90" +# define C_VERSION "90" #endif -const char* info_language_dialect_default = - "INFO" ":" "dialect_default[" C_DIALECT "]"; +const char* info_language_standard_default = + "INFO" ":" "standard_default[" C_VERSION "]"; + +const char* info_language_extensions_default = "INFO" ":" "extensions_default[" +#if (defined(__clang__) || defined(__GNUC__)) && !defined(__STRICT_ANSI__) + "ON" +#else + "OFF" +#endif +"]"; /*--------------------------------------------------------------------------*/ @@ -61,7 +69,8 @@ int main(int argc, char* argv[]) #ifdef SIMULATE_VERSION_MAJOR require += info_simulate_version[argc]; #endif - require += info_language_dialect_default[argc]; + require += info_language_standard_default[argc]; + require += info_language_extensions_default[argc]; (void)argv; return require; } diff --git a/Modules/CMakeOBJCInformation.cmake b/Modules/CMakeOBJCInformation.cmake index ac67d013c..4c697da3d 100644 --- a/Modules/CMakeOBJCInformation.cmake +++ b/Modules/CMakeOBJCInformation.cmake @@ -91,6 +91,15 @@ if(CMAKE_USER_MAKE_RULES_OVERRIDE_OBJC) set(CMAKE_USER_MAKE_RULES_OVERRIDE_OBJC "${_override}") endif() +if(CMAKE_EXECUTABLE_FORMAT STREQUAL "ELF") + if(NOT DEFINED CMAKE_OBJC_LINK_WHAT_YOU_USE_FLAG) + set(CMAKE_OBJC_LINK_WHAT_YOU_USE_FLAG "LINKER:--no-as-needed") + endif() + if(NOT DEFINED CMAKE_LINK_WHAT_YOU_USE_CHECK) + set(CMAKE_LINK_WHAT_YOU_USE_CHECK ldd -u -r) + endif() +endif() + # for most systems a module is the same as a shared library # so unless the variable CMAKE_MODULE_EXISTS is set just diff --git a/Modules/CMakeOBJCXXCompiler.cmake.in b/Modules/CMakeOBJCXXCompiler.cmake.in index a24582b8b..4f271003a 100644 --- a/Modules/CMakeOBJCXXCompiler.cmake.in +++ b/Modules/CMakeOBJCXXCompiler.cmake.in @@ -5,6 +5,7 @@ set(CMAKE_OBJCXX_COMPILER_VERSION "@CMAKE_OBJCXX_COMPILER_VERSION@") set(CMAKE_OBJCXX_COMPILER_VERSION_INTERNAL "@CMAKE_OBJCXX_COMPILER_VERSION_INTERNAL@") set(CMAKE_OBJCXX_COMPILER_WRAPPER "@CMAKE_OBJCXX_COMPILER_WRAPPER@") set(CMAKE_OBJCXX_STANDARD_COMPUTED_DEFAULT "@CMAKE_OBJCXX_STANDARD_COMPUTED_DEFAULT@") +set(CMAKE_OBJCXX_EXTENSIONS_COMPUTED_DEFAULT "@CMAKE_OBJCXX_EXTENSIONS_COMPUTED_DEFAULT@") set(CMAKE_OBJCXX_COMPILE_FEATURES "@CMAKE_OBJCXX_COMPILE_FEATURES@") set(CMAKE_OBJCXX98_COMPILE_FEATURES "@CMAKE_OBJCXX98_COMPILE_FEATURES@") set(CMAKE_OBJCXX11_COMPILE_FEATURES "@CMAKE_OBJCXX11_COMPILE_FEATURES@") diff --git a/Modules/CMakeOBJCXXCompilerId.mm.in b/Modules/CMakeOBJCXXCompilerId.mm.in index e2ac35d05..2145b4046 100644 --- a/Modules/CMakeOBJCXXCompilerId.mm.in +++ b/Modules/CMakeOBJCXXCompilerId.mm.in @@ -29,7 +29,7 @@ char const* qnxnto = "INFO" ":" "qnxnto[]"; #define CXX_STD __cplusplus #endif -const char* info_language_dialect_default = "INFO" ":" "dialect_default[" +const char* info_language_standard_default = "INFO" ":" "standard_default[" #if CXX_STD > 202002L "23" #elfif CXX_STD > 201703L @@ -45,6 +45,14 @@ const char* info_language_dialect_default = "INFO" ":" "dialect_default[" #endif "]"; +const char* info_language_extensions_default = "INFO" ":" "extensions_default[" +#if (defined(__clang__) || defined(__GNUC__)) && !defined(__STRICT_ANSI__) + "ON" +#else + "OFF" +#endif +"]"; + /*--------------------------------------------------------------------------*/ int main(int argc, char* argv[]) @@ -64,7 +72,8 @@ int main(int argc, char* argv[]) #ifdef SIMULATE_VERSION_MAJOR require += info_simulate_version[argc]; #endif - require += info_language_dialect_default[argc]; + require += info_language_standard_default[argc]; + require += info_language_extensions_default[argc]; (void)argv; return require; } diff --git a/Modules/CMakeOBJCXXInformation.cmake b/Modules/CMakeOBJCXXInformation.cmake index 70e8579a9..a6d824f10 100644 --- a/Modules/CMakeOBJCXXInformation.cmake +++ b/Modules/CMakeOBJCXXInformation.cmake @@ -189,6 +189,15 @@ foreach(type SHARED_LIBRARY SHARED_MODULE EXE) endif() endforeach() +if(CMAKE_EXECUTABLE_FORMAT STREQUAL "ELF") + if(NOT DEFINED CMAKE_OBJCXX_LINK_WHAT_YOU_USE_FLAG) + set(CMAKE_OBJCXX_LINK_WHAT_YOU_USE_FLAG "LINKER:--no-as-needed") + endif() + if(NOT DEFINED CMAKE_LINK_WHAT_YOU_USE_CHECK) + set(CMAKE_LINK_WHAT_YOU_USE_CHECK ldd -u -r) + endif() +endif() + # add the flags to the cache based # on the initial values computed in the platform/*.cmake files # use _INIT variables so that this only happens the first time diff --git a/Modules/CMakeSwiftInformation.cmake b/Modules/CMakeSwiftInformation.cmake index 8f0909c99..ecad1d51e 100644 --- a/Modules/CMakeSwiftInformation.cmake +++ b/Modules/CMakeSwiftInformation.cmake @@ -70,6 +70,15 @@ set(CMAKE_Swift_FLAGS_RELEASE_INIT "-O") set(CMAKE_Swift_FLAGS_RELWITHDEBINFO_INIT "-O -g") set(CMAKE_Swift_FLAGS_MINSIZEREL_INIT "-Osize") +if(CMAKE_EXECUTABLE_FORMAT STREQUAL "ELF") + if(NOT DEFINED CMAKE_Swift_LINK_WHAT_YOU_USE_FLAG) + set(CMAKE_Swift_LINK_WHAT_YOU_USE_FLAG "LINKER:--no-as-needed") + endif() + if(NOT DEFINED CMAKE_LINK_WHAT_YOU_USE_CHECK) + set(CMAKE_LINK_WHAT_YOU_USE_CHECK ldd -u -r) + endif() +endif() + cmake_initialize_per_config_variable(CMAKE_Swift_FLAGS "Swift Compiler Flags") # NOTE(compnerd) we do not have an object compile rule since we build the objects as part of the link step diff --git a/Modules/CMakeTestFortranCompiler.cmake b/Modules/CMakeTestFortranCompiler.cmake index f25788df4..579f83ff8 100644 --- a/Modules/CMakeTestFortranCompiler.cmake +++ b/Modules/CMakeTestFortranCompiler.cmake @@ -17,11 +17,18 @@ unset(CMAKE_Fortran_COMPILER_WORKS CACHE) # Try to identify the ABI and configure it into CMakeFortranCompiler.cmake include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) -CMAKE_DETERMINE_COMPILER_ABI(Fortran ${CMAKE_ROOT}/Modules/CMakeFortranCompilerABI.F) +CMAKE_DETERMINE_COMPILER_ABI(Fortran ${CMAKE_ROOT}/Modules/CMakeFortranCompilerABI.F90) if(CMAKE_Fortran_ABI_COMPILED) # The compiler worked so skip dedicated test below. set(CMAKE_Fortran_COMPILER_WORKS TRUE) + set(CMAKE_Fortran_COMPILER_SUPPORTS_F90 1) message(STATUS "Check for working Fortran compiler: ${CMAKE_Fortran_COMPILER} - skipped") +else() + cmake_determine_compiler_abi(Fortran ${CMAKE_ROOT}/Modules/CMakeFortranCompilerABI.F) + if(CMAKE_Fortran_ABI_COMPILED) + set(CMAKE_Fortran_COMPILER_WORKS TRUE) + message(STATUS "Check for working Fortran 77 compiler: ${CMAKE_Fortran_COMPILER} - skipped") + endif() endif() # This file is used by EnableLanguage in cmGlobalGenerator to diff --git a/Modules/CMakeTestHIPCompiler.cmake b/Modules/CMakeTestHIPCompiler.cmake index 5acd80624..ecbfa7fc2 100644 --- a/Modules/CMakeTestHIPCompiler.cmake +++ b/Modules/CMakeTestHIPCompiler.cmake @@ -10,7 +10,7 @@ if(CMAKE_HIP_COMPILER_FORCED) endif() set(__CMAKE_HIP_FLAGS "${CMAKE_HIP_FLAGS}") -string(APPEND CMAKE_HIP_FLAGS "--cuda-host-only") +string(APPEND CMAKE_HIP_FLAGS " --cuda-host-only") include(CMakeTestCompilerCommon) diff --git a/Modules/CPackIFW.cmake b/Modules/CPackIFW.cmake index 2e68770a5..85108db41 100644 --- a/Modules/CPackIFW.cmake +++ b/Modules/CPackIFW.cmake @@ -439,6 +439,7 @@ set(_CPACK_IFW_PREFIXES "QtIFW-") set(_CPACK_IFW_VERSIONS + "4.2" "4.1" "4.0" "3.2" diff --git a/Modules/CheckCXXSymbolExists.cmake b/Modules/CheckCXXSymbolExists.cmake index b4da4fac8..7b13c3aa3 100644 --- a/Modules/CheckCXXSymbolExists.cmake +++ b/Modules/CheckCXXSymbolExists.cmake @@ -25,7 +25,7 @@ Check if a symbol exists as a function, variable, or macro in ``C++``. as a function or variable then the symbol must also be available for linking. If the symbol is a type, enum value, or C++ template it will not be recognized: consider using the :module:`CheckTypeSize` - or :module:`CheckCXXSourceCompiles` module instead. + or :module:`CheckSourceCompiles` module instead. .. note:: diff --git a/Modules/CheckFortranFunctionExists.cmake b/Modules/CheckFortranFunctionExists.cmake index ad72e2f09..8f1ca9dd3 100644 --- a/Modules/CheckFortranFunctionExists.cmake +++ b/Modules/CheckFortranFunctionExists.cmake @@ -20,6 +20,12 @@ Check if a Fortran function exists. ``<result>`` variable to store the result; will be created as an internal cache variable. +.. note:: + + This command does not detect functions in Fortran modules. In general it is + recommended to use :module:`CheckSourceCompiles` instead to determine if a + Fortran function or subroutine is available. + The following variables may be set before calling this macro to modify the way the check is run: diff --git a/Modules/CheckLanguage.cmake b/Modules/CheckLanguage.cmake index 559c103e8..52f707c00 100644 --- a/Modules/CheckLanguage.cmake +++ b/Modules/CheckLanguage.cmake @@ -46,7 +46,7 @@ macro(check_language lang) file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Check${lang}) set(extra_compiler_variables) - if(${lang} STREQUAL CUDA) + if(${lang} STREQUAL CUDA AND NOT CMAKE_GENERATOR MATCHES "Visual Studio") set(extra_compiler_variables "set(CMAKE_CUDA_HOST_COMPILER \\\"\${CMAKE_CUDA_HOST_COMPILER}\\\")") endif() diff --git a/Modules/CheckLinkerFlag.cmake b/Modules/CheckLinkerFlag.cmake index 28ac2e32e..e85e43e9b 100644 --- a/Modules/CheckLinkerFlag.cmake +++ b/Modules/CheckLinkerFlag.cmake @@ -41,6 +41,10 @@ include_guard(GLOBAL) include(CMakeCheckCompilerFlagCommonPatterns) +cmake_policy(PUSH) +cmake_policy(SET CMP0054 NEW) # if() quoted variables not dereferenced +cmake_policy(SET CMP0057 NEW) # if() supports IN_LIST + function(CHECK_LINKER_FLAG _lang _flag _var) get_property (_supported_languages GLOBAL PROPERTY ENABLED_LANGUAGES) if (NOT _lang IN_LIST _supported_languages) @@ -82,3 +86,5 @@ function(CHECK_LINKER_FLAG _lang _flag _var) endforeach() set(${_var} "${${_var}}" PARENT_SCOPE) endfunction() + +cmake_policy(POP) diff --git a/Modules/CheckSymbolExists.cmake b/Modules/CheckSymbolExists.cmake index f8ca58402..48ee3c477 100644 --- a/Modules/CheckSymbolExists.cmake +++ b/Modules/CheckSymbolExists.cmake @@ -24,7 +24,7 @@ available and assumed to work. If the header files declare the symbol as a function or variable then the symbol must also be available for linking (so intrinsics may not be detected). If the symbol is a type, enum value, or intrinsic it will not be recognized -(consider using :module:`CheckTypeSize` or :module:`CheckCSourceCompiles`). +(consider using :module:`CheckTypeSize` or :module:`CheckSourceCompiles`). If the check needs to be done in C++, consider using :module:`CheckCXXSymbolExists` instead. diff --git a/Modules/Compiler/ARMClang-C.cmake b/Modules/Compiler/ARMClang-C.cmake index 0a64a8a4f..01c4cea08 100644 --- a/Modules/Compiler/ARMClang-C.cmake +++ b/Modules/Compiler/ARMClang-C.cmake @@ -2,6 +2,14 @@ include(Compiler/Clang-C) include(Compiler/ARMClang) __compiler_armclang(C) +if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) + AND CMAKE_GENERATOR MATCHES "Makefiles|WMake" + AND CMAKE_DEPFILE_FLAGS_C) + # dependencies are computed by the compiler itself + set(CMAKE_C_DEPFILE_FORMAT gcc) + set(CMAKE_C_DEPENDS_USE_COMPILER TRUE) +endif() + set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90") set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) diff --git a/Modules/Compiler/ARMClang-CXX.cmake b/Modules/Compiler/ARMClang-CXX.cmake index 5dfb4011e..045b78311 100644 --- a/Modules/Compiler/ARMClang-CXX.cmake +++ b/Modules/Compiler/ARMClang-CXX.cmake @@ -1,3 +1,11 @@ include(Compiler/Clang-CXX) include(Compiler/ARMClang) __compiler_armclang(CXX) + +if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) + AND CMAKE_GENERATOR MATCHES "Makefiles|WMake" + AND CMAKE_DEPFILE_FLAGS_CXX) + # dependencies are computed by the compiler itself + set(CMAKE_CXX_DEPFILE_FORMAT gcc) + set(CMAKE_CXX_DEPENDS_USE_COMPILER TRUE) +endif() diff --git a/Modules/Compiler/AppleClang-CXX.cmake b/Modules/Compiler/AppleClang-CXX.cmake index 7c979697a..28be1dfd5 100644 --- a/Modules/Compiler/AppleClang-CXX.cmake +++ b/Modules/Compiler/AppleClang-CXX.cmake @@ -47,17 +47,9 @@ if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0) set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON) endif() -if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13.0) - set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std=c++20") - set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std=gnu++20") -elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0) +if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0) set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std=c++2a") set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std=gnu++2a") endif() -if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13.0) - set(CMAKE_CXX23_STANDARD_COMPILE_OPTION "-std=c++2b") - set(CMAKE_CXX23_EXTENSION_COMPILE_OPTION "-std=gnu++2b") -endif() - __compiler_check_default_language_standard(CXX 4.0 98) diff --git a/Modules/Compiler/CMakeCommonCompilerMacros.cmake b/Modules/Compiler/CMakeCommonCompilerMacros.cmake index c86af98f8..2f220d466 100644 --- a/Modules/Compiler/CMakeCommonCompilerMacros.cmake +++ b/Modules/Compiler/CMakeCommonCompilerMacros.cmake @@ -38,20 +38,26 @@ macro(__compiler_check_default_language_standard lang stdver1 std1) # support for language standards, then don't bother. if (CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL "${stdver1}") if (NOT CMAKE_${lang}_COMPILER_FORCED) - if (NOT CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT) - message(FATAL_ERROR "CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT should be set for ${CMAKE_${lang}_COMPILER_ID} (${CMAKE_${lang}_COMPILER}) version ${CMAKE_${lang}_COMPILER_VERSION}") + if (NOT CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT OR NOT DEFINED CMAKE_${lang}_EXTENSIONS_COMPUTED_DEFAULT) + message(FATAL_ERROR "CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT and CMAKE_${lang}_EXTENSIONS_COMPUTED_DEFAULT should be set for ${CMAKE_${lang}_COMPILER_ID} (${CMAKE_${lang}_COMPILER}) version ${CMAKE_${lang}_COMPILER_VERSION}") endif () set(CMAKE_${lang}_STANDARD_DEFAULT ${CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT}) + set(CMAKE_${lang}_EXTENSIONS_DEFAULT ${CMAKE_${lang}_EXTENSIONS_COMPUTED_DEFAULT}) else () list(REVERSE __std_ver_pairs) foreach (__std_ver_pair IN LISTS __std_ver_pairs) string(REGEX MATCH "([^ ]+) (.+)" __std_ver_pair "${__std_ver_pair}") set(__stdver ${CMAKE_MATCH_1}) set(__std ${CMAKE_MATCH_2}) - if (CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL __stdver AND - NOT DEFINED CMAKE_${lang}_STANDARD_DEFAULT) - # Compiler id was forced so just guess the default standard level. - set(CMAKE_${lang}_STANDARD_DEFAULT ${__std}) + # Compiler id was forced so just guess the defaults. + if (CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL __stdver) + if(NOT DEFINED CMAKE_${lang}_EXTENSIONS_DEFAULT) + # Currently known compilers default to enabling extensions. + set(CMAKE_${lang}_EXTENSIONS_DEFAULT ON) + endif() + if(NOT DEFINED CMAKE_${lang}_STANDARD_DEFAULT) + set(CMAKE_${lang}_STANDARD_DEFAULT ${__std}) + endif() endif () unset(__std) unset(__stdver) diff --git a/Modules/Compiler/Clang-C.cmake b/Modules/Compiler/Clang-C.cmake index cf493d720..1b765ad14 100644 --- a/Modules/Compiler/Clang-C.cmake +++ b/Modules/Compiler/Clang-C.cmake @@ -9,6 +9,7 @@ endif() if("x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC") set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -TC) set(CMAKE_C_CLANG_TIDY_DRIVER_MODE "cl") + set(CMAKE_C_INCLUDE_WHAT_YOU_USE_DRIVER_MODE "cl") if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) AND CMAKE_GENERATOR MATCHES "Makefiles|WMake" AND CMAKE_DEPFILE_FLAGS_C) diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake index 98828e011..84b05d7f0 100644 --- a/Modules/Compiler/Clang-CXX.cmake +++ b/Modules/Compiler/Clang-CXX.cmake @@ -22,6 +22,7 @@ endif() if("x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC") set(CMAKE_CXX_CLANG_TIDY_DRIVER_MODE "cl") + set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE_DRIVER_MODE "cl") if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) AND CMAKE_GENERATOR MATCHES "Makefiles" AND CMAKE_DEPFILE_FLAGS_CXX) diff --git a/Modules/Compiler/IAR-ASM.cmake b/Modules/Compiler/IAR-ASM.cmake index e3ca16edc..bae0fbd8c 100644 --- a/Modules/Compiler/IAR-ASM.cmake +++ b/Modules/Compiler/IAR-ASM.cmake @@ -1,57 +1,45 @@ -# This file is processed when the IAR compiler is used for an assembler file +# This file is processed when the IAR Assembler is used include(Compiler/IAR) -if("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM") - set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -S <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>") - __compiler_iar_ilink(ASM) - set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;asm;msa) +cmake_policy(PUSH) +cmake_policy(SET CMP0057 NEW) # if IN_LIST -elseif("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "RX") - set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>") - __compiler_iar_ilink(ASM) - set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;asm;msa) +set(_CMAKE_IAR_ITOOLS "ARM" "RH850" "RL78" "RX" "RISC-V" "STM8") +set(_CMAKE_IAR_XTOOLS "AVR" "MSP430" "V850" "8051") -elseif("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "RH850") - set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>") - __compiler_iar_ilink(ASM) - set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;asm;msa) - -elseif("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "RL78") - set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>") - __compiler_iar_ilink(ASM) - set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;asm;msa) - -elseif("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "RISC-V") - set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>") - __compiler_iar_ilink(ASM) - set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;asm;msa) +set(_CMAKE_IAR_ASM_SILENT "RH850" "RL78" "RX" "RISC-V" "STM8") +if("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" IN_LIST _CMAKE_IAR_ASM_SILENT) + set(_CMAKE_IAR_SILENCER_FLAG " --silent") +else() + set(_CMAKE_IAR_SILENCER_FLAG " -S") +endif() -elseif("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR") - set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -S <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>") - __compiler_iar_xlink(ASM) - set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s90;asm;msa) +string(APPEND CMAKE_ASM_FLAGS_INIT " ") +string(APPEND CMAKE_ASM_FLAGS_DEBUG_INIT " -r") +string(APPEND CMAKE_ASM_FLAGS_MINSIZEREL_INIT " -DNDEBUG") +string(APPEND CMAKE_ASM_FLAGS_RELEASE_INIT " -DNDEBUG") +string(APPEND CMAKE_ASM_FLAGS_RELWITHDEBINFO_INIT " -r -DNDEBUG") -elseif("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "MSP430") - set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -S <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>") - __compiler_iar_xlink(ASM) - set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s43;asm;msa) +set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> ${_CMAKE_IAR_SILENCER_FLAG} <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>") -elseif("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "V850") - set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -S <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>") - __compiler_iar_xlink(ASM) - set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s85;asm;msa) +if("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" IN_LIST _CMAKE_IAR_ITOOLS) + __compiler_iar_ilink(ASM) + set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;asm;msa;S) -elseif("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "8051") - set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -S <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>") +elseif("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" IN_LIST _CMAKE_IAR_XTOOLS) __compiler_iar_xlink(ASM) - set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s51;asm;msa) - -elseif("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "STM8") - set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>") - __compiler_iar_ilink(ASM) - set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;asm;msa) + # AVR=s90, MSP430=s43, V850=s85, 8051=s51 + set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s90;s43;s85;s51;asm;msa) else() message(FATAL_ERROR "CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID not detected. This should be automatic.") + endif() + +unset(_CMAKE_IAR_ITOOLS) +unset(_CMAKE_IAR_XTOOLS) +unset(_CMAKE_IAR_ASM_SILENT) +unset(_CMAKE_IAR_SILENCER_FLAG) + +cmake_policy(POP) diff --git a/Modules/Compiler/IAR-C.cmake b/Modules/Compiler/IAR-C.cmake index 054ee74c1..0ef1a2a85 100644 --- a/Modules/Compiler/IAR-C.cmake +++ b/Modules/Compiler/IAR-C.cmake @@ -1,54 +1,61 @@ -# This file is processed when the IAR compiler is used for a C file - +# This file is processed when the IAR C Compiler is used +# +# C Language Specification support +# - Newer versions of the IAR C Compiler require the --c89 flag to build a file under the C90 standard. +# - Earlier versions of the compiler had C90 by default, not requiring the backward-compatibility flag. +# +# The IAR Language Extensions +# - The IAR Language Extensions can be enabled by -e flag +# include(Compiler/IAR) include(Compiler/CMakeCommonCompilerMacros) -# Common -if(NOT CMAKE_C_COMPILER_VERSION) +if(NOT DEFINED CMAKE_C_COMPILER_VERSION) message(FATAL_ERROR "CMAKE_C_COMPILER_VERSION not detected. This should be automatic.") endif() +# Unused after CMP0128 set(CMAKE_C_EXTENSION_COMPILE_OPTION -e) if(CMAKE_C_COMPILER_VERSION_INTERNAL VERSION_GREATER 7) set(CMAKE_C90_STANDARD_COMPILE_OPTION --c89) set(CMAKE_C90_EXTENSION_COMPILE_OPTION --c89 -e) - set(CMAKE_C99_STANDARD_COMPILE_OPTION "") - set(CMAKE_C99_EXTENSION_COMPILE_OPTION -e) else() set(CMAKE_C90_STANDARD_COMPILE_OPTION "") set(CMAKE_C90_EXTENSION_COMPILE_OPTION -e) endif() -if(CMAKE_C_COMPILER_VERSION_INTERNAL VERSION_GREATER 8) - set(CMAKE_C11_STANDARD_COMPILE_OPTION "") - set(CMAKE_C11_EXTENSION_COMPILE_OPTION -e) -endif() +set(CMAKE_C${CMAKE_C_STANDARD_COMPUTED_DEFAULT}_STANDARD_COMPILE_OPTION "") +set(CMAKE_C${CMAKE_C_STANDARD_COMPUTED_DEFAULT}_EXTENSION_COMPILE_OPTION -e) # Architecture specific if("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM") - if(CMAKE_C_COMPILER_VERSION_INTERNAL VERSION_LESS 7) - # IAR ARM 4.X uses xlink.exe, detection is not yet implemented - message(FATAL_ERROR "CMAKE_C_COMPILER_VERSION = ${CMAKE_C_COMPILER_VERSION} not supported by CMake.") + if (CMAKE_C_COMPILER_VERSION VERSION_LESS 5) + # IAR C Compiler for Arm prior version 5.xx uses XLINK. Support in CMake is not implemented. + message(FATAL_ERROR "IAR C Compiler for Arm version ${CMAKE_C_COMPILER_VERSION} not supported by CMake.") endif() __compiler_iar_ilink(C) - __compiler_check_default_language_standard(C 1.10 90 6.10 99 8.10 11) + __compiler_check_default_language_standard(C 5.10 90 6.10 99 8.10 11 8.40 17) elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "RX") __compiler_iar_ilink(C) - __compiler_check_default_language_standard(C 1.10 90 2.10 99 4.10 11) + __compiler_check_default_language_standard(C 1.10 90 2.10 99 4.10 11 4.20 17) elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "RH850") __compiler_iar_ilink(C) - __compiler_check_default_language_standard(C 1.10 90 1.10 99 2.10 11) + __compiler_check_default_language_standard(C 1.10 90 1.10 99 2.10 11 2.21 17) elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "RL78") + if(CMAKE_C_COMPILER_VERSION VERSION_LESS 2) + # IAR C Compiler for RL78 prior version 2.xx uses XLINK. Support in CMake is not implemented. + message(FATAL_ERROR "IAR C Compiler for RL78 version ${CMAKE_C_COMPILER_VERSION} not supported by CMake.") + endif() __compiler_iar_ilink(C) - __compiler_check_default_language_standard(C 1.10 90 1.10 99 4.10 11) + __compiler_check_default_language_standard(C 2.10 90 2.10 99 4.10 11 4.20 17) elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "RISCV") __compiler_iar_ilink(C) - __compiler_check_default_language_standard(C 1.10 90 1.10 99 1.10 11) + __compiler_check_default_language_standard(C 1.10 90 1.10 99 1.10 11 1.21 17) elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR") __compiler_iar_xlink(C) diff --git a/Modules/Compiler/IAR-CXX.cmake b/Modules/Compiler/IAR-CXX.cmake index d93b27289..a3f1dbc29 100644 --- a/Modules/Compiler/IAR-CXX.cmake +++ b/Modules/Compiler/IAR-CXX.cmake @@ -1,63 +1,65 @@ -# This file is processed when the IAR compiler is used for a C++ file - +# This file is processed when the IAR C++ Compiler is used +# +# C++ Language Specification support +# - Newer versions of the IAR C++ Compiler require the --c++ flag to build a C++ file. +# Earlier versions for non-ARM architectures provided Embedded C++, enabled with the --eec++ flag. +# +# The IAR Language Extensions +# - The IAR Language Extensions can be enabled by -e flag +# include(Compiler/IAR) include(Compiler/CMakeCommonCompilerMacros) -# Common -if(NOT CMAKE_CXX_COMPILER_VERSION) +if(NOT DEFINED CMAKE_CXX_COMPILER_VERSION) message(FATAL_ERROR "CMAKE_CXX_COMPILER_VERSION not detected. This should be automatic.") endif() +# Whenever needed, override this default behavior using CMAKE_IAR_CXX_FLAG in your toolchain file. if(NOT CMAKE_IAR_CXX_FLAG) - # The --c++ flag was introduced in platform version 9 for all architectures except ARM where it was introduced already in version 7 - if(CMAKE_CXX_COMPILER_VERSION_INTERNAL VERSION_GREATER 8 OR - (CMAKE_CXX_COMPILER_VERSION_INTERNAL VERSION_GREATER 6 AND "${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM") ) - set(CMAKE_IAR_CXX_FLAG --c++) + set(_CMAKE_IAR_MODERNCXX_LIST 14 17) + if(${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT} IN_LIST _CMAKE_IAR_MODERNCXX_LIST OR + ("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM" AND ${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT} EQUAL 98)) + string(PREPEND CMAKE_CXX_FLAGS "--c++ ") else() - set(CMAKE_IAR_CXX_FLAG --eec++) + string(PREPEND CMAKE_CXX_FLAGS "--eec++ ") endif() + unset(_CMAKE_IAR_MODERNCXX_LIST) endif() -set(CMAKE_CXX_EXTENSION_COMPILE_OPTION -e) +set(CMAKE_CXX_STANDARD_COMPILE_OPTION "") +set(CMAKE_CXX_EXTENSION_COMPILE_OPTION -e) # Unused after CMP0128 -if(CMAKE_CXX_COMPILER_VERSION_INTERNAL VERSION_GREATER 7) - set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "") - set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION -e) - set(CMAKE_CXX03_STANDARD_COMPILE_OPTION "") - set(CMAKE_CXX03_EXTENSION_COMPILE_OPTION -e) -endif() - -if(CMAKE_CXX_COMPILER_VERSION_INTERNAL VERSION_GREATER 8) - set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "") - set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION -e) - set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "") - set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION -e) -endif() +set(CMAKE_CXX${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT}_STANDARD_COMPILE_OPTION "") +set(CMAKE_CXX${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT}_EXTENSION_COMPILE_OPTION -e) # Architecture specific if("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM") - if(CMAKE_CXX_COMPILER_VERSION_INTERNAL VERSION_LESS 7) - # IAR ARM 4.X uses xlink.exe, detection is not yet implemented - message(FATAL_ERROR "CMAKE_CXX_COMPILER_VERSION = ${CMAKE_C_COMPILER_VERSION} not supported by CMake.") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5) + # IAR C++ Compiler for Arm prior version 5.xx uses XLINK. Support in CMake is not implemented. + message(FATAL_ERROR "IAR C++ Compiler for Arm version ${CMAKE_CXX_COMPILER_VERSION} not supported by CMake.") endif() __compiler_iar_ilink(CXX) - __compiler_check_default_language_standard(CXX 6.10 98 8.10 14) + __compiler_check_default_language_standard(CXX 5.10 98 8.10 14 8.40 17) elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "RX") __compiler_iar_ilink(CXX) - __compiler_check_default_language_standard(CXX 2.10 98 4.10 14) + __compiler_check_default_language_standard(CXX 2.10 98 4.10 14 4.20 17) elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "RH850") __compiler_iar_ilink(CXX) - __compiler_check_default_language_standard(CXX 1.10 98 2.10 14) + __compiler_check_default_language_standard(CXX 1.10 98 2.10 14 2.21 17) elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "RL78") + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2) + # # IAR C++ Compiler for RL78 prior version 2.xx uses XLINK. Support in CMake is not implemented. + message(FATAL_ERROR "IAR C++ Compiler for RL78 version ${CMAKE_CXX_COMPILER_VERSION} not supported by CMake.") + endif() __compiler_iar_ilink(CXX) - __compiler_check_default_language_standard(CXX 1.10 98 4.10 14) + __compiler_check_default_language_standard(CXX 2.10 98 4.10 14 4.20 17) elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "RISCV") __compiler_iar_ilink(CXX) - __compiler_check_default_language_standard(CXX 1.10 98 1.10 14) + __compiler_check_default_language_standard(CXX 1.10 98 1.10 14 1.21 17) elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR") __compiler_iar_xlink(CXX) diff --git a/Modules/Compiler/IAR-DetermineCompiler.cmake b/Modules/Compiler/IAR-DetermineCompiler.cmake index 443b09c32..b03fd1faa 100644 --- a/Modules/Compiler/IAR-DetermineCompiler.cmake +++ b/Modules/Compiler/IAR-DetermineCompiler.cmake @@ -1,28 +1,26 @@ -# IAR Systems compiler for ARM embedded systems. -# http://www.iar.com -# http://supp.iar.com/FilesPublic/UPDINFO/004916/arm/doc/EWARM_DevelopmentGuide.ENU.pdf +# IAR C/C++ Compiler (https://www.iar.com) +# CPU <arch> supported in CMake: 8051, Arm, AVR, MSP430, RH850, RISC-V, RL78, RX and V850 # -# __IAR_SYSTEMS_ICC__ An integer that identifies the IAR compiler platform: -# 9 and higher means C11 and C++14 as language default -# 8 means C99 and C++03 as language default -# 7 and lower means C89 and EC++ as language default. -# __ICCARM__ An integer that is set to 1 when the code is compiled with the IAR C/C++ Compiler for ARM -# __VER__ An integer that identifies the version number of the IAR compiler in use. For example, -# version 5.11.3 is returned as 5011003. +# IAR C/C++ Compiler for <arch> internal integer symbols used in CMake: # -# IAR Systems Compiler for AVR embedded systems -# http://supp.iar.com/FilesPublic/UPDINFO/007051/ew/doc/EWAVR_CompilerReference.pdf +# __IAR_SYSTEMS_ICC__ +# Provides the compiler internal platform version +# __ICC<arch>__ +# Provides 1 for the current <arch> in use +# __VER__ +# Provides the current version in use +# The semantic version of the compiler is architecture-dependent +# When <arch> is ARM: +# CMAKE_<LANG>_COMPILER_VERSION_MAJOR = (__VER__ / 1E6) +# CMAKE_<LANG>_COMPILER_VERSION_MINOR = (__VER__ / 1E3) % 1E3 +# CMAKE_<LANG>_COMPILER_VERSION_PATCH = (__VER__ % 1E3) +# When <arch> is non-ARM: +# CMAKE_<LANG>_COMPILER_VERSION_MAJOR = (__VER__ / 1E2) +# CMAKE_<LANG>_COMPILER_VERSION_MINOR = (__VER__ - ((__VER__/ 1E2) * 1E2)) +# CMAKE_<LANG>_COMPILER_VERSION_PATCH = (__SUBVERSION__) +# __SUBVERSION__ +# Provides the version's patch level for non-ARM <arch> # -# __IAR_SYSTEMS_ICC__ An integer that identifies the IAR compiler platform. -# __ICCAVR__ An integer that is set to 1 when the code is compiled with the IAR C/C++ Compiler for AVR -# __VER__ An integer that identifies the version number of the IAR compiler in use. -# The value is calculated by (100 * VERSION_MAJOR + VERSION_MINOR). For example the version -# 3.34 is given as 334 -# __SUBVERSION__ An integer that identifies the subversion number of the compiler version number -# for example 3 in 1.2.3.4. THis is used as the patch version, as seen when running iccavr -# from the command line -# - set(_compiler_id_pp_test "defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)") set(_compiler_id_version_compute " diff --git a/Modules/Compiler/IAR.cmake b/Modules/Compiler/IAR.cmake index 2200a21a7..53456f5c3 100644 --- a/Modules/Compiler/IAR.cmake +++ b/Modules/Compiler/IAR.cmake @@ -1,47 +1,15 @@ -# This file is processed when the IAR compiler is used for a C or C++ file -# Documentation can be downloaded here: http://www.iar.com/website1/1.0.1.0/675/1/ -# The initial feature request is here: https://gitlab.kitware.com/cmake/cmake/-/issues/10176 -# It also contains additional links and information. -# See USER GUIDES -> C/C++ Development Guide and ReleaseNotes for EWARM: -# version 6.30.8: http://supp.iar.com/FilesPublic/UPDINFO/006607/arm/doc/infocenter/index.ENU.html -# version 7.60.1: http://supp.iar.com/FilesPublic/UPDINFO/011006/arm/doc/infocenter/index.ENU.html -# version 8.10.1: http://netstorage.iar.com/SuppDB/Public/UPDINFO/011854/arm/doc/infocenter/index.ENU.html - -# The IAR internal compiler platform generations (Predefined symbol __IAR_SYSTEMS_ICC__): -# 9 and higher means C11 and C++14 as language default (EWARM v8.x, EWRX v4.x and higher) -# 8 means C99 and C++03 as language default (EWARM v6.x, v7.x. EWRX v2.x, 3.x) -# 7 and lower means C89 and EC++ as language default. (EWARM v5.x and lower) - -# C/C++ Standard versions -# -# IAR typically only supports one C and C++ Standard version, -# the exception is C89 which is always supported and can be selected -# if its not the default -# -# C++ is trickier, there were historically 3 switches, -# and some IAR versions support multiple of those. -# they are --eec++, --ec++ and --c++ and where used to -# enable various language features like exceptions -# -# recent versions only have --c++ for full support -# but can choose to disable features with further arguments +# This file is processed when the IAR C/C++ Compiler is used # -# C/C++ Standard compliance +# CPU <arch> supported in CMake: 8051, Arm, AVR, MSP430, RH850, RISC-V, RL78, RX and V850 # -# IAR has 3 modes: default, strict and extended -# the extended mode is needed for popular libraries like CMSIS +# The compiler user documentation is architecture-dependent +# and it can found with the product installation under <arch>/doc/{EW,BX}<arch>_DevelopmentGuide.ENU.pdf # -# "Silent" Operation # -# this really is different to most programs I know. -# nothing meaningful from the operation is lost, just some redundant -# code and data size printouts (that can be inspected with common tools). - -# This module is shared by multiple languages; use include blocker. include_guard() macro(__compiler_iar_ilink lang) - set(CMAKE_EXECUTABLE_SUFFIX_${lang} ".elf") + set(CMAKE_EXECUTABLE_SUFFIX ".elf") set(CMAKE_${lang}_OUTPUT_EXTENSION ".o") if (${lang} STREQUAL "C" OR ${lang} STREQUAL "CXX") set(CMAKE_${lang}_COMPILE_OBJECT "<CMAKE_${lang}_COMPILER> ${CMAKE_IAR_${lang}_FLAG} --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>") @@ -58,14 +26,6 @@ macro(__compiler_iar_ilink lang) string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -Oh -r -DNDEBUG") endif() - if (${lang} STREQUAL "ASM") - string(APPEND CMAKE_ASM_FLAGS_INIT " ") - string(APPEND CMAKE_ASM_FLAGS_DEBUG_INIT " -r") - string(APPEND CMAKE_ASM_FLAGS_MINSIZEREL_INIT " -DNDEBUG") - string(APPEND CMAKE_ASM_FLAGS_RELEASE_INIT " -DNDEBUG") - string(APPEND CMAKE_ASM_FLAGS_RELWITHDEBINFO_INIT " -r -DNDEBUG") - endif() - set(CMAKE_${lang}_LINK_EXECUTABLE "<CMAKE_LINKER> --silent <OBJECTS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>") set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "<CMAKE_AR> <TARGET> --create <LINK_FLAGS> <OBJECTS>") set(CMAKE_${lang}_ARCHIVE_CREATE "<CMAKE_AR> <TARGET> --create <LINK_FLAGS> <OBJECTS>") @@ -74,7 +34,7 @@ macro(__compiler_iar_ilink lang) endmacro() macro(__compiler_iar_xlink lang) - set(CMAKE_EXECUTABLE_SUFFIX_${lang} ".bin") + set(CMAKE_EXECUTABLE_SUFFIX ".bin") if (${lang} STREQUAL "C" OR ${lang} STREQUAL "CXX") set(CMAKE_${lang}_COMPILE_OBJECT "<CMAKE_${lang}_COMPILER> ${CMAKE_IAR_${lang}_FLAG} --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>") @@ -91,14 +51,6 @@ macro(__compiler_iar_xlink lang) string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -Oh -r -DNDEBUG") endif() - if (${lang} STREQUAL "ASM") - string(APPEND CMAKE_ASM_FLAGS_INIT " ") - string(APPEND CMAKE_ASM_FLAGS_DEBUG_INIT " -r") - string(APPEND CMAKE_ASM_FLAGS_MINSIZEREL_INIT " -DNDEBUG") - string(APPEND CMAKE_ASM_FLAGS_RELEASE_INIT " -DNDEBUG") - string(APPEND CMAKE_ASM_FLAGS_RELWITHDEBINFO_INIT " -r -DNDEBUG") - endif() - set(CMAKE_${lang}_LINK_EXECUTABLE "<CMAKE_LINKER> -S <OBJECTS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>") set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "<CMAKE_AR> <TARGET> <LINK_FLAGS> <OBJECTS>") set(CMAKE_${lang}_ARCHIVE_CREATE "<CMAKE_AR> <TARGET> <LINK_FLAGS> <OBJECTS>") diff --git a/Modules/Compiler/Intel-C.cmake b/Modules/Compiler/Intel-C.cmake index ead9069f3..9884b58c3 100644 --- a/Modules/Compiler/Intel-C.cmake +++ b/Modules/Compiler/Intel-C.cmake @@ -17,6 +17,7 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC") set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -TC) set(CMAKE_C_CLANG_TIDY_DRIVER_MODE "cl") + set(CMAKE_C_INCLUDE_WHAT_YOU_USE_DRIVER_MODE "cl") if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 16.0.0) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-Qstd=c11") diff --git a/Modules/Compiler/Intel-CXX.cmake b/Modules/Compiler/Intel-CXX.cmake index 37f339a77..7c9cca97e 100644 --- a/Modules/Compiler/Intel-CXX.cmake +++ b/Modules/Compiler/Intel-CXX.cmake @@ -16,6 +16,7 @@ endif() if("x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") set(CMAKE_CXX_CLANG_TIDY_DRIVER_MODE "cl") + set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE_DRIVER_MODE "cl") if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0.0) set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-Qstd=c++20") diff --git a/Modules/Compiler/IntelLLVM-C.cmake b/Modules/Compiler/IntelLLVM-C.cmake index d69d06477..d7346f62b 100644 --- a/Modules/Compiler/IntelLLVM-C.cmake +++ b/Modules/Compiler/IntelLLVM-C.cmake @@ -4,6 +4,7 @@ __compiler_intel_llvm(C) if("x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC") set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -TC) set(CMAKE_C_CLANG_TIDY_DRIVER_MODE "cl") + set(CMAKE_C_INCLUDE_WHAT_YOU_USE_DRIVER_MODE "cl") if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) AND CMAKE_GENERATOR MATCHES "Makefiles|WMake" AND CMAKE_DEPFILE_FLAGS_C) diff --git a/Modules/Compiler/IntelLLVM-CXX.cmake b/Modules/Compiler/IntelLLVM-CXX.cmake index 979988846..cae1f1199 100644 --- a/Modules/Compiler/IntelLLVM-CXX.cmake +++ b/Modules/Compiler/IntelLLVM-CXX.cmake @@ -4,6 +4,7 @@ __compiler_intel_llvm(CXX) if("x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC") set(CMAKE_CXX_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -TP) set(CMAKE_CXX_CLANG_TIDY_DRIVER_MODE "cl") + set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE_DRIVER_MODE "cl") if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) AND CMAKE_GENERATOR MATCHES "Makefiles|WMake" AND CMAKE_DEPFILE_FLAGS_CXX) diff --git a/Modules/Compiler/MSVC-C.cmake b/Modules/Compiler/MSVC-C.cmake index 9a5104bd9..a53df4664 100644 --- a/Modules/Compiler/MSVC-C.cmake +++ b/Modules/Compiler/MSVC-C.cmake @@ -11,6 +11,22 @@ if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.27) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std:c11") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std:c11") + if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.28) + set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_C17_STANDARD_COMPILE_OPTION "-std:c17") + set(CMAKE_C17_EXTENSION_COMPILE_OPTION "-std:c17") + else() + # Special case for 19.27 (VS 16.7): C11 has partial support. + macro(cmake_record_c_compile_features) + _has_compiler_features_c(90) + _has_compiler_features_c(99) + list(APPEND CMAKE_C11_COMPILE_FEATURES c_std_11) + set(_result 0) # expected by cmake_determine_compile_features + endmacro() + endif() + __compiler_check_default_language_standard(C 19.27 99) else() # MSVC has no specific options to set C language standards, but set them as @@ -25,41 +41,42 @@ else() # There is no meaningful default for this set(CMAKE_C_STANDARD_DEFAULT "") + + # There are no C compiler modes so we hard-code the known compiler supported + # features. Override the default macro for this special case. Pretend that + # all language standards are available so that at least compilation + # can be attempted. + macro(cmake_record_c_compile_features) + list(APPEND CMAKE_C_COMPILE_FEATURES + c_std_90 + c_std_99 + c_std_11 + c_std_17 + c_std_23 + c_function_prototypes + ) + list(APPEND CMAKE_C90_COMPILE_FEATURES c_std_90 c_function_prototypes) + list(APPEND CMAKE_C99_COMPILE_FEATURES c_std_99) + list(APPEND CMAKE_C11_COMPILE_FEATURES c_std_11) + if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 14.0) + list(APPEND CMAKE_C_COMPILE_FEATURES c_variadic_macros) + list(APPEND CMAKE_C99_COMPILE_FEATURES c_variadic_macros) + endif() + set(_result 0) # expected by cmake_determine_compile_features + endmacro() endif() set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -TC) set(CMAKE_C_CLANG_TIDY_DRIVER_MODE "cl") - -# There are no C compiler modes so we hard-code the known compiler supported -# features. Override the default macro for this special case. Pretend that -# all language standards are available so that at least compilation -# can be attempted. -macro(cmake_record_c_compile_features) - list(APPEND CMAKE_C_COMPILE_FEATURES - c_std_90 - c_std_99 - c_std_11 - c_function_prototypes - ) - list(APPEND CMAKE_C90_COMPILE_FEATURES c_std_90 c_function_prototypes) - list(APPEND CMAKE_C99_COMPILE_FEATURES c_std_99) - list(APPEND CMAKE_C11_COMPILE_FEATURES c_std_11) - if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 14.0) - list(APPEND CMAKE_C_COMPILE_FEATURES c_variadic_macros) - list(APPEND CMAKE_C99_COMPILE_FEATURES c_variadic_macros) - endif() - if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.27) - list(APPEND CMAKE_C_COMPILE_FEATURES c_restrict) - list(APPEND CMAKE_C99_COMPILE_FEATURES c_restrict) - endif() - if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.28) - list(APPEND CMAKE_C_COMPILE_FEATURES c_static_assert) - list(APPEND CMAKE_C11_COMPILE_FEATURES c_static_assert) - endif() - set(_result 0) # expected by cmake_determine_compile_features -endmacro() +set(CMAKE_C_INCLUDE_WHAT_YOU_USE_DRIVER_MODE "cl") # /JMC "Just My Code" is only supported by MSVC 19.05 onward. if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.05) set(CMAKE_C_COMPILE_OPTIONS_JMC "-JMC") endif() + +# The `/external:I` flag was made non-experimental in 19.29.30036.3. +if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.29.30036.3) + set(CMAKE_INCLUDE_SYSTEM_FLAG_C "-external:I ") + set(_CMAKE_INCLUDE_SYSTEM_FLAG_C_WARNING "-external:W0 ") +endif () diff --git a/Modules/Compiler/MSVC-CXX.cmake b/Modules/Compiler/MSVC-CXX.cmake index 5df5c1ebf..bcaec69e8 100644 --- a/Modules/Compiler/MSVC-CXX.cmake +++ b/Modules/Compiler/MSVC-CXX.cmake @@ -4,6 +4,7 @@ include(Compiler/CMakeCommonCompilerMacros) set(CMAKE_CXX_CLANG_TIDY_DRIVER_MODE "cl") +set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE_DRIVER_MODE "cl") if ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.0.24215.1 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.10) OR @@ -80,3 +81,9 @@ endif() if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.05) set(CMAKE_CXX_COMPILE_OPTIONS_JMC "-JMC") endif() + +# The `/external:I` flag was made non-experimental in 19.29.30036.3. +if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.29.30036.3) + set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-external:I ") + set(_CMAKE_INCLUDE_SYSTEM_FLAG_CXX_WARNING "-external:W0 ") +endif () diff --git a/Modules/Compiler/NVHPC.cmake b/Modules/Compiler/NVHPC.cmake index 70486705c..b51bb4339 100644 --- a/Modules/Compiler/NVHPC.cmake +++ b/Modules/Compiler/NVHPC.cmake @@ -12,4 +12,5 @@ include(Compiler/PGI) macro(__compiler_nvhpc lang) # Logic specific to NVHPC. + set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ") endmacro() diff --git a/Modules/Compiler/PGI.cmake b/Modules/Compiler/PGI.cmake index 4f8b90b13..d111be9ab 100644 --- a/Modules/Compiler/PGI.cmake +++ b/Modules/Compiler/PGI.cmake @@ -26,7 +26,7 @@ macro(__compiler_pgi lang) endif() set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Wl,") - set(CMAKE_${lang}_LINKER_WRAPPER_FLAG ",") + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP ",") set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES) if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL ppc64le AND (NOT CMAKE_HOST_WIN32 OR CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 16.3)) diff --git a/Modules/CompilerId/VS-10.csproj.in b/Modules/CompilerId/VS-10.csproj.in index ed5e8476f..fba74ff58 100644 --- a/Modules/CompilerId/VS-10.csproj.in +++ b/Modules/CompilerId/VS-10.csproj.in @@ -6,6 +6,9 @@ <Keyword>Win32Proj</Keyword> @id_system@ @id_system_version@ + @id_TargetFrameworkVersion@ + @id_TargetFrameworkIdentifier@ + @id_TargetFrameworkTargetsVersion@ @id_WindowsTargetPlatformVersion@ @id_WindowsSDKDesktopARMSupport@ </PropertyGroup> diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 9e25beeca..e49faae18 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -224,14 +224,14 @@ External Project Definition ``TLS_CAINFO <file>`` Specify a custom certificate authority file to use if ``TLS_VERIFY`` is enabled. If this option is not specified, the value of the - ``CMAKE_TLS_CAINFO`` variable will be used instead (see + :variable:`CMAKE_TLS_CAINFO` variable will be used instead (see :command:`file(DOWNLOAD)`) ``NETRC <level>`` .. versionadded:: 3.11 Specify whether the ``.netrc`` file is to be used for operation. - If this option is not specified, the value of the ``CMAKE_NETRC`` + If this option is not specified, the value of the :variable:`CMAKE_NETRC` variable will be used instead (see :command:`file(DOWNLOAD)`) Valid levels are: @@ -251,8 +251,8 @@ External Project Definition Specify an alternative ``.netrc`` file to the one in your home directory if the ``NETRC`` level is ``OPTIONAL`` or ``REQUIRED``. If this option - is not specified, the value of the ``CMAKE_NETRC_FILE`` variable will - be used instead (see :command:`file(DOWNLOAD)`) + is not specified, the value of the :variable:`CMAKE_NETRC_FILE` variable + will be used instead (see :command:`file(DOWNLOAD)`) .. versionadded:: 3.1 Added support for `tbz2`, `.tar.xz`, `.txz`, and `.7z` extensions. diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake index bd82a90e1..be75689b0 100644 --- a/Modules/FetchContent.cmake +++ b/Modules/FetchContent.cmake @@ -21,13 +21,14 @@ supported by the :module:`ExternalProject` module. Whereas configure step to use the content in commands like :command:`add_subdirectory`, :command:`include` or :command:`file` operations. -Content population details would normally be defined separately from the -command that performs the actual population. This separation ensures that -all of the dependency details are defined before anything may try to use those -details to populate content. This is particularly important in more complex -project hierarchies where dependencies may be shared between multiple projects. +Content population details should be defined separately from the command that +performs the actual population. This separation ensures that all the +dependency details are defined before anything might try to use them to +populate content. This is particularly important in more complex project +hierarchies where dependencies may be shared between multiple projects. -The following shows a typical example of declaring content details: +The following shows a typical example of declaring content details for some +dependencies and then ensuring they are populated with a separate call: .. code-block:: cmake @@ -36,57 +37,67 @@ The following shows a typical example of declaring content details: GIT_REPOSITORY https://github.com/google/googletest.git GIT_TAG 703bd9caab50b139428cea1aaff9974ebee5742e # release-1.10.0 ) + FetchContent_Declare( + myCompanyIcons + URL https://intranet.mycompany.com/assets/iconset_1.12.tar.gz + URL_HASH MD5=5588a7b18261c20068beabfb4f530b87 + ) + + FetchContent_MakeAvailable(googletest secret_sauce) + +The :command:`FetchContent_MakeAvailable` command ensures the named +dependencies have been populated, either by an earlier call or by populating +them itself. When performing the population, it will also add them to the +main build, if possible, so that the main build can use the populated +projects' targets, etc. See the command's documentation for how these steps +are performed. + +When using a hierarchical project arrangement, projects at higher levels in +the hierarchy are able to override the declared details of content specified +anywhere lower in the project hierarchy. The first details to be declared +for a given dependency take precedence, regardless of where in the project +hierarchy that occurs. Similarly, the first call that tries to populate a +dependency "wins", with subsequent populations reusing the result of the +first instead of repeating the population again. +See the :ref:`Examples <fetch-content-examples>` which demonstrate +this scenario. -For most typical cases, populating the content can then be done with a single -command like so: +In some cases, the main project may need to have more precise control over +the population, or it may be required to explicitly define the population +steps in a way that cannot be captured by the declared details alone. +For such situations, the lower level :command:`FetchContent_GetProperties` and +:command:`FetchContent_Populate` commands can be used. These lack the richer +features provided by :command:`FetchContent_MakeAvailable` though, so their +direct use should be considered a last resort. The typical pattern of such +custom steps looks like this: .. code-block:: cmake - FetchContent_MakeAvailable(googletest) + # NOTE: Where possible, prefer to use FetchContent_MakeAvailable() + # instead of custom logic like this -The above command not only populates the content, it also adds it to the main -build (if possible) so that the main build can use the populated project's -targets, etc. In some cases, the main project may need to have more precise -control over the population or may be required to explicitly define the -population steps (e.g. if CMake versions earlier than 3.14 need to be -supported). The typical pattern of such custom steps looks like this: + # Check if population has already been performed + FetchContent_GetProperties(depname) + if(NOT depname_POPULATED) + # Fetch the content using previously declared details + FetchContent_Populate(depname) -.. code-block:: cmake + # Set custom variables, policies, etc. + # ... - FetchContent_GetProperties(googletest) - if(NOT googletest_POPULATED) - FetchContent_Populate(googletest) - add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR}) + # Bring the populated content into the build + add_subdirectory(${depname_SOURCE_DIR} ${depname_BINARY_DIR}) endif() -Regardless of which population method is used, when using the -declare-populate pattern with a hierarchical project arrangement, projects at -higher levels in the hierarchy are able to override the population details of -content specified anywhere lower in the project hierarchy. The ability to -detect whether content has already been populated ensures that even if -multiple child projects want certain content to be available, the first one -to populate it wins. The other child project can simply make use of the -already available content instead of repeating the population for itself. -See the :ref:`Examples <fetch-content-examples>` section which demonstrates -this scenario. - The ``FetchContent`` module also supports defining and populating content in a single call, with no check for whether the content has been -populated elsewhere in the project already. This is a more low level -operation and would not normally be the way the module is used, but it is -sometimes useful as part of implementing some higher level feature or to -populate some content in CMake's script mode. - -.. versionchanged:: 3.14 - ``FetchContent`` commands can access the terminal. This is necessary - for password prompts and real-time progress displays to work. +populated elsewhere already. This should not be done in projects, but may +be appropriate for populating content in CMake's script mode. +See :command:`FetchContent_Populate` for details. Commands ^^^^^^^^ -Declaring Content Details -""""""""""""""""""""""""" - .. command:: FetchContent_Declare .. code-block:: cmake @@ -94,7 +105,7 @@ Declaring Content Details FetchContent_Declare(<name> <contentOptions>...) The ``FetchContent_Declare()`` function records the options that describe - how to populate the specified content, but if such details have already + how to populate the specified content. If such details have already been recorded earlier in this project (regardless of where in the project hierarchy), this and all later calls for the same content ``<name>`` are ignored. This "first to record, wins" approach is what allows hierarchical @@ -110,7 +121,7 @@ Declaring Content Details projects needing that same content will use the same name, leading to the content being populated multiple times. - The ``<contentOptions>`` can be any of the download or update/patch options + The ``<contentOptions>`` can be any of the download, update or patch options that the :command:`ExternalProject_Add` command understands. The configure, build, install and test steps are explicitly disabled and therefore options related to them will be ignored. The ``SOURCE_SUBDIR`` option is an @@ -146,47 +157,95 @@ Declaring Content Details than a branch or tag name. A commit hash is more secure and helps to confirm that the downloaded contents are what you expected. -Populating The Content -"""""""""""""""""""""" + .. versionchanged:: 3.14 + Commands for the download, update or patch steps can access the terminal. + This may be needed for things like password prompts or real-time display + of command progress. -For most common scenarios, population means making content available to the -main build according to previously declared details for that dependency. -There are two main patterns for populating content, one based on calling -:command:`FetchContent_GetProperties` and -:command:`FetchContent_Populate` for more precise control and the other on -calling :command:`FetchContent_MakeAvailable` for a simpler, more automated -approach. The former generally follows this canonical pattern: + .. versionadded:: 3.22 + The :variable:`CMAKE_TLS_VERIFY`, :variable:`CMAKE_TLS_CAINFO`, + :variable:`CMAKE_NETRC` and :variable:`CMAKE_NETRC_FILE` variables now + provide the defaults for their corresponding content options, just like + they do for :command:`ExternalProject_Add`. Previously, these variables + were ignored by the ``FetchContent`` module. -.. _`fetch-content-canonical-pattern`: +.. command:: FetchContent_MakeAvailable -.. code-block:: cmake + .. versionadded:: 3.14 - # Check if population has already been performed - FetchContent_GetProperties(<name>) - string(TOLOWER "<name>" lcName) - if(NOT ${lcName}_POPULATED) - # Fetch the content using previously declared details - FetchContent_Populate(<name>) + .. code-block:: cmake - # Set custom variables, policies, etc. - # ... + FetchContent_MakeAvailable(<name1> [<name2>...]) + + This command ensures that each of the named dependencies are populated and + potentially added to the build by the time it returns. It iterates over + the list, and for each dependency, the following logic is applied: + + * If the dependency has already been populated earlier in this run, set + the ``<lowercaseName>_POPULATED``, ``<lowercaseName>_SOURCE_DIR`` and + ``<lowercaseName>_BINARY_DIR`` variables in the same way as a call to + :command:`FetchContent_GetProperties`, then skip the remaining steps + below and move on to the next dependency in the list. + + * Call :command:`FetchContent_Populate` to populate the dependency using + the details recorded by an earlier call to :command:`FetchContent_Declare`. + Halt with a fatal error if no such details have been recorded. + :variable:`FETCHCONTENT_SOURCE_DIR_<uppercaseName>` can be used to override + the declared details and use content provided at the specified location + instead. + + * If the top directory of the populated content contains a ``CMakeLists.txt`` + file, call :command:`add_subdirectory` to add it to the main build. + It is not an error for there to be no ``CMakeLists.txt`` file, which + allows the command to be used for dependencies that make downloaded + content available at a known location, but which do not need or support + being added directly to the build. + + .. versionadded:: 3.18 + The ``SOURCE_SUBDIR`` option can be given in the declared details to + look somewhere below the top directory instead (i.e. the same way that + ``SOURCE_SUBDIR`` is used by the :command:`ExternalProject_Add` + command). The path provided with ``SOURCE_SUBDIR`` must be relative + and will be treated as relative to the top directory. It can also + point to a directory that does not contain a ``CMakeLists.txt`` file + or even to a directory that doesn't exist. This can be used to avoid + adding a project that contains a ``CMakeLists.txt`` file in its top + directory. + + Projects should aim to declare the details of all dependencies they might + use before they call ``FetchContent_MakeAvailable()`` for any of them. + This ensures that if any of the dependencies are also sub-dependencies of + one or more of the others, the main project still controls the details + that will be used (because it will declare them first before the + dependencies get a chance to). In the following code samples, assume that + the ``uses_other`` dependency also uses ``FetchContent`` to add the ``other`` + dependency internally: - # Bring the populated content into the build - add_subdirectory(${${lcName}_SOURCE_DIR} ${${lcName}_BINARY_DIR}) - endif() + .. code-block:: cmake + + # WRONG: Should declare all details first + FetchContent_Declare(uses_other ...) + FetchContent_MakeAvailable(uses_other) -The above is such a common pattern that, where no custom steps are needed -between the calls to :command:`FetchContent_Populate` and -:command:`add_subdirectory`, equivalent logic can be obtained by calling -:command:`FetchContent_MakeAvailable` instead. Where it meets the needs of -the project, :command:`FetchContent_MakeAvailable` should be preferred, as it -is simpler and provides additional features over the pattern above. + FetchContent_Declare(other ...) # Will be ignored, uses_other beat us to it + FetchContent_MakeAvailable(other) # Would use details declared by uses_other + + .. code-block:: cmake + + # CORRECT: All details declared first, so they will take priority + FetchContent_Declare(uses_other ...) + FetchContent_Declare(other ...) + FetchContent_MakeAvailable(uses_other other) .. command:: FetchContent_Populate + .. note:: + Where possible, prefer to use :command:`FetchContent_MakeAvailable` + instead of implementing population manually with this command. + .. code-block:: cmake - FetchContent_Populate( <name> ) + FetchContent_Populate(<name>) In most cases, the only argument given to ``FetchContent_Populate()`` is the ``<name>``. When used this way, the command assumes the content details have @@ -211,88 +270,29 @@ is simpler and provides additional features over the pattern above. ``FetchContent_Populate()``. ``FetchContent_Populate()`` will set three variables in the scope of the - caller; ``<lcName>_POPULATED``, ``<lcName>_SOURCE_DIR`` and - ``<lcName>_BINARY_DIR``, where ``<lcName>`` is the lowercased ``<name>``. - ``<lcName>_POPULATED`` will always be set to ``True`` by the call. - ``<lcName>_SOURCE_DIR`` is the location where the - content can be found upon return (it will have already been populated), while - ``<lcName>_BINARY_DIR`` is a directory intended for use as a corresponding - build directory. The main use case for the two directory variables is to - call :command:`add_subdirectory` immediately after population, i.e.: + caller: + + ``<lowercaseName>_POPULATED`` + This will always be set to ``TRUE`` by the call. + + ``<lowercaseName>_SOURCE_DIR`` + The location where the populated content can be found upon return. + + ``<lowercaseName>_BINARY_DIR`` + A directory intended for use as a corresponding build directory. + + The main use case for the ``<lowercaseName>_SOURCE_DIR`` and + ``<lowercaseName>_BINARY_DIR`` variables is to call + :command:`add_subdirectory` immediately after population: .. code-block:: cmake - FetchContent_Populate(FooBar ...) + FetchContent_Populate(FooBar) add_subdirectory(${foobar_SOURCE_DIR} ${foobar_BINARY_DIR}) The values of the three variables can also be retrieved from anywhere in the project hierarchy using the :command:`FetchContent_GetProperties` command. - A number of cache variables influence the behavior of all content population - performed using details saved from a :command:`FetchContent_Declare` call: - - ``FETCHCONTENT_BASE_DIR`` - In most cases, the saved details do not specify any options relating to the - directories to use for the internal sub-build, final source and build areas. - It is generally best to leave these decisions up to the ``FetchContent`` - module to handle on the project's behalf. The ``FETCHCONTENT_BASE_DIR`` - cache variable controls the point under which all content population - directories are collected, but in most cases developers would not need to - change this. The default location is ``${CMAKE_BINARY_DIR}/_deps``, but if - developers change this value, they should aim to keep the path short and - just below the top level of the build tree to avoid running into path - length problems on Windows. - - ``FETCHCONTENT_QUIET`` - The logging output during population can be quite verbose, making the - configure stage quite noisy. This cache option (``ON`` by default) hides - all population output unless an error is encountered. If experiencing - problems with hung downloads, temporarily switching this option off may - help diagnose which content population is causing the issue. - - ``FETCHCONTENT_FULLY_DISCONNECTED`` - When this option is enabled, no attempt is made to download or update - any content. It is assumed that all content has already been populated in - a previous run or the source directories have been pointed at existing - contents the developer has provided manually (using options described - further below). When the developer knows that no changes have been made to - any content details, turning this option ``ON`` can significantly speed up - the configure stage. It is ``OFF`` by default. - - ``FETCHCONTENT_UPDATES_DISCONNECTED`` - This is a less severe download/update control compared to - ``FETCHCONTENT_FULLY_DISCONNECTED``. Instead of bypassing all download and - update logic, the ``FETCHCONTENT_UPDATES_DISCONNECTED`` only disables the - update stage. Therefore, if content has not been downloaded previously, - it will still be downloaded when this option is enabled. This can speed up - the configure stage, but not as much as - ``FETCHCONTENT_FULLY_DISCONNECTED``. It is ``OFF`` by default. - - In addition to the above cache variables, the following cache variables are - also defined for each content name (``<ucName>`` is the uppercased value of - ``<name>``): - - ``FETCHCONTENT_SOURCE_DIR_<ucName>`` - If this is set, no download or update steps are performed for the specified - content and the ``<lcName>_SOURCE_DIR`` variable returned to the caller is - pointed at this location. This gives developers a way to have a separate - checkout of the content that they can modify freely without interference - from the build. The build simply uses that existing source, but it still - defines ``<lcName>_BINARY_DIR`` to point inside its own build area. - Developers are strongly encouraged to use this mechanism rather than - editing the sources populated in the default location, as changes to - sources in the default location can be lost when content population details - are changed by the project. - - ``FETCHCONTENT_UPDATES_DISCONNECTED_<ucName>`` - This is the per-content equivalent of - ``FETCHCONTENT_UPDATES_DISCONNECTED``. If the global option or this option - is ``ON``, then updates will be disabled for the named content. - Disabling updates for individual content can be useful for content whose - details rarely change, while still leaving other frequently changing - content with updates enabled. - - The ``FetchContent_Populate()`` command also supports a syntax allowing the content details to be specified directly rather than using any saved details. This is more low-level and use of this form is generally to be @@ -303,7 +303,8 @@ is simpler and provides additional features over the pattern above. .. code-block:: cmake - FetchContent_Populate( <name> + FetchContent_Populate( + <name> [QUIET] [SUBBUILD_DIR <subBuildDir>] [SOURCE_DIR <srcDir>] @@ -325,16 +326,17 @@ is simpler and provides additional features over the pattern above. - The ``FETCHCONTENT_FULLY_DISCONNECTED`` and ``FETCHCONTENT_UPDATES_DISCONNECTED`` cache variables are ignored. - The ``<lcName>_SOURCE_DIR`` and ``<lcName>_BINARY_DIR`` variables are still - returned to the caller, but since these locations are not stored as global - properties when this form is used, they are only available to the calling - scope and below rather than the entire project hierarchy. No - ``<lcName>_POPULATED`` variable is set in the caller's scope with this form. + The ``<lowercaseName>_SOURCE_DIR`` and ``<lowercaseName>_BINARY_DIR`` + variables are still returned to the caller, but since these locations are + not stored as global properties when this form is used, they are only + available to the calling scope and below rather than the entire project + hierarchy. No ``<lowercaseName>_POPULATED`` variable is set in the caller's + scope with this form. The supported options for ``FetchContent_Populate()`` are the same as those for :command:`FetchContent_Declare()`. Those few options shown just above are either specific to ``FetchContent_Populate()`` or their behavior is - slightly modified from how :command:`ExternalProject_Add` treats them. + slightly modified from how :command:`ExternalProject_Add` treats them: ``QUIET`` The ``QUIET`` option can be given to hide the output associated with @@ -347,9 +349,9 @@ is simpler and provides additional features over the pattern above. ``SUBBUILD_DIR`` The ``SUBBUILD_DIR`` argument can be provided to change the location of the sub-build created to perform the population. The default value is - ``${CMAKE_CURRENT_BINARY_DIR}/<lcName>-subbuild`` and it would be unusual - to need to override this default. If a relative path is specified, it will - be interpreted as relative to :variable:`CMAKE_CURRENT_BINARY_DIR`. + ``${CMAKE_CURRENT_BINARY_DIR}/<lowercaseName>-subbuild`` and it would be + unusual to need to override this default. If a relative path is specified, + it will be interpreted as relative to :variable:`CMAKE_CURRENT_BINARY_DIR`. This option should not be confused with the ``SOURCE_SUBDIR`` option which only affects the :command:`FetchContent_MakeAvailable` command. @@ -357,9 +359,9 @@ is simpler and provides additional features over the pattern above. The ``SOURCE_DIR`` and ``BINARY_DIR`` arguments are supported by :command:`ExternalProject_Add`, but different default values are used by ``FetchContent_Populate()``. ``SOURCE_DIR`` defaults to - ``${CMAKE_CURRENT_BINARY_DIR}/<lcName>-src`` and ``BINARY_DIR`` defaults to - ``${CMAKE_CURRENT_BINARY_DIR}/<lcName>-build``. If a relative path is - specified, it will be interpreted as relative to + ``${CMAKE_CURRENT_BINARY_DIR}/<lowercaseName>-src`` and ``BINARY_DIR`` + defaults to ``${CMAKE_CURRENT_BINARY_DIR}/<lowercaseName>-build``. + If a relative path is specified, it will be interpreted as relative to :variable:`CMAKE_CURRENT_BINARY_DIR`. In addition to the above explicit options, any other unrecognized options are @@ -380,11 +382,12 @@ is simpler and provides additional features over the pattern above. on the command line invoking the script. .. versionadded:: 3.18 - Added support for ``DOWNLOAD_NO_EXTRACT`` and ``SOURCE_SUBDIR`` options. + Added support for the ``DOWNLOAD_NO_EXTRACT`` option. .. command:: FetchContent_GetProperties - When using saved content details, a call to :command:`FetchContent_Populate` + When using saved content details, a call to + :command:`FetchContent_MakeAvailable` or :command:`FetchContent_Populate` records information in global properties which can be queried at any time. This information includes the source and binary directories associated with the content and also whether or not the content population has been processed @@ -392,7 +395,8 @@ is simpler and provides additional features over the pattern above. .. code-block:: cmake - FetchContent_GetProperties( <name> + FetchContent_GetProperties( + <name> [SOURCE_DIR <srcDirVar>] [BINARY_DIR <binDirVar>] [POPULATED <doneVar>] @@ -403,49 +407,104 @@ is simpler and provides additional features over the pattern above. which is the name of the variable in which to store that property. Most of the time though, only ``<name>`` is given, in which case the call will then set the same variables as a call to - :command:`FetchContent_Populate(name) <FetchContent_Populate>`. This allows - the following canonical pattern to be used, which ensures that the relevant - variables will always be defined regardless of whether or not the population - has been performed elsewhere in the project already: + :command:`FetchContent_MakeAvailable(name) <FetchContent_MakeAvailable>` or + :command:`FetchContent_Populate(name) <FetchContent_Populate>`. - .. code-block:: cmake - - FetchContent_GetProperties(foobar) - if(NOT foobar_POPULATED) - FetchContent_Populate(foobar) - ... - endif() - - The above pattern allows other parts of the overall project hierarchy to - re-use the same content and ensure that it is only populated once. - - -.. command:: FetchContent_MakeAvailable + This command is rarely needed when using + :command:`FetchContent_MakeAvailable`. It is more commonly used as part of + implementing the following pattern with :command:`FetchContent_Populate`, + which ensures that the relevant variables will always be defined regardless + of whether or not the population has been performed elsewhere in the project + already: .. code-block:: cmake - FetchContent_MakeAvailable( <name1> [<name2>...] ) + # Check if population has already been performed + FetchContent_GetProperties(depname) + if(NOT depname_POPULATED) + # Fetch the content using previously declared details + FetchContent_Populate(depname) - .. versionadded:: 3.14 + # Set custom variables, policies, etc. + # ... - This command implements the common pattern typically needed for most - dependencies. It iterates over each of the named dependencies in turn - and for each one it loosely follows the - :ref:`canonical pattern <fetch-content-canonical-pattern>` as - presented at the beginning of this section. An important difference is - that :command:`add_subdirectory` will only be called on the - populated content if there is a ``CMakeLists.txt`` file in its top level - source directory. This allows the command to be used for dependencies - that make downloaded content available at a known location but which do - not need or support being added directly to the build. - - The ``SOURCE_SUBDIR`` option can be given in the declared details to - instruct ``FetchContent_MakeAvailable()`` to look for a ``CMakeLists.txt`` - file in a subdirectory below the top level (i.e. the same way that - ``SOURCE_SUBDIR`` is used by the :command:`ExternalProject_Add` command). - ``SOURCE_SUBDIR`` must always be a relative path. See the next section - for an example of this option. + # Bring the populated content into the build + add_subdirectory(${depname_SOURCE_DIR} ${depname_BINARY_DIR}) + endif() +Variables +^^^^^^^^^ + +A number of cache variables can influence the behavior where details from a +:command:`FetchContent_Declare` call are used to populate content. +The variables are all intended for the developer to customize behavior and +should not normally be set by the project. + +.. variable:: FETCHCONTENT_BASE_DIR + + In most cases, the saved details do not specify any options relating to the + directories to use for the internal sub-build, final source and build areas. + It is generally best to leave these decisions up to the ``FetchContent`` + module to handle on the project's behalf. The ``FETCHCONTENT_BASE_DIR`` + cache variable controls the point under which all content population + directories are collected, but in most cases, developers would not need to + change this. The default location is ``${CMAKE_BINARY_DIR}/_deps``, but if + developers change this value, they should aim to keep the path short and + just below the top level of the build tree to avoid running into path + length problems on Windows. + +.. variable:: FETCHCONTENT_QUIET + + The logging output during population can be quite verbose, making the + configure stage quite noisy. This cache option (``ON`` by default) hides + all population output unless an error is encountered. If experiencing + problems with hung downloads, temporarily switching this option off may + help diagnose which content population is causing the issue. + +.. variable:: FETCHCONTENT_FULLY_DISCONNECTED + + When this option is enabled, no attempt is made to download or update + any content. It is assumed that all content has already been populated in + a previous run or the source directories have been pointed at existing + contents the developer has provided manually (using options described + further below). When the developer knows that no changes have been made to + any content details, turning this option ``ON`` can significantly speed up + the configure stage. It is ``OFF`` by default. + +.. variable:: FETCHCONTENT_UPDATES_DISCONNECTED + + This is a less severe download/update control compared to + :variable:`FETCHCONTENT_FULLY_DISCONNECTED`. Instead of bypassing all + download and update logic, ``FETCHCONTENT_UPDATES_DISCONNECTED`` only + disables the update stage. Therefore, if content has not been downloaded + previously, it will still be downloaded when this option is enabled. + This can speed up the configure stage, but not as much as + :variable:`FETCHCONTENT_FULLY_DISCONNECTED`. It is ``OFF`` by default. + +In addition to the above cache variables, the following cache variables are +also defined for each content name: + +.. variable:: FETCHCONTENT_SOURCE_DIR_<uppercaseName> + + If this is set, no download or update steps are performed for the specified + content and the ``<lowercaseName>_SOURCE_DIR`` variable returned to the + caller is pointed at this location. This gives developers a way to have a + separate checkout of the content that they can modify freely without + interference from the build. The build simply uses that existing source, + but it still defines ``<lowercaseName>_BINARY_DIR`` to point inside its own + build area. Developers are strongly encouraged to use this mechanism rather + than editing the sources populated in the default location, as changes to + sources in the default location can be lost when content population details + are changed by the project. + +.. variable:: FETCHCONTENT_UPDATES_DISCONNECTED_<uppercaseName> + + This is the per-content equivalent of + :variable:`FETCHCONTENT_UPDATES_DISCONNECTED`. If the global option or + this option is ``ON``, then updates will be disabled for the named content. + Disabling updates for individual content can be useful for content whose + details rarely change, while still leaving other frequently changing content + with updates enabled. .. _`fetch-content-examples`: @@ -470,7 +529,7 @@ frameworks are available to the main build: ) # After the following call, the CMake targets defined by googletest and - # Catch2 will be defined and available to the rest of the build + # Catch2 will be available to the rest of the build FetchContent_MakeAvailable(googletest Catch2) If the sub-project's ``CMakeLists.txt`` file is not at the top level of its @@ -964,18 +1023,29 @@ ExternalProject_Add_Step(${contentName}-populate copyfile unset(subCMakeOpts) endif() - if(DEFINED CMAKE_EP_GIT_REMOTE_UPDATE_STRATEGY) - list(APPEND subCMakeOpts - "-DCMAKE_EP_GIT_REMOTE_UPDATE_STRATEGY=${CMAKE_EP_GIT_REMOTE_UPDATE_STRATEGY}") - endif() + set(__FETCHCONTENT_CACHED_INFO "") + set(__passthrough_vars + CMAKE_EP_GIT_REMOTE_UPDATE_STRATEGY + CMAKE_TLS_VERIFY + CMAKE_TLS_CAINFO + CMAKE_NETRC + CMAKE_NETRC_FILE + ) + foreach(var IN LISTS __passthrough_vars) + if(DEFINED ${var}) + # Embed directly in the generated CMakeLists.txt file to avoid making + # the cmake command line excessively long. It also makes debugging and + # testing easier. + string(APPEND __FETCHCONTENT_CACHED_INFO "set(${var} [==[${${var}}]==])\n") + endif() + endforeach() # Avoid using if(... IN_LIST ...) so we don't have to alter policy settings - set(__FETCHCONTENT_CACHED_INFO "") list(FIND ARG_UNPARSED_ARGUMENTS GIT_REPOSITORY indexResult) if(indexResult GREATER_EQUAL 0) find_package(Git QUIET) - set(__FETCHCONTENT_CACHED_INFO -"# Pass through things we've already detected in the main project to avoid + string(APPEND __FETCHCONTENT_CACHED_INFO " +# Pass through things we've already detected in the main project to avoid # paying the cost of redetecting them again in ExternalProject_Add() set(GIT_EXECUTABLE [==[${GIT_EXECUTABLE}]==]) set(GIT_VERSION_STRING [==[${GIT_VERSION_STRING}]==]) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index 726ff75bf..308138f41 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -35,6 +35,19 @@ The following variables may be set to influence this module's behavior: if set ``pkg-config`` will be used to search for a BLAS library first and if one is found that is preferred +``BLA_SIZEOF_INTEGER`` + .. versionadded:: 3.22 + + Specify the BLAS/LAPACK library integer size: + + ``4`` + Search for a BLAS/LAPACK with 32-bit integer interfaces. + ``8`` + Search for a BLAS/LAPACK with 64-bit integer interfaces. + ``ANY`` + Search for any BLAS/LAPACK. + Most likely, a BLAS/LAPACK with 32-bit integer interfaces will be found. + Imported targets ^^^^^^^^^^^^^^^^ @@ -101,15 +114,16 @@ BLAS/LAPACK Vendors ``FlexiBLAS`` .. versionadded:: 3.19 -``Fujitsu_SSL2``, ``Fujitsu_SSL2BLAMP`` +``Fujitsu_SSL2``, ``Fujitsu_SSL2BLAMP``, ``Fujitsu_SSL2SVE``, ``Fujitsu_SSL2BLAMPSVE`` .. versionadded:: 3.20 - Fujitsu SSL2 serial and parallel blas/lapack + Fujitsu SSL2 serial and parallel blas/lapack with SVE instructions ``Goto`` GotoBLAS -``IBMESSL`` +``IBMESSL``, ``IBMESSL_SMP`` + IBM Engineering and Scientific Subroutine Library ``Intel`` @@ -150,7 +164,7 @@ BLAS/LAPACK Vendors ``PhiPACK`` Portable High Performance ANSI C (PHiPAC) -``SCSL`` +``SCSL``, ``SCSL_mp`` Scientific Computing Software Library ``SGIMATH`` @@ -312,9 +326,9 @@ function(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlib list(APPEND _libraries "${_library}") else() string(REGEX REPLACE "[^A-Za-z0-9]" "_" _lib_var "${_library}") - set(_combined_name ${_combined_name}_${_lib_var}) + string(APPEND _combined_name "_${_lib_var}") if(NOT "${_deps}" STREQUAL "") - set(_combined_name ${_combined_name}_deps) + string(APPEND _combined_name "_deps") endif() if(_libraries_work) find_library(${_prefix}_${_lib_var}_LIBRARY @@ -332,7 +346,7 @@ function(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlib foreach(_flag ${_flags}) string(REGEX REPLACE "[^A-Za-z0-9]" "_" _flag_var "${_flag}") - set(_combined_name ${_combined_name}_${_flag_var}) + string(APPEND _combined_name "_${_flag_var}") endforeach() if(_libraries_work) # Test this combination of libraries. @@ -371,6 +385,17 @@ else() endif() endif() +if(NOT BLA_SIZEOF_INTEGER) + # in the reality we do not know which API of BLAS/LAPACK is masked in library + set(_blas_sizeof_integer "ANY") +elseif((BLA_SIZEOF_INTEGER STREQUAL "ANY") OR + (BLA_SIZEOF_INTEGER STREQUAL "4") OR + (BLA_SIZEOF_INTEGER STREQUAL "8")) + set(_blas_sizeof_integer ${BLA_SIZEOF_INTEGER}) +else() + message(FATAL_ERROR "BLA_SIZEOF_INTEGER can have only <no value>, ANY, 4, or 8 values") +endif() + # Implicitly linked BLAS libraries? if(BLA_VENDOR STREQUAL "All") if(NOT BLAS_LIBRARIES) @@ -386,6 +411,8 @@ if(BLA_VENDOR STREQUAL "All") ) endif() if(BLAS_WORKS) + # Give a more helpful "found" message + set(BLAS_WORKS "implicitly linked") set(_blas_fphsa_req_var BLAS_WORKS) endif() endif() @@ -429,17 +456,23 @@ if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") find_package(Threads REQUIRED) endif() - if(BLA_VENDOR MATCHES "_64ilp") + if(_blas_sizeof_integer EQUAL 8) set(BLAS_mkl_ILP_MODE "ilp64") - else() + elseif(_blas_sizeof_integer EQUAL 4) set(BLAS_mkl_ILP_MODE "lp64") + else() + if(BLA_VENDOR MATCHES "_64ilp") + set(BLAS_mkl_ILP_MODE "ilp64") + else() + set(BLAS_mkl_ILP_MODE "lp64") + endif() endif() set(BLAS_SEARCH_LIBS "") if(BLA_F95) set(BLAS_mkl_SEARCH_SYMBOL "sgemm_f95") - set(_LIBRARIES BLAS95_LIBRARIES) + set(_BLAS_LIBRARIES BLAS95_LIBRARIES) if(WIN32) # Find the main file (32-bit or 64-bit) set(BLAS_SEARCH_LIBS_WIN_MAIN "") @@ -501,7 +534,7 @@ if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") endif() else() set(BLAS_mkl_SEARCH_SYMBOL sgemm) - set(_LIBRARIES BLAS_LIBRARIES) + set(_BLAS_LIBRARIES BLAS_LIBRARIES) if(WIN32) # Find the main file (32-bit or 64-bit) set(BLAS_SEARCH_LIBS_WIN_MAIN "") @@ -613,15 +646,15 @@ if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") "lib/${BLAS_mkl_ARCH_NAME}" ) - foreach(IT ${BLAS_SEARCH_LIBS}) - string(REPLACE " " ";" SEARCH_LIBS ${IT}) - if(NOT ${_LIBRARIES}) + foreach(_search ${BLAS_SEARCH_LIBS}) + string(REPLACE " " ";" _search ${_search}) + if(NOT ${_BLAS_LIBRARIES}) check_blas_libraries( - ${_LIBRARIES} + ${_BLAS_LIBRARIES} BLAS ${BLAS_mkl_SEARCH_SYMBOL} "" - "${SEARCH_LIBS}" + "${_search}" "${CMAKE_THREAD_LIBS_INIT};${BLAS_mkl_LM};${BLAS_mkl_LDL}" "${BLAS_mkl_MKLROOT}" "${BLAS_mkl_LIB_PATH_SUFFIXES}" @@ -629,6 +662,7 @@ if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") endif() endforeach() + unset(_search) unset(BLAS_mkl_ILP_MODE) unset(BLAS_mkl_INTFACE) unset(BLAS_mkl_THREADING) @@ -671,29 +705,43 @@ endif() # FlexiBLAS? (http://www.mpi-magdeburg.mpg.de/mpcsc/software/FlexiBLAS/) if(BLA_VENDOR STREQUAL "FlexiBLAS" OR BLA_VENDOR STREQUAL "All") + set(_blas_flexiblas_lib "flexiblas") + + if(_blas_sizeof_integer EQUAL 8) + string(APPEND _blas_flexiblas_lib "64") + endif() + if(NOT BLAS_LIBRARIES) check_blas_libraries( BLAS_LIBRARIES BLAS sgemm "" - "flexiblas" + "${_blas_flexiblas_lib}" "" "" "" ) endif() + + unset(_blas_flexiblas_lib) endif() # OpenBLAS? (http://www.openblas.net) if(BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All") + set(_blas_openblas_lib "openblas") + + if(_blas_sizeof_integer EQUAL 8) + string(APPEND _blas_openblas_lib "64") + endif() + if(NOT BLAS_LIBRARIES) check_blas_libraries( BLAS_LIBRARIES BLAS sgemm "" - "openblas" + "${_blas_openblas_lib}" "" "" "" @@ -720,59 +768,75 @@ if(BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All") BLAS sgemm "" - "openblas" + "${_blas_openblas_lib}" "${_threadlibs}" "" "" ) unset(_threadlibs) endif() + + unset(_blas_openblas_lib) endif() # ArmPL blas library? (https://developer.arm.com/tools-and-software/server-and-hpc/compile/arm-compiler-for-linux/arm-performance-libraries) if(BLA_VENDOR MATCHES "Arm" OR BLA_VENDOR STREQUAL "All") # Check for 64bit Integer support - if(BLA_VENDOR MATCHES "_ilp64") - set(BLAS_armpl_LIB "armpl_ilp64") - else() - set(BLAS_armpl_LIB "armpl_lp64") - endif() + if(_blas_sizeof_integer EQUAL 8) + set(_blas_armpl_lib "armpl_ilp64") + elseif(_blas_sizeof_integer EQUAL 4) + set(_blas_armpl_lib "armpl_lp64") + else() + if(BLA_VENDOR MATCHES "_ilp64") + set(_blas_armpl_lib "armpl_ilp64") + else() + set(_blas_armpl_lib "armpl_lp64") + endif() + endif() # Check for OpenMP support, VIA BLA_VENDOR of Arm_mp or Arm_ipl64_mp if(BLA_VENDOR MATCHES "_mp") - set(BLAS_armpl_LIB "${BLAS_armpl_LIB}_mp") + string(APPEND _blas_armpl_lib "_mp") endif() if(NOT BLAS_LIBRARIES) - check_blas_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "${BLAS_armpl_LIB}" - "" - "" - "" - ) + check_blas_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "${_blas_armpl_lib}" + "" + "" + "" + ) endif() - + unset(_blas_armpl_lib) endif() # FLAME's blis library? (https://github.com/flame/blis) if(BLA_VENDOR STREQUAL "FLAME" OR BLA_VENDOR STREQUAL "All") + set(_blas_flame_lib "blis") + + if(_blas_sizeof_integer EQUAL 8) + string(APPEND _blas_flame_lib "64") + endif() + if(NOT BLAS_LIBRARIES) check_blas_libraries( BLAS_LIBRARIES BLAS sgemm "" - "blis" + "${_blas_flame_lib}" "" "" "" ) endif() + + unset(_blas_flame_lib) endif() # BLAS in the ATLAS library? (http://math-atlas.sourceforge.net/) @@ -809,33 +873,45 @@ endif() # BLAS in Alpha CXML library? if(BLA_VENDOR STREQUAL "CXML" OR BLA_VENDOR STREQUAL "All") - if(NOT BLAS_LIBRARIES) - check_blas_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "cxml" - "" - "" - "" - ) + if(_blas_sizeof_integer EQUAL 8) + if(BLA_VENDOR STREQUAL "CXML") + message(FATAL_ERROR "CXML does not support Int64 type") + endif() + else() + if(NOT BLAS_LIBRARIES) + check_blas_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "cxml" + "" + "" + "" + ) + endif() endif() endif() # BLAS in Alpha DXML library? (now called CXML, see above) if(BLA_VENDOR STREQUAL "DXML" OR BLA_VENDOR STREQUAL "All") - if(NOT BLAS_LIBRARIES) - check_blas_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "" - "dxml" - "" - "" - "" - ) + if(_blas_sizeof_integer EQUAL 8) + if(BLA_VENDOR STREQUAL "DXML") + message(FATAL_ERROR "DXML does not support Int64 type") + endif() + else() + if(NOT BLAS_LIBRARIES) + check_blas_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "dxml" + "" + "" + "" + ) + endif() endif() endif() @@ -859,19 +935,30 @@ if(BLA_VENDOR STREQUAL "SunPerf" OR BLA_VENDOR STREQUAL "All") endif() # BLAS in SCSL library? (SGI/Cray Scientific Library) -if(BLA_VENDOR STREQUAL "SCSL" OR BLA_VENDOR STREQUAL "All") +if(BLA_VENDOR MATCHES "SCSL" OR BLA_VENDOR STREQUAL "All") + set(_blas_scsl_lib "scs") + + if(_blas_sizeof_integer EQUAL 8) + string(APPEND _blas_scsl_lib "_i8") + endif() + if(BLA_VENDOR MATCHES "_mp") + string(APPEND _blas_scsl_lib "_mp") + endif() + if(NOT BLAS_LIBRARIES) check_blas_libraries( BLAS_LIBRARIES BLAS sgemm "" - "scsl" + "${_blas_scsl_lib}" "" "" "" ) endif() + + unset(_blas_scsl_lib) endif() # BLAS in SGIMATH library? @@ -890,20 +977,31 @@ if(BLA_VENDOR STREQUAL "SGIMATH" OR BLA_VENDOR STREQUAL "All") endif() endif() -# BLAS in IBM ESSL library? (requires generic BLAS lib, too) -if(BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All") +# BLAS in IBM ESSL library? +if(BLA_VENDOR MATCHES "IBMESSL" OR BLA_VENDOR STREQUAL "All") + set(_blas_essl_lib "essl") + + if(BLA_VENDOR MATCHES "_SMP") + string(APPEND _blas_essl_lib "smp") + endif() + if(_blas_sizeof_integer EQUAL 8) + string(APPEND _blas_essl_lib "6464") + endif() + if(NOT BLAS_LIBRARIES) check_blas_libraries( BLAS_LIBRARIES BLAS sgemm "" - "essl;blas" + "${_blas_essl_lib}" "" "" "" ) endif() + + unset(_blas_essl_lib) endif() # BLAS in acml library? @@ -927,7 +1025,7 @@ if(BLA_VENDOR MATCHES "ACML" OR BLA_VENDOR STREQUAL "All") list(GET _ACML_GPU_ROOT 0 _ACML_GPU_ROOT) if(_ACML_ROOT) get_filename_component(_ACML_ROOT ${_ACML_ROOT} PATH) - if(SIZEOF_INTEGER EQUAL 8) + if(_blas_sizeof_integer EQUAL 8) set(_ACML_PATH_SUFFIX "_int64") else() set(_ACML_PATH_SUFFIX "") @@ -1054,102 +1152,179 @@ endif() # ACML # Apple BLAS library? if(BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") + if(_blas_sizeof_integer EQUAL 8) + if(BLA_VENDOR STREQUAL "Apple") + message(FATAL_ERROR "Accelerate Framework does not support Int64 type") + endif() + else() + if(NOT BLAS_LIBRARIES) + check_blas_libraries( + BLAS_LIBRARIES + BLAS + dgemm + "" + "Accelerate" + "" + "" + "" + ) + endif() + endif() +endif() + +# Apple NAS (vecLib) library? +if(BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") + if(_blas_sizeof_integer EQUAL 8) + if(BLA_VENDOR STREQUAL "NAS") + message(FATAL_ERROR "Accelerate Framework does not support Int64 type") + endif() + else() + if(NOT BLAS_LIBRARIES) + check_blas_libraries( + BLAS_LIBRARIES + BLAS + dgemm + "" + "vecLib" + "" + "" + "" + ) + endif() + endif() +endif() + +# Elbrus Math Library? +if(BLA_VENDOR MATCHES "EML" OR BLA_VENDOR STREQUAL "All") + + set(_blas_eml_lib "eml") + + if(_blas_sizeof_integer EQUAL 8) + string(APPEND _blas_eml_lib "_ilp64") + endif() + # Check for OpenMP support, VIA BLA_VENDOR of eml_mt + if(BLA_VENDOR MATCHES "_mt") + string(APPEND _blas_eml_lib "_mt") + endif() + if(NOT BLAS_LIBRARIES) check_blas_libraries( BLAS_LIBRARIES BLAS - dgemm + sgemm "" - "Accelerate" + "${_blas_eml_lib}" "" "" "" ) endif() + unset(_blas_eml_lib) endif() -# Apple NAS (vecLib) library? -if(BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") +# Fujitsu SSL2 Library? +if(NOT BLAS_LIBRARIES + AND (BLA_VENDOR MATCHES "^Fujitsu_SSL2" OR BLA_VENDOR STREQUAL "All")) + set(_blas_fjlapack_lib "fjlapack") + set(_blas_fjlapack_flags "-Kopenmp") + + if(BLA_VENDOR MATCHES "BLAMP") + string(APPEND _blas_fjlapack_lib "ex") + endif() + if(BLA_VENDOR MATCHES "SVE") + string(APPEND _blas_fjlapack_lib "sve") + endif() + if(_blas_sizeof_integer EQUAL 8) + string(APPEND _blas_fjlapack_lib "_ilp64") + endif() + if(NOT BLAS_LIBRARIES) check_blas_libraries( BLAS_LIBRARIES BLAS - dgemm - "" - "vecLib" + sgemm + "${_blas_fjlapack_flags}" + "${_blas_fjlapack_lib}" "" "" "" ) + if(BLAS_LIBRARIES) + set(BLAS_LINKER_FLAGS ${_blas_fjlapack_flags}) + endif() endif() -endif() -# Elbrus Math Library? -if(BLA_VENDOR MATCHES "EML" OR BLA_VENDOR STREQUAL "All") + unset(_blas_fjlapack_flags) + unset(_blas_fjlapack_lib) +endif() - set(BLAS_EML_LIB "eml") +# BLAS in nVidia HPC SDK? (https://developer.nvidia.com/hpc-sdk) +if(BLA_VENDOR STREQUAL "NVHPC" OR BLA_VENDOR STREQUAL "All") + set(_blas_nvhpc_lib "blas") - # Check for OpenMP support, VIA BLA_VENDOR of eml_mt - if(BLA_VENDOR MATCHES "_mt") - set(BLAS_EML_LIB "${BLAS_EML_LIB}_mt") - endif() + if(_blas_sizeof_integer EQUAL 8) + string(APPEND _blas_nvhpc_lib "_ilp64") + elseif(_blas_sizeof_integer EQUAL 4) + string(APPEND _blas_nvhpc_lib "_lp64") + endif() - if(NOT BLAS_LIBRARIES) + if(NOT BLAS_LIBRARIES) check_blas_libraries( BLAS_LIBRARIES BLAS sgemm "" - "${BLAS_EML_LIB}" + "${_blas_nvhpc_lib}" "" "" "" ) endif() -endif() + # an additional check for NVHPC 2020 + # which does not have differentiation + # between lp64 and ilp64 modes + if(NOT BLAS_LIBRARIES AND NOT _blas_sizeof_integer EQUAL 8) + set(_blas_nvhpc_lib "blas") -# Fujitsu SSL2 Library? -if(NOT BLAS_LIBRARIES - AND (BLA_VENDOR MATCHES "Fujitsu_SSL2" OR BLA_VENDOR STREQUAL "All")) - if(BLA_VENDOR STREQUAL "Fujitsu_SSL2BLAMP") - set(_ssl2_suffix BLAMP) - else() - set(_ssl2_suffix) - endif() - check_blas_libraries( - BLAS_LIBRARIES - BLAS - sgemm - "-SSL2${_ssl2_suffix}" - "" - "" - "" - "" - ) - if(BLAS_LIBRARIES) - set(BLAS_LINKER_FLAGS "-SSL2${_ssl2_suffix}") - set(_blas_fphsa_req_var BLAS_LINKER_FLAGS) + check_blas_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "${_blas_nvhpc_lib}" + "" + "" + "" + ) endif() - unset(_ssl2_suffix) + + unset(_blas_nvhpc_lib) endif() # Generic BLAS library? if(BLA_VENDOR STREQUAL "Generic" OR - BLA_VENDOR STREQUAL "NVHPC" OR BLA_VENDOR STREQUAL "All") + set(_blas_generic_lib "blas") + + if(_blas_sizeof_integer EQUAL 8) + string(APPEND _blas_generic_lib "64") + endif() + if(NOT BLAS_LIBRARIES) check_blas_libraries( BLAS_LIBRARIES BLAS sgemm "" - "blas" + "${_blas_generic_lib}" "" "" "" ) endif() + + unset(_blas_generic_lib) endif() # On compilers that implicitly link BLAS (i.e. CrayPrgEnv) we used a @@ -1163,3 +1338,6 @@ if(NOT BLA_F95) endif() _add_blas_target() +unset(_blas_fphsa_req_var) +unset(_blas_sizeof_integer) +unset(_BLAS_LIBRARIES) diff --git a/Modules/FindCUDAToolkit.cmake b/Modules/FindCUDAToolkit.cmake index 89b8c997c..d22a6765e 100644 --- a/Modules/FindCUDAToolkit.cmake +++ b/Modules/FindCUDAToolkit.cmake @@ -742,6 +742,19 @@ elseif(NOT CUDAToolkit_FIND_QUIETLY) message(STATUS "Unable to find cuda_runtime.h in \"${CUDAToolkit_TARGET_DIR}/include\" for CUDAToolkit_INCLUDE_DIR.") endif() +# The NVHPC layout moves math library headers and libraries to a sibling directory. +# Create a separate variable so this directory can be selectively added to math targets. +if(NOT EXISTS "${CUDAToolkit_INCLUDE_DIR}/cublas_v2.h") + set(CUDAToolkit_MATH_INCLUDE_DIR "${CUDAToolkit_TARGET_DIR}/../../math_libs/include") + cmake_path(NORMAL_PATH CUDAToolkit_MATH_INCLUDE_DIR) + if(NOT EXISTS "${CUDAToolkit_MATH_INCLUDE_DIR}/cublas_v2.h") + if(NOT CUDAToolkit_FIND_QUIETLY) + message(STATUS "Unable to find cublas_v2.h in either \"${CUDAToolkit_INCLUDE_DIR}\" or \"${CUDAToolkit_MATH_INCLUDE_DIR}\"") + endif() + unset(CUDAToolkit_MATH_INCLUDE_DIR) + endif() +endif() + if(CUDAToolkit_NVCC_EXECUTABLE AND CMAKE_CUDA_COMPILER_VERSION AND CUDAToolkit_NVCC_EXECUTABLE STREQUAL CMAKE_CUDA_COMPILER) @@ -844,14 +857,23 @@ if(CUDAToolkit_FOUND) HINTS ${CUDAToolkit_LIBRARY_DIR} ENV CUDA_PATH PATH_SUFFIXES lib64/stubs lib/x64/stubs lib/stubs stubs + # Support NVHPC splayed math library layout + ../../math_libs/${CUDAToolkit_VERSION_MAJOR}.${CUDAToolkit_VERSION_MINOR}/lib64 + ../../math_libs/lib64 ) mark_as_advanced(CUDA_${lib_name}_LIBRARY) if (NOT TARGET CUDA::${lib_name} AND CUDA_${lib_name}_LIBRARY) - add_library(CUDA::${lib_name} IMPORTED INTERFACE) + add_library(CUDA::${lib_name} UNKNOWN IMPORTED) target_include_directories(CUDA::${lib_name} SYSTEM INTERFACE "${CUDAToolkit_INCLUDE_DIRS}") - target_link_libraries(CUDA::${lib_name} INTERFACE "${CUDA_${lib_name}_LIBRARY}") + if(DEFINED CUDAToolkit_MATH_INCLUDE_DIR) + string(FIND ${CUDA_${lib_name}_LIBRARY} "math_libs" math_libs) + if(NOT ${math_libs} EQUAL -1) + target_include_directories(CUDA::${lib_name} SYSTEM INTERFACE "${CUDAToolkit_MATH_INCLUDE_DIR}") + endif() + endif() + set_property(TARGET CUDA::${lib_name} PROPERTY IMPORTED_LOCATION "${CUDA_${lib_name}_LIBRARY}") foreach(dep ${arg_DEPS}) if(TARGET CUDA::${dep}) target_link_libraries(CUDA::${lib_name} INTERFACE CUDA::${dep}) diff --git a/Modules/FindFLTK.cmake b/Modules/FindFLTK.cmake index bab72560d..d54d2f68b 100644 --- a/Modules/FindFLTK.cmake +++ b/Modules/FindFLTK.cmake @@ -152,13 +152,17 @@ if(NOT FLTK_DIR) endif() # Check if FLTK was built using CMake -if(EXISTS ${FLTK_DIR}/FLTKConfig.cmake) - set(FLTK_BUILT_WITH_CMAKE 1) -endif() +foreach(fltk_include IN LISTS FLTK_DIR) + if(EXISTS "${fltk_include}/FLTKConfig.cmake") + set(FLTK_BUILT_WITH_CMAKE 1) + set(FLTK_CMAKE_PATH "${fltk_include}/FLTKConfig.cmake") + break() + endif() +endforeach() if(FLTK_BUILT_WITH_CMAKE) set(FLTK_FOUND 1) - include(${FLTK_DIR}/FLTKConfig.cmake) + include("${FLTK_CMAKE_PATH}") # Fluid if(FLUID_COMMAND) diff --git a/Modules/FindGLUT.cmake b/Modules/FindGLUT.cmake index 2770c604d..dd0975d39 100644 --- a/Modules/FindGLUT.cmake +++ b/Modules/FindGLUT.cmake @@ -41,8 +41,43 @@ Also defined, but not for general use are: #]=======================================================================] include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -if (WIN32) +function(_add_glut_target_simple) + if(TARGET GLUT::GLUT) + return() + endif() + add_library(GLUT::GLUT INTERFACE IMPORTED) + if(GLUT_INCLUDE_DIRS) + target_include_directories(GLUT::GLUT SYSTEM + INTERFACE "${GLUT_INCLUDE_DIRS}") + endif() + if(GLUT_LIBRARIES) + target_link_libraries(GLUT::GLUT INTERFACE ${GLUT_LIBRARIES}) + endif() + if(GLUT_LDFLAGS) + target_link_options(GLUT::GLUT INTERFACE ${GLUT_LDFLAGS}) + endif() + if(GLUT_CFLAGS) + separate_arguments(GLUT_CFLAGS_SPLIT UNIX_COMMAND "${GLUT_CFLAGS}") + target_compile_options(GLUT::GLUT INTERFACE ${GLUT_CFLAGS_SPLIT}) + endif() + + set_property(TARGET GLUT::GLUT APPEND PROPERTY + IMPORTED_LOCATION "${GLUT_glut_LIBRARY}") +endfunction() + +find_package(PkgConfig) +if(PKG_CONFIG_FOUND) + pkg_check_modules(GLUT glut) + if(GLUT_FOUND) + _add_glut_target_simple() + FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLUT REQUIRED_VARS GLUT_FOUND) + return() + endif() +endif() + +if(WIN32) find_path( GLUT_INCLUDE_DIR NAMES GL/glut.h PATHS ${GLUT_ROOT_PATH}/include ) find_library( GLUT_glut_LIBRARY_RELEASE NAMES glut glut32 freeglut @@ -57,85 +92,75 @@ if (WIN32) ) mark_as_advanced(GLUT_glut_LIBRARY_RELEASE GLUT_glut_LIBRARY_DEBUG) select_library_configurations(GLUT_glut) -else () - - if (APPLE) - find_path(GLUT_INCLUDE_DIR glut.h ${OPENGL_LIBRARY_DIR}) - find_library(GLUT_glut_LIBRARY GLUT DOC "GLUT library for OSX") - find_library(GLUT_cocoa_LIBRARY Cocoa DOC "Cocoa framework for OSX") - mark_as_advanced(GLUT_glut_LIBRARY GLUT_cocoa_LIBRARY) - - if(GLUT_cocoa_LIBRARY AND NOT TARGET GLUT::Cocoa) - add_library(GLUT::Cocoa UNKNOWN IMPORTED) - # Cocoa should always be a Framework, but we check to make sure. - if(GLUT_cocoa_LIBRARY MATCHES "/([^/]+)\\.framework$") - set(_glut_cocoa "${GLUT_cocoa_LIBRARY}/${CMAKE_MATCH_1}") - if(EXISTS "${_glut_cocoa}.tbd") - string(APPEND _glut_cocoa ".tbd") - endif() - set_target_properties(GLUT::Cocoa PROPERTIES - IMPORTED_LOCATION "${_glut_cocoa}") - else() - set_target_properties(GLUT::Cocoa PROPERTIES - IMPORTED_LOCATION "${GLUT_cocoa_LIBRARY}") +elseif(APPLE) + find_path(GLUT_INCLUDE_DIR glut.h ${OPENGL_LIBRARY_DIR}) + find_library(GLUT_glut_LIBRARY GLUT DOC "GLUT library for OSX") + find_library(GLUT_cocoa_LIBRARY Cocoa DOC "Cocoa framework for OSX") + mark_as_advanced(GLUT_glut_LIBRARY GLUT_cocoa_LIBRARY) + + if(GLUT_cocoa_LIBRARY AND NOT TARGET GLUT::Cocoa) + add_library(GLUT::Cocoa UNKNOWN IMPORTED) + # Cocoa should always be a Framework, but we check to make sure. + if(GLUT_cocoa_LIBRARY MATCHES "/([^/]+)\\.framework$") + set(_glut_cocoa "${GLUT_cocoa_LIBRARY}/${CMAKE_MATCH_1}") + if(EXISTS "${_glut_cocoa}.tbd") + string(APPEND _glut_cocoa ".tbd") endif() - endif() - else () - - if (BEOS) - - set(_GLUT_INC_DIR /boot/develop/headers/os/opengl) - set(_GLUT_glut_LIB_DIR /boot/develop/lib/x86) - + set_target_properties(GLUT::Cocoa PROPERTIES + IMPORTED_LOCATION "${_glut_cocoa}") else() - - find_library( GLUT_Xi_LIBRARY Xi - /usr/openwin/lib - ) - mark_as_advanced(GLUT_Xi_LIBRARY) - - find_library( GLUT_Xmu_LIBRARY Xmu - /usr/openwin/lib - ) - mark_as_advanced(GLUT_Xmu_LIBRARY) - - if(GLUT_Xi_LIBRARY AND NOT TARGET GLUT::Xi) - add_library(GLUT::Xi UNKNOWN IMPORTED) - set_target_properties(GLUT::Xi PROPERTIES - IMPORTED_LOCATION "${GLUT_Xi_LIBRARY}") - endif() - - if(GLUT_Xmu_LIBRARY AND NOT TARGET GLUT::Xmu) - add_library(GLUT::Xmu UNKNOWN IMPORTED) - set_target_properties(GLUT::Xmu PROPERTIES - IMPORTED_LOCATION "${GLUT_Xmu_LIBRARY}") - endif() - - endif () - - find_path( GLUT_INCLUDE_DIR GL/glut.h - /usr/include/GL - /usr/openwin/share/include - /usr/openwin/include - /opt/graphics/OpenGL/include - /opt/graphics/OpenGL/contrib/libglut - ${_GLUT_INC_DIR} + set_target_properties(GLUT::Cocoa PROPERTIES + IMPORTED_LOCATION "${GLUT_cocoa_LIBRARY}") + endif() + endif() +else() + if(BEOS) + set(_GLUT_INC_DIR /boot/develop/headers/os/opengl) + set(_GLUT_glut_LIB_DIR /boot/develop/lib/x86) + else() + find_library( GLUT_Xi_LIBRARY Xi + /usr/openwin/lib ) + mark_as_advanced(GLUT_Xi_LIBRARY) - find_library( GLUT_glut_LIBRARY glut + find_library( GLUT_Xmu_LIBRARY Xmu /usr/openwin/lib - ${_GLUT_glut_LIB_DIR} ) - mark_as_advanced(GLUT_glut_LIBRARY) + mark_as_advanced(GLUT_Xmu_LIBRARY) - unset(_GLUT_INC_DIR) - unset(_GLUT_glut_LIB_DIR) + if(GLUT_Xi_LIBRARY AND NOT TARGET GLUT::Xi) + add_library(GLUT::Xi UNKNOWN IMPORTED) + set_target_properties(GLUT::Xi PROPERTIES + IMPORTED_LOCATION "${GLUT_Xi_LIBRARY}") + endif() + + if(GLUT_Xmu_LIBRARY AND NOT TARGET GLUT::Xmu) + add_library(GLUT::Xmu UNKNOWN IMPORTED) + set_target_properties(GLUT::Xmu PROPERTIES + IMPORTED_LOCATION "${GLUT_Xmu_LIBRARY}") + endif() endif () -endif () + find_path( GLUT_INCLUDE_DIR GL/glut.h + /usr/include/GL + /usr/openwin/share/include + /usr/openwin/include + /opt/graphics/OpenGL/include + /opt/graphics/OpenGL/contrib/libglut + ${_GLUT_INC_DIR} + ) + + find_library( GLUT_glut_LIBRARY glut + /usr/openwin/lib + ${_GLUT_glut_LIB_DIR} + ) + + unset(_GLUT_INC_DIR) + unset(_GLUT_glut_LIB_DIR) +endif() +mark_as_advanced(GLUT_glut_LIBRARY) -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLUT REQUIRED_VARS GLUT_glut_LIBRARY GLUT_INCLUDE_DIR) if (GLUT_FOUND) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index e33535513..6cadadb90 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -161,6 +161,8 @@ include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) # scope somewhere else. We can't rely on it because different components may # have been requested for this call. set(HDF5_FOUND OFF) +set(HDF5_LIBRARIES) +set(HDF5_HL_LIBRARIES) # List of the valid HDF5 components set(HDF5_VALID_LANGUAGE_BINDINGS C CXX Fortran) @@ -560,7 +562,7 @@ if(NOT HDF5_FOUND AND NOT HDF5_NO_FIND_PACKAGE_CONFIG_FILE) set(HDF5_${_lang}_FOUND TRUE) endif() if(HDF5_FIND_HL) - get_target_property(_lang_hl_location ${HDF5_${_lang}_HL_TARGET}${_suffix} IMPORTED_IMPLIB_${_hdf5_imported_conf} ) + get_target_property(_hdf5_lang_hl_location ${HDF5_${_lang}_HL_TARGET}${_suffix} IMPORTED_IMPLIB_${_hdf5_imported_conf} ) if (NOT _hdf5_lang_hl_location) get_target_property(_hdf5_lang_hl_location ${HDF5_${_lang}_HL_TARGET}${_suffix} LOCATION_${_hdf5_imported_conf}) if (NOT _hdf5_hl_lang_location) @@ -586,6 +588,9 @@ if(NOT HDF5_FOUND) set(HDF5_COMPILER_NO_INTERROGATE TRUE) # Only search for languages we've enabled foreach(_lang IN LISTS HDF5_LANGUAGE_BINDINGS) + set(HDF5_${_lang}_LIBRARIES) + set(HDF5_${_lang}_HL_LIBRARIES) + # First check to see if our regular compiler is one of wrappers if(_lang STREQUAL "C") _HDF5_test_regular_compiler_C( @@ -811,6 +816,9 @@ if( NOT HDF5_FOUND ) endif() foreach(_lang IN LISTS HDF5_LANGUAGE_BINDINGS) + set(HDF5_${_lang}_LIBRARIES) + set(HDF5_${_lang}_HL_LIBRARIES) + # The "main" library. set(_hdf5_main_library "") diff --git a/Modules/FindICU.cmake b/Modules/FindICU.cmake index 2bb49adec..1bae825a5 100644 --- a/Modules/FindICU.cmake +++ b/Modules/FindICU.cmake @@ -172,7 +172,7 @@ function(_ICU_FIND) DOC "ICU ${program} executable" NO_PACKAGE_ROOT_PATH ) - mark_as_advanced(cache_var) + mark_as_advanced("${cache_var}") set("${program_var}" "${${cache_var}}" PARENT_SCOPE) endforeach() @@ -301,7 +301,7 @@ function(_ICU_FIND) HINTS ${icu_roots} PATH_SUFFIXES ${icu_data_suffixes} DOC "ICU ${data} data file") - mark_as_advanced(cache_var) + mark_as_advanced("${cache_var}") set("${data_var}" "${${cache_var}}" PARENT_SCOPE) endforeach() diff --git a/Modules/FindJasper.cmake b/Modules/FindJasper.cmake index 729a50350..9a62669f2 100644 --- a/Modules/FindJasper.cmake +++ b/Modules/FindJasper.cmake @@ -5,43 +5,86 @@ FindJasper ---------- -Try to find the Jasper JPEG2000 library +Find the Jasper JPEG2000 library. -Once done this will define +IMPORTED Targets +^^^^^^^^^^^^^^^^ -:: +``Jasper::Jasper`` + The jasper library, if found. - JASPER_FOUND - system has Jasper - JASPER_INCLUDE_DIR - the Jasper include directory - JASPER_LIBRARIES - the libraries needed to use Jasper - JASPER_VERSION_STRING - the version of Jasper found (since CMake 2.8.8) -#]=======================================================================] +Result Variables +^^^^^^^^^^^^^^^^ -find_path(JASPER_INCLUDE_DIR jasper/jasper.h) +This module defines the following variables: + +``JASPER_FOUND`` + system has Jasper +``JASPER_INCLUDE_DIRS`` + .. versionadded:: 3.22 + + the Jasper include directory +``JASPER_LIBRARIES`` + the libraries needed to use Jasper +``JASPER_VERSION_STRING`` + the version of Jasper found + +Cache variables +^^^^^^^^^^^^^^^ -if (NOT JASPER_LIBRARIES) - find_package(JPEG) +The following cache variables may also be set: - find_library(JASPER_LIBRARY_RELEASE NAMES jasper libjasper) - find_library(JASPER_LIBRARY_DEBUG NAMES jasperd) +``JASPER_INCLUDE_DIR`` + where to find jasper/jasper.h, etc. +``JASPER_LIBRARY_RELEASE`` + where to find the Jasper library (optimized). +``JASPER_LIBARRY_DEBUG`` + where to find the Jasper library (debug). +#]=======================================================================] - include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) - SELECT_LIBRARY_CONFIGURATIONS(JASPER) -endif () +find_path(JASPER_INCLUDE_DIR jasper/jasper.h) +mark_as_advanced(JASPER_INCLUDE_DIR) -if (JASPER_INCLUDE_DIR AND EXISTS "${JASPER_INCLUDE_DIR}/jasper/jas_config.h") - file(STRINGS "${JASPER_INCLUDE_DIR}/jasper/jas_config.h" jasper_version_str REGEX "^#define[\t ]+JAS_VERSION[\t ]+\".*\".*") +if(NOT JASPER_LIBRARIES) + find_package(JPEG) + find_library(JASPER_LIBRARY_RELEASE NAMES jasper libjasper) + find_library(JASPER_LIBRARY_DEBUG NAMES jasperd) + include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) + select_library_configurations(JASPER) +endif() - string(REGEX REPLACE "^#define[\t ]+JAS_VERSION[\t ]+\"([^\"]+)\".*" "\\1" JASPER_VERSION_STRING "${jasper_version_str}") -endif () +if(JASPER_INCLUDE_DIR AND EXISTS "${JASPER_INCLUDE_DIR}/jasper/jas_config.h") + file(STRINGS "${JASPER_INCLUDE_DIR}/jasper/jas_config.h" jasper_version_str REGEX "^#define[\t ]+JAS_VERSION[\t ]+\".*\".*") + string(REGEX REPLACE "^#define[\t ]+JAS_VERSION[\t ]+\"([^\"]+)\".*" "\\1" JASPER_VERSION_STRING "${jasper_version_str}") +endif() include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Jasper +find_package_handle_standard_args(Jasper REQUIRED_VARS JASPER_LIBRARIES JASPER_INCLUDE_DIR JPEG_LIBRARIES VERSION_VAR JASPER_VERSION_STRING) -if (JASPER_FOUND) - set(JASPER_LIBRARIES ${JASPER_LIBRARIES} ${JPEG_LIBRARIES} ) -endif () - -mark_as_advanced(JASPER_INCLUDE_DIR) +if(JASPER_FOUND) + set(JASPER_LIBRARIES ${JASPER_LIBRARIES} ${JPEG_LIBRARIES}) + set(JASPER_INCLUDE_DIRS ${JASPER_INCLUDE_DIR}) + if(NOT TARGET Jasper::Jasper) + add_library(Jasper::Jasper UNKNOWN IMPORTED) + if(JASPER_INCLUDE_DIRS) + set_target_properties(Jasper::Jasper PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${JASPER_INCLUDE_DIRS}") + endif() + if(EXISTS "${JASPER_LIBRARY_RELEASE}") + set_property(TARGET Jasper::Jasper APPEND PROPERTY + IMPORTED CONFIGURATION RELEASE) + set_target_properties(Jasper::Jasper PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C" + IMPORTED_LOCATION "${JASPER_LIBRARY_RELEASE}") + endif() + if(EXISTS "${JASPER_LIBRARY_DEBUG}") + set_property(TARGET Jasper::Jasper APPEND PROPERTY + IMPORTED CONFIGURATION DEBUG) + set_target_properties(Jasper::Jasper PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C" + IMPORTED_LOCATION "${JASPER_LIBRARY_DEBUG}") + endif() + endif() +endif() diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 3146e06d4..5540965e5 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -35,6 +35,19 @@ The following variables may be set to influence this module's behavior: if set ``pkg-config`` will be used to search for a LAPACK library first and if one is found that is preferred +``BLA_SIZEOF_INTEGER`` + .. versionadded:: 3.22 + + Specify the BLAS/LAPACK library integer size: + + ``4`` + Search for a BLAS/LAPACK with 32-bit integer interfaces. + ``8`` + Search for a BLAS/LAPACK with 64-bit integer interfaces. + ``ANY`` + Search for any BLAS/LAPACK. + Most likely, a BLAS/LAPACK with 32-bit integer interfaces will be found. + Imported targets ^^^^^^^^^^^^^^^^ @@ -168,9 +181,9 @@ function(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addl list(APPEND _libraries "${_library}") else() string(REGEX REPLACE "[^A-Za-z0-9]" "_" _lib_var "${_library}") - set(_combined_name ${_combined_name}_${_lib_var}) + string(APPEND _combined_name "_${_lib_var}") if(NOT "${_deps}" STREQUAL "") - set(_combined_name ${_combined_name}_deps) + string(APPEND _combined_name "_deps") endif() if(_libraries_work) find_library(${_prefix}_${_lib_var}_LIBRARY @@ -188,7 +201,7 @@ function(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addl foreach(_flag ${_flags}) string(REGEX REPLACE "[^A-Za-z0-9]" "_" _flag_var "${_flag}") - set(_combined_name ${_combined_name}_${_flag_var}) + string(APPEND _combined_name "_${_flag_var}") endforeach() if(_libraries_work) # Test this combination of libraries. @@ -247,6 +260,17 @@ if(NOT (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED OR CMAKE_Fortran_CO "FindLAPACK requires Fortran, C, or C++ to be enabled.") endif() +if(NOT BLA_SIZEOF_INTEGER) + # in the reality we do not know which API of BLAS/LAPACK is masked in library + set(_lapack_sizeof_integer "ANY") +elseif((BLA_SIZEOF_INTEGER STREQUAL "ANY") OR + (BLA_SIZEOF_INTEGER STREQUAL "4") OR + (BLA_SIZEOF_INTEGER STREQUAL "8")) + set(_lapack_sizeof_integer ${BLA_SIZEOF_INTEGER}) +else() + message(FATAL_ERROR "BLA_SIZEOF_INTEGER can have only <no value>, ANY, 4, or 8 values") +endif() + # Load BLAS if(NOT LAPACK_NOT_FOUND_MESSAGE) _lapack_find_dependency(BLAS) @@ -288,17 +312,23 @@ if(NOT LAPACK_NOT_FOUND_MESSAGE) _lapack_find_dependency(Threads) - if(BLA_VENDOR MATCHES "_64ilp") + if(_lapack_sizeof_integer EQUAL 8) set(LAPACK_mkl_ILP_MODE "ilp64") - else() + elseif(_lapack_sizeof_integer EQUAL 4) set(LAPACK_mkl_ILP_MODE "lp64") + else() + if(BLA_VENDOR MATCHES "_64ilp") + set(LAPACK_mkl_ILP_MODE "ilp64") + else() + set(LAPACK_mkl_ILP_MODE "lp64") + endif() endif() set(LAPACK_SEARCH_LIBS "") if(BLA_F95) set(LAPACK_mkl_SEARCH_SYMBOL "cheev_f95") - set(_LIBRARIES LAPACK95_LIBRARIES) + set(_LAPACK_LIBRARIES LAPACK95_LIBRARIES) set(_BLAS_LIBRARIES ${BLAS95_LIBRARIES}) # old @@ -311,7 +341,7 @@ if(NOT LAPACK_NOT_FOUND_MESSAGE) "mkl_lapack95_${LAPACK_mkl_ILP_MODE}") else() set(LAPACK_mkl_SEARCH_SYMBOL "cheev") - set(_LIBRARIES LAPACK_LIBRARIES) + set(_LAPACK_LIBRARIES LAPACK_LIBRARIES) set(_BLAS_LIBRARIES ${BLAS_LIBRARIES}) # old and new >= 10.3 @@ -350,10 +380,10 @@ if(NOT LAPACK_NOT_FOUND_MESSAGE) "lib/${LAPACK_mkl_ARCH_NAME}" ) - # First try empty lapack libs - if(NOT ${_LIBRARIES}) + # First try empty lapack libs (implicitly linked or automatic from BLAS) + if(NOT ${_LAPACK_LIBRARIES}) check_lapack_libraries( - ${_LIBRARIES} + ${_LAPACK_LIBRARIES} LAPACK ${LAPACK_mkl_SEARCH_SYMBOL} "" @@ -363,18 +393,23 @@ if(NOT LAPACK_NOT_FOUND_MESSAGE) "${LAPACK_mkl_LIB_PATH_SUFFIXES}" "${_BLAS_LIBRARIES}" ) + if(LAPACK_WORKS AND NOT _BLAS_LIBRARIES) + # Give a more helpful "found" message + set(LAPACK_WORKS "implicitly linked") + set(_lapack_fphsa_req_var LAPACK_WORKS) + endif() endif() # Then try the search libs - foreach(IT ${LAPACK_SEARCH_LIBS}) - string(REPLACE " " ";" SEARCH_LIBS ${IT}) - if(NOT ${_LIBRARIES}) + foreach(_search ${LAPACK_SEARCH_LIBS}) + string(REPLACE " " ";" _search ${_search}) + if(NOT ${_LAPACK_LIBRARIES}) check_lapack_libraries( - ${_LIBRARIES} + ${_LAPACK_LIBRARIES} LAPACK ${LAPACK_mkl_SEARCH_SYMBOL} "" - "${SEARCH_LIBS}" + "${_search}" "${CMAKE_THREAD_LIBS_INIT};${LAPACK_mkl_LM};${LAPACK_mkl_LDL}" "${LAPACK_mkl_MKLROOT}" "${LAPACK_mkl_LIB_PATH_SUFFIXES}" @@ -383,6 +418,7 @@ if(NOT LAPACK_NOT_FOUND_MESSAGE) endif() endforeach() + unset(_search) unset(LAPACK_mkl_ILP_MODE) unset(LAPACK_mkl_SEARCH_SYMBOL) unset(LAPACK_mkl_LM) @@ -412,48 +448,70 @@ if(NOT LAPACK_NOT_FOUND_MESSAGE) # FlexiBLAS? (http://www.mpi-magdeburg.mpg.de/mpcsc/software/FlexiBLAS/) if(NOT LAPACK_LIBRARIES AND (BLA_VENDOR STREQUAL "FlexiBLAS" OR BLA_VENDOR STREQUAL "All")) + set(_lapack_flexiblas_lib "flexiblas") + + if(_lapack_sizeof_integer EQUAL 8) + string(APPEND _lapack_flexiblas_lib "64") + endif() + check_lapack_libraries( LAPACK_LIBRARIES LAPACK cheev "" - "flexiblas" + "${_lapack_flexiblas_lib}" "" "" "" "${BLAS_LIBRARIES}" ) + + unset(_lapack_flexiblas_lib) endif() # OpenBLAS? (http://www.openblas.net) if(NOT LAPACK_LIBRARIES AND (BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All")) + set(_lapack_openblas_lib "openblas") + + if(_lapack_sizeof_integer EQUAL 8) + string(APPEND _lapack_openblas_lib "64") + endif() + check_lapack_libraries( LAPACK_LIBRARIES LAPACK cheev "" - "openblas" + "${_lapack_openblas_lib}" "" "" "" "${BLAS_LIBRARIES}" ) + + unset(_lapack_openblas_lib) endif() # ArmPL? (https://developer.arm.com/tools-and-software/server-and-hpc/compile/arm-compiler-for-linux/arm-performance-libraries) if(NOT LAPACK_LIBRARIES AND (BLA_VENDOR MATCHES "Arm" OR BLA_VENDOR STREQUAL "All")) # Check for 64bit Integer support - if(BLA_VENDOR MATCHES "_ilp64") + if(_lapack_sizeof_integer EQUAL 8) set(LAPACK_armpl_LIB "armpl_ilp64") - else() + elseif(_lapack_sizeof_integer EQUAL 4) set(LAPACK_armpl_LIB "armpl_lp64") + else() + if(BLA_VENDOR MATCHES "_ilp64") + set(LAPACK_armpl_LIB "armpl_ilp64") + else() + set(LAPACK_armpl_LIB "armpl_lp64") + endif() endif() # Check for OpenMP support, VIA BLA_VENDOR of Arm_mp or Arm_ipl64_mp if(BLA_VENDOR MATCHES "_mp") - set(LAPACK_armpl_LIB "${LAPACK_armpl_LIB}_mp") + string(APPEND LAPACK_armpl_LIB "_mp") endif() check_lapack_libraries( @@ -472,17 +530,50 @@ if(NOT LAPACK_NOT_FOUND_MESSAGE) # FLAME's blis library? (https://github.com/flame/blis) if(NOT LAPACK_LIBRARIES AND (BLA_VENDOR STREQUAL "FLAME" OR BLA_VENDOR STREQUAL "All")) + if(_lapack_sizeof_integer EQUAL 8) + if(BLA_VENDOR STREQUAL "FLAME") + message(FATAL_ERROR "libFLAME does not support Int64 type") + endif() + else() + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "flame" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) + endif() + endif() + + # LAPACK in SCSL library? (SGI/Cray Scientific Library) + if(NOT LAPACK_LIBRARIES + AND (BLA_VENDOR MATCHES "SCSL" OR BLA_VENDOR STREQUAL "All")) + set(_lapack_scsl_lib "scs") + + if(_lapack_sizeof_integer EQUAL 8) + string(APPEND _lapack_scsl_lib "_i8") + endif() + # Check for OpenMP support, VIA BLA_VENDOR of scs_mp + if(BLA_VENDOR MATCHES "_mp") + string(APPEND _lapack_scsl_lib "_mp") + endif() + check_lapack_libraries( LAPACK_LIBRARIES LAPACK cheev "" - "flame" + "${_lapack_scsl_lib}" "" "" "" "${BLAS_LIBRARIES}" ) + unset(_lapack_scsl_lib) endif() # BLAS in acml library? @@ -495,105 +586,116 @@ if(NOT LAPACK_NOT_FOUND_MESSAGE) # Apple LAPACK library? if(NOT LAPACK_LIBRARIES AND (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All")) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "Accelerate" - "" - "" - "" - "${BLAS_LIBRARIES}" - ) + if(_lapack_sizeof_integer EQUAL 8) + if(BLA_VENDOR STREQUAL "Apple") + message(FATAL_ERROR "Accelerate Framework does not support Int64 type") + endif() + else() + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "Accelerate" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) + endif() endif() # Apple NAS (vecLib) library? if(NOT LAPACK_LIBRARIES AND (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All")) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "vecLib" - "" - "" - "" - "${BLAS_LIBRARIES}" - ) + if(_lapack_sizeof_integer EQUAL 8) + if(BLA_VENDOR STREQUAL "NAS") + message(FATAL_ERROR "Accelerate Framework does not support Int64 type") + endif() + else() + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "vecLib" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) + endif() endif() # Elbrus Math Library? if(NOT LAPACK_LIBRARIES AND (BLA_VENDOR MATCHES "EML" OR BLA_VENDOR STREQUAL "All")) - - set(LAPACK_EML_LIB "eml") - - # Check for OpenMP support, VIA BLA_VENDOR of eml_mt - if(BLA_VENDOR MATCHES "_mt") - set(LAPACK_EML_LIB "${LAPACK_EML_LIB}_mt") + if(BLAS_LIBRARIES MATCHES "eml.+") + set(LAPACK_LIBRARIES ${BLAS_LIBRARIES}) endif() - - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "${LAPACK_EML_LIB}" - "" - "" - "" - "${BLAS_LIBRARIES}" - ) endif() # Fujitsu SSL2 Library? if(NOT LAPACK_LIBRARIES AND (BLA_VENDOR MATCHES "Fujitsu_SSL2" OR BLA_VENDOR STREQUAL "All")) - if(BLA_VENDOR STREQUAL "Fujitsu_SSL2BLAMP") - set(_ssl2_suffix BLAMP) - else() - set(_ssl2_suffix) - endif() - set(_ssl2_blas) - if(BLAS_LIBRARIES STREQUAL "") - set(_ssl2_blas "${BLAS_LINKER_FLAGS}") - else() - set(_ssl2_blas "${BLAS_LIBRARIES} ${BLAS_LINKER_FLAGS}") + if(BLAS_LIBRARIES MATCHES "fjlapack.+") + set(LAPACK_LIBRARIES ${BLAS_LIBRARIES}) + set(LAPACK_LINKER_FLAGS ${BLAS_LINKER_FLAGS}) endif() - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "-SSL2${_ssl2_suffix}" - "" - "" - "" - "" - "${_ssl2_blas}" - ) - if(LAPACK_LIBRARIES) - set(LAPACK_LINKER_FLAGS "-SSL2${_ssl2_suffix}") - set(_lapack_fphsa_req_var LAPACK_LINKER_FLAGS) + endif() + + # LAPACK in IBM ESSL library? + if(NOT LAPACK_LIBRARIES + AND (BLA_VENDOR MATCHES "IBMESSL" OR BLA_VENDOR STREQUAL "All")) + if(BLAS_LIBRARIES MATCHES "essl.+") + set(LAPACK_LIBRARIES ${BLAS_LIBRARIES}) endif() - unset(_ssl2_suffix) endif() # NVHPC Library? + if(NOT LAPACK_LIBRARIES AND (BLA_VENDOR MATCHES "NVHPC" OR BLA_VENDOR STREQUAL "All")) + set(_lapack_nvhpc_lib "lapack") + + if(_lapack_sizeof_integer EQUAL 8) + string(APPEND _lapack_nvhpc_lib "_ilp64") + elseif(_lapack_sizeof_integer EQUAL 4) + string(APPEND _lapack_nvhpc_lib "_lp64") + endif() + check_lapack_libraries( LAPACK_LIBRARIES LAPACK cheev "" - "lapack" + "${_lapack_nvhpc_lib}" "-fortranlibs" "" "" "${BLAS_LIBRARIES}" ) + + # an additional check for NVHPC 2020 + # which does not have differentiation + # between lp64 and ilp64 modes + if(NOT LAPACK_LIBRARIES AND NOT _lapack_sizeof_integer EQUAL 8) + set(_lapack_nvhpc_lib "lapack") + + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "${_lapack_nvhpc_lib}" + "-fortranlibs" + "" + "" + "${BLAS_LIBRARIES}" + ) + endif() + + unset(_lapack_nvhpc_lib) endif() # Generic LAPACK library? @@ -601,6 +703,7 @@ if(NOT LAPACK_NOT_FOUND_MESSAGE) AND (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All")) + set(_lapack_generic_lib "lapack") if(BLA_STATIC) # We do not know for sure how the LAPACK reference implementation # is built on this host. Guess typical dependencies. @@ -608,18 +711,25 @@ if(NOT LAPACK_NOT_FOUND_MESSAGE) else() set(_lapack_generic_deps "") endif() + + if(_lapack_sizeof_integer EQUAL 8) + string(APPEND _lapack_generic_lib "64") + endif() + check_lapack_libraries( LAPACK_LIBRARIES LAPACK cheev "" - "lapack" + "${_lapack_generic_lib}" "${_lapack_generic_deps}" "" "" "${BLAS_LIBRARIES}" ) + unset(_lapack_generic_deps) + unset(_lapack_generic_lib) endif() endif() @@ -646,3 +756,6 @@ if(LAPACK_LIBRARIES STREQUAL "LAPACK_LIBRARIES-PLACEHOLDER-FOR-EMPTY-LIBRARIES") endif() _add_lapack_target() +unset(_lapack_fphsa_req_var) +unset(_lapack_sizeof_integer) +unset(_LAPACK_LIBRARIES) diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index d8f033408..c974d3388 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -105,7 +105,7 @@ This module performs a four step search for an MPI implementation: 1. Search for ``MPIEXEC_EXECUTABLE`` and, if found, use its base directory. 2. Check if the compiler has MPI support built-in. This is the case if the user passed a - compiler wrapper as ``CMAKE_<LANG>_COMPILER`` or if they're on a Cray system. + compiler wrapper as ``CMAKE_<LANG>_COMPILER`` or if they use Cray system compiler wrappers. 3. Attempt to find an MPI compiler wrapper and determine the compiler information from it. 4. Try to find an MPI implementation that does not ship such a wrapper by guessing settings. Currently, only Microsoft MPI and MPICH2 on Windows are supported. @@ -267,6 +267,7 @@ cmake_policy(PUSH) cmake_policy(SET CMP0057 NEW) # if IN_LIST include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +find_package(PkgConfig QUIET) # Generic compiler names set(_MPI_C_GENERIC_COMPILER_NAMES mpicc mpcc mpicc_r mpcc_r) @@ -333,6 +334,11 @@ set(_MPI_XL_Fortran_COMPILER_NAMES mpixlf95 mpixlf95_r mpxlf95 mpxlf95 mpixlf77 mpixlf77_r mpxlf77 mpxlf77_r mpixlf mpixlf_r mpxlf mpxlf_r) +# Cray Compiler names +set(_MPI_Cray_C_COMPILER_NAMES cc) +set(_MPI_Cray_CXX_COMPILER_NAMES CC) +set(_MPI_Cray_Fortran_COMPILER_NAMES ftn) + # Prepend vendor-specific compiler wrappers to the list. If we don't know the compiler, # attempt all of them. # By attempting vendor-specific compiler names first, we should avoid situations where the compiler wrapper @@ -488,6 +494,26 @@ function (_MPI_interrogate_compiler LANG) endif() endif() + # Cray compiler wrappers come usually without a separate mpicc/c++/ftn, but offer + # --cray-print-opts=... + if (NOT MPI_COMPILER_RETURN EQUAL 0) + _MPI_check_compiler(${LANG} "--cray-print-opts=cflags" + MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) + + if (MPI_COMPILER_RETURN EQUAL 0) + # Pass --no-as-needed so the mpi library is always linked. Otherwise, the + # Cray compiler wrapper puts an --as-needed flag around the mpi library, + # and it is not linked unless code directly refers to it. + _MPI_check_compiler(${LANG} "--no-as-needed;--cray-print-opts=libs" + MPI_LINK_CMDLINE MPI_COMPILER_RETURN) + + if (NOT MPI_COMPILER_RETURN EQUAL 0) + unset(MPI_COMPILE_CMDLINE) + unset(MPI_LINK_CMDLINE) + endif() + endif() + endif() + # MPICH, MVAPICH2 and Intel MPI just use "-show". Open MPI also offers this, but the # -showme commands are more specialized. if (NOT MPI_COMPILER_RETURN EQUAL 0) @@ -1441,9 +1467,10 @@ foreach(LANG IN ITEMS C CXX Fortran) endif() if(_MPI_FIND_${LANG}) if( ${LANG} STREQUAL CXX AND NOT MPICXX IN_LIST MPI_FIND_COMPONENTS ) - set(MPI_CXX_SKIP_MPICXX FALSE CACHE BOOL "If true, the MPI-2 C++ bindings are disabled using definitions.") + option(MPI_CXX_SKIP_MPICXX "If true, the MPI-2 C++ bindings are disabled using definitions." FALSE) mark_as_advanced(MPI_CXX_SKIP_MPICXX) endif() + _MPI_adjust_compile_definitions(${LANG}) if(NOT (MPI_${LANG}_LIB_NAMES AND (MPI_${LANG}_INCLUDE_PATH OR MPI_${LANG}_INCLUDE_DIRS OR MPI_${LANG}_COMPILER_INCLUDE_DIRS))) set(MPI_${LANG}_TRIED_IMPLICIT FALSE) set(MPI_${LANG}_WORKS_IMPLICIT FALSE) @@ -1520,10 +1547,66 @@ foreach(LANG IN ITEMS C CXX Fortran) endif() endif() + # We are on a Cray, environment identfier: PE_ENV is set (CRAY), and + # have NOT found an mpic++-like compiler wrapper (previous block), + # and we do NOT use the Cray cc/CC compiler wrappers as CC/CXX CMake + # compiler. + # So as a last resort, we now interrogate cc/CC/ftn for MPI flags. + if(DEFINED ENV{PE_ENV} AND NOT "${MPI_${LANG}_COMPILER}") + set(MPI_PINNED_COMPILER TRUE) + find_program(MPI_${LANG}_COMPILER + NAMES ${_MPI_Cray_${LANG}_COMPILER_NAMES} + PATH_SUFFIXES bin sbin + DOC "MPI compiler for ${LANG}" + ) + + # If we haven't made the implicit compiler test yet, perform it now. + if(NOT MPI_${LANG}_TRIED_IMPLICIT) + _MPI_create_imported_target(${LANG}) + _MPI_check_lang_works(${LANG} TRUE) + endif() + + set(MPI_${LANG}_WORKS_IMPLICIT TRUE) + _MPI_interrogate_compiler(${LANG}) + endif() + if(NOT MPI_PINNED_COMPILER AND NOT MPI_${LANG}_WRAPPER_FOUND) # If MPI_PINNED_COMPILER wasn't given, and the MPI compiler we potentially found didn't work, we withdraw it. set(MPI_${LANG}_COMPILER "MPI_${LANG}_COMPILER-NOTFOUND" CACHE FILEPATH "MPI compiler for ${LANG}" FORCE) - if(NOT MPI_SKIP_GUESSING) + + if(LANG STREQUAL "C") + set(_MPI_PKG "mpi-c") + elseif(LANG STREQUAL "CXX") + set(_MPI_PKG "mpi-cxx") + elseif(LANG STREQUAL "Fortran") + set(_MPI_PKG "mpi-fort") + else() + set(_MPI_PKG "") + endif() + if(_MPI_PKG AND PKG_CONFIG_FOUND) + pkg_check_modules("MPI_${LANG}_PKG" "${_MPI_PKG}") + if("${MPI_${LANG}_PKG_FOUND}") + set(MPI_${LANG}_COMPILE_OPTIONS ${MPI_${LANG}_PKG_CFLAGS} CACHE STRING "MPI ${LANG} compilation options" FORCE) + set(MPI_${LANG}_INCLUDE_PATH ${MPI_${LANG}_PKG_INCLUDE_DIRS} CACHE STRING "MPI ${LANG} include directories" FORCE) + set(MPI_${LANG}_LINK_FLAGS ${MPI_${LANG}_PKG_LDFLAGS} CACHE STRING "MPI ${LANG} linker flags" FORCE) + set(MPI_${LANG}_LIB_NAMES ${MPI_${LANG}_PKG_LIBRARIES} CACHE STRING "MPI ${LANG} libraries to link against" FORCE) + foreach(_MPI_LIB IN LISTS MPI_${LANG}_LIB_NAMES) + if(_MPI_LIB) + get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB}" NAME_WE) + get_filename_component(_MPI_LIB_NAME "${_MPI_LIB}" NAME) + get_filename_component(_MPI_LIB_DIR "${_MPI_LIB}" DIRECTORY) + find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY + NAMES "${_MPI_LIB_NAME}" "lib${_MPI_LIB_NAME}" + HINTS ${_MPI_LIB_DIR} + DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI" + ) + mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY) + endif() + endforeach() + endif() + endif() + + if(NOT MPI_SKIP_GUESSING AND NOT "${MPI_${LANG}_PKG_FOUND}") # For C++, we may use the settings for C. Should a given compiler wrapper for C++ not exist, but one for C does, we copy over the # settings for C. An MPI distribution that is in this situation would be IBM Platform MPI. if("${LANG}" STREQUAL "CXX" AND MPI_C_WRAPPER_FOUND) @@ -1548,7 +1631,6 @@ foreach(LANG IN ITEMS C CXX Fortran) endif() _MPI_assemble_libraries(${LANG}) - _MPI_adjust_compile_definitions(${LANG}) # We always create imported targets even if they're empty _MPI_create_imported_target(${LANG}) diff --git a/Modules/FindMPI/test_mpi.c b/Modules/FindMPI/test_mpi.c index 7c96d54a8..70d7e1d3e 100644 --- a/Modules/FindMPI/test_mpi.c +++ b/Modules/FindMPI/test_mpi.c @@ -7,15 +7,15 @@ #endif #if defined(MPI_VERSION) && defined(MPI_SUBVERSION) -const char mpiver_str[] = { 'I', 'N', - 'F', 'O', - ':', 'M', - 'P', 'I', - '-', 'V', - 'E', 'R', - '[', ('0' + MPI_VERSION), - '.', ('0' + MPI_SUBVERSION), - ']', '\0' }; +const static char mpiver_str[] = { 'I', 'N', + 'F', 'O', + ':', 'M', + 'P', 'I', + '-', 'V', + 'E', 'R', + '[', ('0' + MPI_VERSION), + '.', ('0' + MPI_SUBVERSION), + ']', '\0' }; #endif int main(int argc, char* argv[]) diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake index e7cd834d9..0ca593e98 100644 --- a/Modules/FindMatlab.cmake +++ b/Modules/FindMatlab.cmake @@ -93,6 +93,33 @@ behavior: additional versions of Matlab for the automatic retrieval of the installed versions. +Imported targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 3.22 + +This module defines the following :prop_tgt:`IMPORTED` targets: + +``Matlab::mex`` + The ``mex`` library, always available. + +``Matlab::mx`` + The mx library of Matlab (arrays), always available. + +``Matlab::eng`` + Matlab engine library. Available only if the ``ENG_LIBRARY`` component + is requested. + +``Matlab::mat`` + Matlab matrix library. Available only if the ``MAT_LIBRARY`` component + is requested. + +``Matlab::MatlabEngine`` + Matlab C++ engine library, always available for R2018a and newer. + +``Matlab::MatlabDataArray`` + Matlab C++ data array library, always available for R2018a and newer. + Variables defined by the module ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -451,7 +478,7 @@ function(matlab_extract_all_installed_versions_from_registry win64 matlab_versio if(matlabs_from_registry) list(REMOVE_DUPLICATES matlabs_from_registry) - list(SORT matlabs_from_registry) + list(SORT matlabs_from_registry COMPARE NATURAL) list(REVERSE matlabs_from_registry) endif() @@ -495,7 +522,7 @@ macro(extract_matlab_versions_from_registry_brute_force matlab_versions) # we order from more recent to older if(matlab_supported_versions) list(REMOVE_DUPLICATES matlab_supported_versions) - list(SORT matlab_supported_versions) + list(SORT matlab_supported_versions COMPARE NATURAL) list(REVERSE matlab_supported_versions) endif() @@ -1545,6 +1572,29 @@ if(_numbers_of_matlab_roots GREATER 0) list(GET _matlab_possible_roots ${_matlab_or_mcr_index} Matlab_Or_MCR) list(GET _matlab_possible_roots ${_list_index} Matlab_VERSION_STRING) list(GET _matlab_possible_roots ${_matlab_root_dir_index} Matlab_ROOT_DIR) + elseif(DEFINED Matlab_FIND_VERSION) + foreach(_matlab_root_index RANGE 1 ${_numbers_of_matlab_roots} 3) + list(GET _matlab_possible_roots ${_matlab_root_index} _matlab_root_version) + if(_matlab_root_version VERSION_GREATER_EQUAL Matlab_FIND_VERSION) + set(_list_index ${_matlab_root_index}) + break() + endif() + endforeach() + + if(_list_index LESS 0) + set(_list_index 1) + endif() + + math(EXPR _matlab_or_mcr_index "${_list_index} - 1") + math(EXPR _matlab_root_dir_index "${_list_index} + 1") + list(GET _matlab_possible_roots ${_matlab_or_mcr_index} Matlab_Or_MCR) + list(GET _matlab_possible_roots ${_list_index} Matlab_VERSION_STRING) + list(GET _matlab_possible_roots ${_matlab_root_dir_index} Matlab_ROOT_DIR) + # adding a warning in case of ambiguity + if(_numbers_of_matlab_roots GREATER 3 AND MATLAB_FIND_DEBUG) + message(WARNING "[MATLAB] Found several distributions of Matlab. Setting the current version to ${Matlab_VERSION_STRING} (located ${Matlab_ROOT_DIR})." + " If this is not the desired behavior, use the EXACT keyword or provide the -DMatlab_ROOT_DIR=... on the command line") + endif() else() list(GET _matlab_possible_roots 0 Matlab_Or_MCR) list(GET _matlab_possible_roots 1 Matlab_VERSION_STRING) @@ -1866,6 +1916,32 @@ if(Matlab_DATAARRAY_LIBRARY) list(APPEND Matlab_LIBRARIES ${Matlab_DATAARRAY_LIBRARY}) endif() +# internal +# This small stub permits to add imported targets for the found MATLAB libraries +function(_Matlab_add_imported_target _matlab_library_variable_name _matlab_library_target_name) + if(Matlab_${_matlab_library_variable_name}_LIBRARY) + if(NOT TARGET Matlab::${_matlab_library_target_name}) + add_library(Matlab::${_matlab_library_target_name} UNKNOWN IMPORTED) + set_target_properties(Matlab::${_matlab_library_target_name} PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${Matlab_INCLUDE_DIRS}" + IMPORTED_LOCATION "${Matlab_${_matlab_library_variable_name}_LIBRARY}") + if(_matlab_library_target_name STREQUAL "mex" OR + _matlab_library_target_name STREQUAL "eng" OR + _matlab_library_target_name STREQUAL "mat") + set_target_properties(Matlab::${_matlab_library_target_name} PROPERTIES + INTERFACE_LINK_LIBRARIES Matlab::mx) + endif() + endif() + endif() +endfunction() + +_Matlab_add_imported_target(MX mx) +_Matlab_add_imported_target(MEX mex) +_Matlab_add_imported_target(ENG eng) +_Matlab_add_imported_target(MAT mat) +_Matlab_add_imported_target(ENGINE MatlabEngine) +_Matlab_add_imported_target(DATAARRAY MatlabDataArray) + find_package_handle_standard_args( Matlab FOUND_VAR Matlab_FOUND diff --git a/Modules/FindPatch.cmake b/Modules/FindPatch.cmake index 41086517d..f4fe4a614 100644 --- a/Modules/FindPatch.cmake +++ b/Modules/FindPatch.cmake @@ -43,7 +43,7 @@ endif() # First search the PATH find_program(Patch_EXECUTABLE - NAME patch + NAMES patch PATHS ${_patch_path} DOC ${_doc} ) diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index 01ad5ac6b..ef43a3ae9 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -12,11 +12,24 @@ Finds the ``pkg-config`` executable and adds the :command:`pkg_get_variable`, following variables will also be set: ``PKG_CONFIG_FOUND`` - if pkg-config executable was found -``PKG_CONFIG_EXECUTABLE`` - pathname of the pkg-config program + True if a pkg-config executable was found. + ``PKG_CONFIG_VERSION_STRING`` - version of pkg-config (since CMake 2.8.8) + .. versionadded:: 2.8.8 + + The version of pkg-config that was found. + +``PKG_CONFIG_EXECUTABLE`` + The pathname of the pkg-config program. + +``PKG_CONFIG_ARGN`` + .. versionadded:: 3.22 + + A list of arguments to pass to pkg-config. + +Both ``PKG_CONFIG_EXECUTABLE`` and ``PKG_CONFIG_ARGN`` are initialized by the +module, but may be overridden by the user. See `Variables Affecting Behavior`_ +for how these variables are initialized. #]========================================] @@ -29,13 +42,22 @@ set(PKG_CONFIG_VERSION 1) # find pkg-config, use PKG_CONFIG if set if((NOT PKG_CONFIG_EXECUTABLE) AND (NOT "$ENV{PKG_CONFIG}" STREQUAL "")) - set(PKG_CONFIG_EXECUTABLE "$ENV{PKG_CONFIG}" CACHE FILEPATH "pkg-config executable") + separate_arguments(PKG_CONFIG_FROM_ENV_SPLIT NATIVE_COMMAND PROGRAM SEPARATE_ARGS "$ENV{PKG_CONFIG}") + list(LENGTH PKG_CONFIG_FROM_ENV_SPLIT PKG_CONFIG_FROM_ENV_SPLIT_ARGC) + if(PKG_CONFIG_FROM_ENV_SPLIT_ARGC GREATER 0) + list(GET PKG_CONFIG_FROM_ENV_SPLIT 0 PKG_CONFIG_FROM_ENV_ARGV0) + if(PKG_CONFIG_FROM_ENV_SPLIT_ARGC GREATER 1) + list(SUBLIST PKG_CONFIG_FROM_ENV_SPLIT 1 -1 PKG_CONFIG_ARGN) + endif() + set(PKG_CONFIG_EXECUTABLE "${PKG_CONFIG_FROM_ENV_ARGV0}" CACHE FILEPATH "pkg-config executable") + endif() endif() set(PKG_CONFIG_NAMES "pkg-config") if(CMAKE_HOST_WIN32) list(PREPEND PKG_CONFIG_NAMES "pkg-config.bat") endif() +list(PREPEND PKG_CONFIG_NAMES "pkgconf") find_program(PKG_CONFIG_EXECUTABLE NAMES ${PKG_CONFIG_NAMES} @@ -43,9 +65,12 @@ find_program(PKG_CONFIG_EXECUTABLE DOC "pkg-config executable") mark_as_advanced(PKG_CONFIG_EXECUTABLE) +set(PKG_CONFIG_ARGN "${PKG_CONFIG_ARGN}" CACHE STRING "Arguments to supply to pkg-config") +mark_as_advanced(PKG_CONFIG_ARGN) + set(_PKG_CONFIG_FAILURE_MESSAGE "") if (PKG_CONFIG_EXECUTABLE) - execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --version + execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} ${PKG_CONFIG_ARGN} --version OUTPUT_VARIABLE PKG_CONFIG_VERSION_STRING OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_VARIABLE _PKG_CONFIG_VERSION_ERROR ERROR_STRIP_TRAILING_WHITESPACE RESULT_VARIABLE _PKG_CONFIG_VERSION_RESULT @@ -53,14 +78,18 @@ if (PKG_CONFIG_EXECUTABLE) if (NOT _PKG_CONFIG_VERSION_RESULT EQUAL 0) string(REPLACE "\n" "\n " _PKG_CONFIG_VERSION_ERROR " ${_PKG_CONFIG_VERSION_ERROR}") + if(PKG_CONFIG_ARGN) + string(REPLACE ";" " " PKG_CONFIG_ARGN " ${PKG_CONFIG_ARGN}") + endif() string(APPEND _PKG_CONFIG_FAILURE_MESSAGE "The command\n" - " \"${PKG_CONFIG_EXECUTABLE}\" --version\n" + " \"${PKG_CONFIG_EXECUTABLE}\"${PKG_CONFIG_ARGN} --version\n" " failed with output:\n${PKG_CONFIG_VERSION_STRING}\n" " stderr: \n${_PKG_CONFIG_VERSION_ERROR}\n" " result: \n${_PKG_CONFIG_VERSION_RESULT}" ) set(PKG_CONFIG_EXECUTABLE "") + set(PKG_CONFIG_ARGN "") unset(PKG_CONFIG_VERSION_STRING) endif () unset(_PKG_CONFIG_VERSION_RESULT) @@ -99,7 +128,7 @@ macro(_pkgconfig_invoke _pkglist _prefix _varname _regexp) set(_pkgconfig_invoke_result) execute_process( - COMMAND ${PKG_CONFIG_EXECUTABLE} ${ARGN} ${_pkglist} + COMMAND ${PKG_CONFIG_EXECUTABLE} ${PKG_CONFIG_ARGN} ${ARGN} ${_pkglist} OUTPUT_VARIABLE _pkgconfig_invoke_result RESULT_VARIABLE _pkgconfig_failed OUTPUT_STRIP_TRAILING_WHITESPACE) @@ -393,6 +422,14 @@ macro(_pkg_set_path_internal) unset(_lib_dirs) unset(_pkgconfig_path) endif() + + # Tell pkg-config not to strip any -L paths so we can search them all. + if(DEFINED ENV{PKG_CONFIG_ALLOW_SYSTEM_LIBS}) + set(_pkgconfig_allow_system_libs_old "$ENV{PKG_CONFIG_ALLOW_SYSTEM_LIBS}") + else() + unset(_pkgconfig_allow_system_libs_old) + endif() + set(ENV{PKG_CONFIG_ALLOW_SYSTEM_LIBS} 0) endmacro() macro(_pkg_restore_path_internal) @@ -400,6 +437,10 @@ macro(_pkg_restore_path_internal) # Restore the environment variable set(ENV{PKG_CONFIG_PATH} "${_pkgconfig_path_old}") endif() + if(DEFINED _pkgconfig_allow_system_libs_old) + set(ENV{PKG_CONFIG_ALLOW_SYSTEM_LIBS} "${_pkgconfig_allow_system_libs_old}") + unset(_pkgconfig_allow_system_libs_old) + endif() unset(_extra_paths) unset(_pkgconfig_path_old) @@ -541,7 +582,7 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma # execute the query execute_process( - COMMAND ${PKG_CONFIG_EXECUTABLE} ${_pkg_check_modules_exist_query} + COMMAND ${PKG_CONFIG_EXECUTABLE} ${PKG_CONFIG_ARGN} ${_pkg_check_modules_exist_query} RESULT_VARIABLE _pkgconfig_retval ERROR_VARIABLE _pkgconfig_error ERROR_STRIP_TRAILING_WHITESPACE) @@ -893,12 +934,30 @@ Variables Affecting Behavior .. variable:: PKG_CONFIG_EXECUTABLE - This can be set to the path of the pkg-config executable. If not provided, - it will be set by the module as a result of calling :command:`find_program` - internally. + This cache variable can be set to the path of the pkg-config executable. + :command:`find_program` is called internally by the module with this + variable. .. versionadded:: 3.1 - The ``PKG_CONFIG`` environment variable can be used as a hint. + The ``PKG_CONFIG`` environment variable can be used as a hint if + ``PKG_CONFIG_EXECUTABLE`` has not yet been set. + + .. versionchanged:: 3.22 + If the ``PKG_CONFIG`` environment variable is set, only the first + argument is taken from it when using it as a hint. + +.. variable:: PKG_CONFIG_ARGN + + .. versionadded:: 3.22 + + This cache variable can be set to a list of arguments to additionally pass + to pkg-config if needed. If not provided, it will be initialized from the + ``PKG_CONFIG`` environment variable, if set. The first argument in that + environment variable is assumed to be the pkg-config program, while all + remaining arguments after that are used to initialize ``PKG_CONFIG_ARGN``. + If no such environment variable is defined, ``PKG_CONFIG_ARGN`` is + initialized to an empty string. The module does not update the variable once + it has been set in the cache. .. variable:: PKG_CONFIG_USE_CMAKE_PREFIX_PATH diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake index c6a3451f7..e4d6cf3cb 100644 --- a/Modules/FindThreads.cmake +++ b/Modules/FindThreads.cmake @@ -106,7 +106,7 @@ endmacro() # Do NOT even think about using it outside of this file! macro(_check_pthreads_flag) if(NOT Threads_FOUND) - # If we did not found -lpthread, -lpthread, or -lthread, look for -pthread + # If we did not find -lpthreads, -lpthread, or -lthread, look for -pthread if(NOT DEFINED THREADS_HAVE_PTHREAD_ARG) message(CHECK_START "Check if compiler accepts -pthread") if(CMAKE_C_COMPILER_LOADED) diff --git a/Modules/FindX11.cmake b/Modules/FindX11.cmake index d480fc480..fd5ee5395 100644 --- a/Modules/FindX11.cmake +++ b/Modules/FindX11.cmake @@ -828,6 +828,12 @@ if (UNIX) X11_Xau_INCLUDE_PATH X11_xcb_LIB X11_xcb_INCLUDE_PATH + X11_xcb_icccm_LIB + X11_xcb_icccm_INCLUDE_PATH + X11_xcb_util_LIB + X11_xcb_util_INCLUDE_PATH + X11_xcb_xfixes_LIB + X11_xcb_xfixes_INCLUDE_PATH X11_xcb_xkb_LIB X11_X11_xcb_LIB X11_X11_xcb_INCLUDE_PATH diff --git a/Modules/GNUInstallDirs.cmake b/Modules/GNUInstallDirs.cmake index 4aaad797b..6ca424ad5 100644 --- a/Modules/GNUInstallDirs.cmake +++ b/Modules/GNUInstallDirs.cmake @@ -218,6 +218,7 @@ if(NOT DEFINED CMAKE_INSTALL_LIBDIR OR (_libdir_set # Override this default 'lib' with 'lib64' iff: # - we are on Linux system but NOT cross-compiling # - we are NOT on debian + # - we are NOT building for conda # - we are on a 64 bits system # reason is: amd64 ABI: https://github.com/hjl-tools/x86-psABI/wiki/X86-psABI # For Debian with multiarch, use 'lib/${CMAKE_LIBRARY_ARCHITECTURE}' if @@ -239,11 +240,34 @@ if(NOT DEFINED CMAKE_INSTALL_LIBDIR OR (_libdir_set "Unable to determine default CMAKE_INSTALL_LIBDIR directory because no target architecture is known. " "Please enable at least one language before including GNUInstallDirs.") endif() + if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$" - AND NOT CMAKE_CROSSCOMPILING - AND NOT EXISTS "/etc/alpine-release" - AND NOT EXISTS "/etc/arch-release") - if (EXISTS "/etc/debian_version") # is this a debian system ? + AND NOT CMAKE_CROSSCOMPILING) + unset(__system_type_for_install) + if(DEFINED ENV{CONDA_BUILD} AND DEFINED ENV{PREFIX}) + set(conda_prefix "$ENV{PREFIX}") + cmake_path(ABSOLUTE_PATH conda_prefix NORMALIZE) + if("${CMAKE_INSTALL_PREFIX}" STREQUAL conda_prefix) + set(__system_type_for_install "conda") + endif() + elseif(DEFINED ENV{CONDA_PREFIX}) + set(conda_prefix "$ENV{CONDA_PREFIX}") + cmake_path(ABSOLUTE_PATH conda_prefix NORMALIZE) + if("${CMAKE_INSTALL_PREFIX}" STREQUAL conda_prefix) + set(__system_type_for_install "conda") + endif() + endif() + if(NOT __system_type_for_install) + if (EXISTS "/etc/alpine-release") + set(__system_type_for_install "alpine") + elseif (EXISTS "/etc/arch-release") + set(__system_type_for_install "arch linux") + elseif (EXISTS "/etc/debian_version") + set(__system_type_for_install "debian") + endif() + endif() + + if(__system_type_for_install STREQUAL "debian") if(CMAKE_LIBRARY_ARCHITECTURE) if("${CMAKE_INSTALL_PREFIX}" MATCHES "^/usr/?$") set(_LIBDIR_DEFAULT "lib/${CMAKE_LIBRARY_ARCHITECTURE}") @@ -253,7 +277,8 @@ if(NOT DEFINED CMAKE_INSTALL_LIBDIR OR (_libdir_set set(__LAST_LIBDIR_DEFAULT "lib/${CMAKE_LIBRARY_ARCHITECTURE}") endif() endif() - else() # not debian, rely on CMAKE_SIZEOF_VOID_P: + elseif(NOT DEFINED __system_type_for_install) + # not debian, alpine, arch, or conda so rely on CMAKE_SIZEOF_VOID_P: if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") set(_LIBDIR_DEFAULT "lib64") if(DEFINED _GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX) @@ -262,6 +287,8 @@ if(NOT DEFINED CMAKE_INSTALL_LIBDIR OR (_libdir_set endif() endif() endif() + unset(__system_type_for_install) + if(NOT DEFINED CMAKE_INSTALL_LIBDIR) set(CMAKE_INSTALL_LIBDIR "${_LIBDIR_DEFAULT}" CACHE PATH "Object code libraries (${_LIBDIR_DEFAULT})") elseif(DEFINED __LAST_LIBDIR_DEFAULT diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake index e90a9b5b7..53584c639 100644 --- a/Modules/GetPrerequisites.cmake +++ b/Modules/GetPrerequisites.cmake @@ -746,7 +746,7 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa set(gp_regex_error "") set(gp_regex_fallback "") set(gp_regex_cmp_count 1) - elseif(gp_tool MATCHES "objdump$") + elseif(gp_tool MATCHES "objdump(\\.exe)?$") set(gp_cmd_args "-p") set(gp_regex "^\t*DLL Name: (.*\\.[Dd][Ll][Ll])${eol_char}$") set(gp_regex_error "") diff --git a/Modules/GoogleTest.cmake b/Modules/GoogleTest.cmake index 80d8e2397..f5f4f0238 100644 --- a/Modules/GoogleTest.cmake +++ b/Modules/GoogleTest.cmake @@ -151,6 +151,7 @@ same as the Google Test name (i.e. ``suite.testcase``); see also [WORKING_DIRECTORY dir] [TEST_PREFIX prefix] [TEST_SUFFIX suffix] + [TEST_FILTER expr] [NO_PRETTY_TYPES] [NO_PRETTY_VALUES] [PROPERTIES name1 value1...] [TEST_LIST var] @@ -204,6 +205,15 @@ same as the Google Test name (i.e. ``suite.testcase``); see also every discovered test case. Both ``TEST_PREFIX`` and ``TEST_SUFFIX`` may be specified. + ``TEST_FILTER expr`` + .. versionadded:: 3.22 + + Filter expression to pass as a ``--gtest_filter`` argument during test + discovery. Note that the expression is a wildcard-based format that + matches against the original test names as used by gtest. For type or + value-parameterized tests, these names may be different to the potentially + pretty-printed test names that ``ctest`` uses. + ``NO_PRETTY_TYPES`` By default, the type index of type-parameterized tests is replaced by the actual type name in the CTest test name. If this behavior is undesirable @@ -411,7 +421,7 @@ function(gtest_discover_tests TARGET) "" "NO_PRETTY_TYPES;NO_PRETTY_VALUES" "TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;TEST_LIST;DISCOVERY_TIMEOUT;XML_OUTPUT_DIR;DISCOVERY_MODE" - "EXTRA_ARGS;PROPERTIES" + "EXTRA_ARGS;PROPERTIES;TEST_FILTER" ${ARGN} ) @@ -475,6 +485,7 @@ function(gtest_discover_tests TARGET) -D "TEST_PROPERTIES=${_PROPERTIES}" -D "TEST_PREFIX=${_TEST_PREFIX}" -D "TEST_SUFFIX=${_TEST_SUFFIX}" + -D "TEST_FILTER=${_TEST_FILTER}" -D "NO_PRETTY_TYPES=${_NO_PRETTY_TYPES}" -D "NO_PRETTY_VALUES=${_NO_PRETTY_VALUES}" -D "TEST_LIST=${_TEST_LIST}" @@ -505,7 +516,8 @@ function(gtest_discover_tests TARGET) string(CONCAT ctest_include_content "if(EXISTS \"$<TARGET_FILE:${TARGET}>\")" "\n" " if(NOT EXISTS \"${ctest_tests_file}\" OR" "\n" - " NOT \"${ctest_tests_file}\" IS_NEWER_THAN \"$<TARGET_FILE:${TARGET}>\")" "\n" + " NOT \"${ctest_tests_file}\" IS_NEWER_THAN \"$<TARGET_FILE:${TARGET}>\" OR\n" + " NOT \"${ctest_tests_file}\" IS_NEWER_THAN \"\${CMAKE_CURRENT_LIST_FILE}\")\n" " include(\"${_GOOGLETEST_DISCOVER_TESTS_SCRIPT}\")" "\n" " gtest_discover_tests_impl(" "\n" " TEST_EXECUTABLE" " [==[" "$<TARGET_FILE:${TARGET}>" "]==]" "\n" @@ -515,6 +527,7 @@ function(gtest_discover_tests TARGET) " TEST_PROPERTIES" " [==[" "${_PROPERTIES}" "]==]" "\n" " TEST_PREFIX" " [==[" "${_TEST_PREFIX}" "]==]" "\n" " TEST_SUFFIX" " [==[" "${_TEST_SUFFIX}" "]==]" "\n" + " TEST_FILTER" " [==[" "${_TEST_FILTER}" "]==]" "\n" " NO_PRETTY_TYPES" " [==[" "${_NO_PRETTY_TYPES}" "]==]" "\n" " NO_PRETTY_VALUES" " [==[" "${_NO_PRETTY_VALUES}" "]==]" "\n" " TEST_LIST" " [==[" "${_TEST_LIST}" "]==]" "\n" diff --git a/Modules/GoogleTestAddTests.cmake b/Modules/GoogleTestAddTests.cmake index 0f79c9afc..6b3bf34ee 100644 --- a/Modules/GoogleTestAddTests.cmake +++ b/Modules/GoogleTestAddTests.cmake @@ -44,7 +44,7 @@ function(gtest_discover_tests_impl) cmake_parse_arguments( "" "" - "NO_PRETTY_TYPES;NO_PRETTY_VALUES;TEST_EXECUTABLE;TEST_WORKING_DIR;TEST_PREFIX;TEST_SUFFIX;TEST_LIST;CTEST_FILE;TEST_DISCOVERY_TIMEOUT;TEST_XML_OUTPUT_DIR" + "NO_PRETTY_TYPES;NO_PRETTY_VALUES;TEST_EXECUTABLE;TEST_WORKING_DIR;TEST_PREFIX;TEST_SUFFIX;TEST_LIST;CTEST_FILE;TEST_DISCOVERY_TIMEOUT;TEST_XML_OUTPUT_DIR;TEST_FILTER" "TEST_EXTRA_ARGS;TEST_PROPERTIES;TEST_EXECUTOR" ${ARGN} ) @@ -58,6 +58,12 @@ function(gtest_discover_tests_impl) set(tests) set(tests_buffer) + if(_TEST_FILTER) + set(filter "--gtest_filter=${_TEST_FILTER}") + else() + set(filter) + endif() + # Run test executable to get list of available tests if(NOT EXISTS "${_TEST_EXECUTABLE}") message(FATAL_ERROR @@ -66,7 +72,7 @@ function(gtest_discover_tests_impl) ) endif() execute_process( - COMMAND ${_TEST_EXECUTOR} "${_TEST_EXECUTABLE}" --gtest_list_tests + COMMAND ${_TEST_EXECUTOR} "${_TEST_EXECUTABLE}" --gtest_list_tests ${filter} WORKING_DIRECTORY "${_TEST_WORKING_DIR}" TIMEOUT ${_TEST_DISCOVERY_TIMEOUT} OUTPUT_VARIABLE output @@ -178,6 +184,7 @@ if(CMAKE_SCRIPT_MODE_FILE) TEST_WORKING_DIR ${TEST_WORKING_DIR} TEST_PREFIX ${TEST_PREFIX} TEST_SUFFIX ${TEST_SUFFIX} + TEST_FILTER ${TEST_FILTER} TEST_LIST ${TEST_LIST} CTEST_FILE ${CTEST_FILE} TEST_DISCOVERY_TIMEOUT ${TEST_DISCOVERY_TIMEOUT} diff --git a/Modules/InstallRequiredSystemLibraries.cmake b/Modules/InstallRequiredSystemLibraries.cmake index a2672784d..689cab591 100644 --- a/Modules/InstallRequiredSystemLibraries.cmake +++ b/Modules/InstallRequiredSystemLibraries.cmake @@ -73,6 +73,8 @@ set(_IRSL_HAVE_MSVC FALSE) foreach(LANG IN ITEMS C CXX Fortran) if("${CMAKE_${LANG}_COMPILER_ID}" MATCHES "Intel") if(NOT _IRSL_HAVE_Intel) + # The oneAPI icx/ifx compilers are under ${os}/bin. + # The classic icc/icpc/icl/ifort compilers may be under ${os}/bin/intel64. get_filename_component(_Intel_basedir "${CMAKE_${LANG}_COMPILER}" PATH) if(CMAKE_SIZEOF_VOID_P EQUAL 8) set(_Intel_archdir intel64) @@ -80,19 +82,36 @@ foreach(LANG IN ITEMS C CXX Fortran) set(_Intel_archdir ia32) endif() set(_Intel_compiler_ver ${CMAKE_${LANG}_COMPILER_VERSION}) - if(WIN32 AND EXISTS "${_Intel_basedir}/../redist/${_Intel_archdir}_win/compiler") - get_filename_component(_Intel_redistdir "${_Intel_basedir}/../redist/${_Intel_archdir}_win/compiler" ABSOLUTE) - elseif(WIN32) - get_filename_component(_Intel_redistdir "${_Intel_basedir}/../../redist/${_Intel_archdir}/compiler" ABSOLUTE) + if(WIN32) + set(_Intel_possible_redistdirs + "${_Intel_basedir}/../redist/${_Intel_archdir}_win/compiler" + "${_Intel_basedir}/../redist/${_Intel_archdir}/compiler" + "${_Intel_basedir}/../../redist/${_Intel_archdir}_win/compiler" + "${_Intel_basedir}/../../redist/${_Intel_archdir}/compiler" + ) elseif(APPLE) - get_filename_component(_Intel_redistdir "${_Intel_basedir}/../../compiler/lib" ABSOLUTE) + set(_Intel_possible_redistdirs + "${_Intel_basedir}/../../compiler/lib" + ) else() - if(EXISTS "${_Intel_basedir}/../lib/${_Intel_archdir}_lin") - get_filename_component(_Intel_redistdir "${_Intel_basedir}/../lib/${_Intel_archdir}" ABSOLUTE) - else() - get_filename_component(_Intel_redistdir "${_Intel_basedir}/../../compiler/lib/${_Intel_archdir}_lin" ABSOLUTE) + set(_Intel_possible_redistdirs + "${_Intel_basedir}/../lib/${_Intel_archdir}" + "${_Intel_basedir}/../../compiler/lib/${_Intel_archdir}_lin" + ) + endif() + + set(_Intel_redistdir NOT-FOUND) + foreach(dir IN LISTS _Intel_possible_redistdirs) + if(EXISTS "${dir}") + set(_Intel_redistdir "${dir}") + break() endif() + endforeach() + # Fall back to last dir + if(NOT _Intel_redistdir) + list(POP_BACK _Intel_possible_redistdirs _Intel_redistdir) endif() + unset(_Intel_possible_redistdirs) set(_IRSL_HAVE_Intel TRUE) endif() elseif("${CMAKE_${LANG}_COMPILER_ID}" STREQUAL "MSVC") diff --git a/Modules/Internal/CPack/CPackDeb.cmake b/Modules/Internal/CPack/CPackDeb.cmake index 967ad7bc1..c115f003e 100644 --- a/Modules/Internal/CPack/CPackDeb.cmake +++ b/Modules/Internal/CPack/CPackDeb.cmake @@ -662,10 +662,12 @@ function(cpack_deb_prepare_package_vars) # add ldconfig call in default postrm and postint set(CPACK_ADD_LDCONFIG_CALL 0) + # all files in CPACK_DEB_SHARED_OBJECT_FILES have dot at the beginning + set(_LDCONF_DEFAULTS "./lib" "./usr/lib") foreach(_FILE IN LISTS CPACK_DEB_SHARED_OBJECT_FILES) get_filename_component(_DIR ${_FILE} DIRECTORY) - # all files in CPACK_DEB_SHARED_OBJECT_FILES have dot at the beginning - if(_DIR STREQUAL "./lib" OR _DIR STREQUAL "./usr/lib") + get_filename_component(_PARENT_DIR ${_DIR} DIRECTORY) + if(_DIR IN_LIST _LDCONF_DEFAULTS OR _PARENT_DIR IN_LIST _LDCONF_DEFAULTS) set(CPACK_ADD_LDCONFIG_CALL 1) endif() endforeach() diff --git a/Modules/Internal/CPack/CPackRPM.cmake b/Modules/Internal/CPack/CPackRPM.cmake index cbd748b2c..c72bf6db4 100644 --- a/Modules/Internal/CPack/CPackRPM.cmake +++ b/Modules/Internal/CPack/CPackRPM.cmake @@ -1160,6 +1160,16 @@ function(cpack_rpm_generate_package) set(TMP_RPM_SPEC_INSTALL_POST "%define __spec_install_post ${CPACK_RPM_SPEC_INSTALL_POST}") endif() + # CPACK_RPM_REQUIRES_EXCLUDE_FROM + # May be defined to keep the dependency generator from + # scanning specific files or directories for deps. + if(CPACK_RPM_REQUIRES_EXCLUDE_FROM) + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: User defined CPACK_RPM_REQUIRES_EXCLUDE_FROM = ${CPACK_RPM_REQUIRES_EXCLUDE_FROM}") + endif() + set(TMP_RPM_REQUIRES_EXCLUDE_FROM "%global __requires_exclude_from ${CPACK_RPM_REQUIRES_EXCLUDE_FROM}") + endif() + # CPACK_RPM_POST_INSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_POST_INSTALL_SCRIPT_FILE) # CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_POST_UNINSTALL_SCRIPT_FILE) # CPACK_RPM_POST_TRANS_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_POST_TRANS_SCRIPT_FILE) @@ -1648,6 +1658,7 @@ Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@ \@FILE_NAME_DEFINE\@ %define _unpackaged_files_terminate_build 0 \@TMP_RPM_SPEC_INSTALL_POST\@ +\@TMP_RPM_REQUIRES_EXCLUDE_FROM\@ \@CPACK_RPM_SPEC_MORE_DEFINE\@ \@CPACK_RPM_COMPRESSION_TYPE_TMP\@ @@ -1782,6 +1793,7 @@ Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@ \@FILE_NAME_DEFINE\@ %define _unpackaged_files_terminate_build 0 \@TMP_RPM_SPEC_INSTALL_POST\@ +\@TMP_RPM_REQUIRES_EXCLUDE_FROM\@ \@CPACK_RPM_SPEC_MORE_DEFINE\@ \@CPACK_RPM_COMPRESSION_TYPE_TMP\@ diff --git a/Modules/Internal/CPack/NSIS.template.in b/Modules/Internal/CPack/NSIS.template.in index 0a9c4877d..8a0c9726c 100644 --- a/Modules/Internal/CPack/NSIS.template.in +++ b/Modules/Internal/CPack/NSIS.template.in @@ -540,7 +540,7 @@ FunctionEnd @CPACK_NSIS_INSTALLER_WELCOME_TITLE_3LINES_CODE@ !insertmacro MUI_PAGE_WELCOME - !insertmacro MUI_PAGE_LICENSE "@CPACK_RESOURCE_FILE_LICENSE@" + @CPACK_NSIS_LICENSE_PAGE@ Page custom InstallOptionsPage !insertmacro MUI_PAGE_DIRECTORY @@ -564,21 +564,27 @@ FunctionEnd ;Languages !insertmacro MUI_LANGUAGE "English" ;first language is the default language + !insertmacro MUI_LANGUAGE "Afrikaans" !insertmacro MUI_LANGUAGE "Albanian" !insertmacro MUI_LANGUAGE "Arabic" + !insertmacro MUI_LANGUAGE "Asturian" !insertmacro MUI_LANGUAGE "Basque" !insertmacro MUI_LANGUAGE "Belarusian" !insertmacro MUI_LANGUAGE "Bosnian" !insertmacro MUI_LANGUAGE "Breton" !insertmacro MUI_LANGUAGE "Bulgarian" + !insertmacro MUI_LANGUAGE "Catalan" + !insertmacro MUI_LANGUAGE "Corsican" !insertmacro MUI_LANGUAGE "Croatian" !insertmacro MUI_LANGUAGE "Czech" !insertmacro MUI_LANGUAGE "Danish" !insertmacro MUI_LANGUAGE "Dutch" + !insertmacro MUI_LANGUAGE "Esperanto" !insertmacro MUI_LANGUAGE "Estonian" !insertmacro MUI_LANGUAGE "Farsi" !insertmacro MUI_LANGUAGE "Finnish" !insertmacro MUI_LANGUAGE "French" + !insertmacro MUI_LANGUAGE "Galician" !insertmacro MUI_LANGUAGE "German" !insertmacro MUI_LANGUAGE "Greek" !insertmacro MUI_LANGUAGE "Hebrew" @@ -597,22 +603,29 @@ FunctionEnd !insertmacro MUI_LANGUAGE "Malay" !insertmacro MUI_LANGUAGE "Mongolian" !insertmacro MUI_LANGUAGE "Norwegian" + !insertmacro MUI_LANGUAGE "NorwegianNynorsk" + !insertmacro MUI_LANGUAGE "Pashto" !insertmacro MUI_LANGUAGE "Polish" !insertmacro MUI_LANGUAGE "Portuguese" !insertmacro MUI_LANGUAGE "PortugueseBR" !insertmacro MUI_LANGUAGE "Romanian" !insertmacro MUI_LANGUAGE "Russian" + !insertmacro MUI_LANGUAGE "ScotsGaelic" !insertmacro MUI_LANGUAGE "Serbian" !insertmacro MUI_LANGUAGE "SerbianLatin" !insertmacro MUI_LANGUAGE "SimpChinese" !insertmacro MUI_LANGUAGE "Slovak" !insertmacro MUI_LANGUAGE "Slovenian" !insertmacro MUI_LANGUAGE "Spanish" + !insertmacro MUI_LANGUAGE "SpanishInternational" !insertmacro MUI_LANGUAGE "Swedish" + !insertmacro MUI_LANGUAGE "Tatar" !insertmacro MUI_LANGUAGE "Thai" !insertmacro MUI_LANGUAGE "TradChinese" !insertmacro MUI_LANGUAGE "Turkish" !insertmacro MUI_LANGUAGE "Ukrainian" + !insertmacro MUI_LANGUAGE "Uzbek" + !insertmacro MUI_LANGUAGE "Vietnamese" !insertmacro MUI_LANGUAGE "Welsh" ;-------------------------------- @@ -661,7 +674,7 @@ Section "-Core installation" Push "@CPACK_PACKAGE_VENDOR@" Call ConditionalAddToRegisty Push "UninstallString" - Push "$INSTDIR\@CPACK_NSIS_UNINSTALL_NAME@.exe" + Push "$\"$INSTDIR\@CPACK_NSIS_UNINSTALL_NAME@.exe$\"" Call ConditionalAddToRegisty Push "NoRepair" Push "1" diff --git a/Modules/Internal/OSRelease/010-TryOldCentOS.cmake b/Modules/Internal/OSRelease/010-TryOldCentOS.cmake new file mode 100644 index 000000000..ff358977f --- /dev/null +++ b/Modules/Internal/OSRelease/010-TryOldCentOS.cmake @@ -0,0 +1,41 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +# Author: Alex Turbov + +if(NOT EXISTS "${CMAKE_SYSROOT}/etc/centos-release") + return() +endif() + +# Get the first string only +file( + STRINGS "${CMAKE_SYSROOT}/etc/centos-release" CMAKE_GET_OS_RELEASE_FALLBACK_CONTENT + LIMIT_COUNT 1 + ) + +# +# Example: +# CentOS release 6.10 (Final) +# +if(CMAKE_GET_OS_RELEASE_FALLBACK_CONTENT MATCHES "CentOS release ([0-9\.]+) .*") + + set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_NAME CentOS) + set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_PRETTY_NAME "${CMAKE_GET_OS_RELEASE_FALLBACK_CONTENT}") + set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_ID centos) + set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_ID_LIKE rhel) + set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION ${CMAKE_MATCH_1}) + set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION_ID ${CMAKE_MATCH_1}) + + list( + APPEND CMAKE_GET_OS_RELEASE_FALLBACK_RESULT + CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_NAME + CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_PRETTY_NAME + CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_ID + CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_ID_LIKE + CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION + CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION_ID + ) + +endif() + +unset(CMAKE_GET_OS_RELEASE_FALLBACK_CONTENT) diff --git a/Modules/Internal/OSRelease/020-TryDebianVersion.cmake b/Modules/Internal/OSRelease/020-TryDebianVersion.cmake new file mode 100644 index 000000000..8ebe19a72 --- /dev/null +++ b/Modules/Internal/OSRelease/020-TryDebianVersion.cmake @@ -0,0 +1,38 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +# Author: Alex Turbov + +if(NOT EXISTS "${CMAKE_SYSROOT}/etc/debian_version") + return() +endif() + +# Get the first string only +file( + STRINGS "${CMAKE_SYSROOT}/etc/debian_version" CMAKE_GET_OS_RELEASE_FALLBACK_CONTENT + LIMIT_COUNT 1 + ) + +# +# Example: +# 6.0.10 # Old debian +# wheezy/sid # Ubuntu +# +if(CMAKE_GET_OS_RELEASE_FALLBACK_CONTENT MATCHES "[0-9]+(\.[0-9]+)*") + + set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_NAME Debian) + set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_ID debian) + set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION ${CMAKE_GET_OS_RELEASE_FALLBACK_CONTENT}) + set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION_ID ${CMAKE_GET_OS_RELEASE_FALLBACK_CONTENT}) + + list( + APPEND CMAKE_GET_OS_RELEASE_FALLBACK_RESULT + CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_NAME + CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_ID + CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION + CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION_ID + ) + +endif() + +unset(CMAKE_GET_OS_RELEASE_FALLBACK_CONTENT) diff --git a/Modules/Platform/Android-Determine.cmake b/Modules/Platform/Android-Determine.cmake index 7b67f839e..a4e957495 100644 --- a/Modules/Platform/Android-Determine.cmake +++ b/Modules/Platform/Android-Determine.cmake @@ -52,14 +52,16 @@ if(CMAKE_GENERATOR MATCHES "Visual Studio") endif() configure_file(${CMAKE_ROOT}/Modules/Platform/Android/VCXProjInspect.vcxproj.in ${CMAKE_PLATFORM_INFO_DIR}/VCXProjInspect.vcxproj @ONLY) + cmake_host_system_information(RESULT _msbuild QUERY VS_MSBUILD_COMMAND) # undocumented query execute_process( - COMMAND "${CMAKE_VS_MSBUILD_COMMAND}" "VCXProjInspect.vcxproj" + COMMAND "${_msbuild}" "VCXProjInspect.vcxproj" "/p:Configuration=Debug" "/p:Platform=${vcx_platform}" WORKING_DIRECTORY ${CMAKE_PLATFORM_INFO_DIR} OUTPUT_VARIABLE VCXPROJ_INSPECT_OUTPUT ERROR_VARIABLE VCXPROJ_INSPECT_OUTPUT RESULT_VARIABLE VCXPROJ_INSPECT_RESULT ) + unset(_msbuild) if(NOT CMAKE_SYSROOT AND VCXPROJ_INSPECT_OUTPUT MATCHES "CMAKE_SYSROOT=([^%\r\n]+)[\r\n]") # Strip VS diagnostic output from the end of the line. string(REGEX REPLACE " \\(TaskId:[0-9]*\\)$" "" _sysroot "${CMAKE_MATCH_1}") diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake index 373be760d..1c32018f3 100644 --- a/Modules/Platform/Windows-Clang.cmake +++ b/Modules/Platform/Windows-Clang.cmake @@ -38,6 +38,8 @@ macro(__windows_compiler_clang_gnu lang) set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Xlinker" " ") set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP) + set(CMAKE_${lang}_LINKER_MANIFEST_FLAG " -Xlinker /MANIFESTINPUT:") + if("${CMAKE_${lang}_SIMULATE_VERSION}" MATCHES "^([0-9]+)\\.([0-9]+)") math(EXPR MSVC_VERSION "${CMAKE_MATCH_1}*100 + ${CMAKE_MATCH_2}") endif() @@ -66,10 +68,10 @@ macro(__windows_compiler_clang_gnu lang) set(CMAKE_${lang}_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>") set(CMAKE_${lang}_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>") set(CMAKE_${lang}_CREATE_SHARED_LIBRARY - "<CMAKE_${lang}_COMPILER> -fuse-ld=lld-link -nostartfiles -nostdlib <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} -Xlinker /implib:<TARGET_IMPLIB> -Xlinker /pdb:<TARGET_PDB> -Xlinker /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <OBJECTS> <LINK_LIBRARIES>") + "<CMAKE_${lang}_COMPILER> -fuse-ld=lld-link -nostartfiles -nostdlib <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} -Xlinker /MANIFEST:EMBED -Xlinker /implib:<TARGET_IMPLIB> -Xlinker /pdb:<TARGET_PDB> -Xlinker /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <OBJECTS> <LINK_LIBRARIES> <MANIFESTS>") set(CMAKE_${lang}_CREATE_SHARED_MODULE ${CMAKE_${lang}_CREATE_SHARED_LIBRARY}) set(CMAKE_${lang}_LINK_EXECUTABLE - "<CMAKE_${lang}_COMPILER> -fuse-ld=lld-link -nostartfiles -nostdlib <FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Xlinker /implib:<TARGET_IMPLIB> -Xlinker /pdb:<TARGET_PDB> -Xlinker /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>") + "<CMAKE_${lang}_COMPILER> -fuse-ld=lld-link -nostartfiles -nostdlib <FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Xlinker /MANIFEST:EMBED -Xlinker /implib:<TARGET_IMPLIB> -Xlinker /pdb:<TARGET_PDB> -Xlinker /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES> <MANIFESTS>") set(CMAKE_${lang}_CREATE_WIN32_EXE "-Xlinker /subsystem:windows") set(CMAKE_${lang}_CREATE_CONSOLE_EXE "-Xlinker /subsystem:console") diff --git a/Modules/Platform/Windows-GNU.cmake b/Modules/Platform/Windows-GNU.cmake index a04882f56..51dc14631 100644 --- a/Modules/Platform/Windows-GNU.cmake +++ b/Modules/Platform/Windows-GNU.cmake @@ -8,6 +8,8 @@ if(__WINDOWS_GNU) endif() set(__WINDOWS_GNU 1) +set(MINGW 1) + set(CMAKE_IMPORT_LIBRARY_PREFIX "lib") set(CMAKE_SHARED_LIBRARY_PREFIX "lib") set(CMAKE_SHARED_MODULE_PREFIX "lib") @@ -19,16 +21,12 @@ set(CMAKE_SHARED_LIBRARY_SUFFIX ".dll") set(CMAKE_SHARED_MODULE_SUFFIX ".dll") set(CMAKE_STATIC_LIBRARY_SUFFIX ".a") -if(MSYS OR MINGW) - set(CMAKE_EXTRA_LINK_EXTENSIONS ".lib") # MinGW can also link to a MS .lib -endif() +set(CMAKE_EXTRA_LINK_EXTENSIONS ".lib") # MinGW can also link to a MS .lib -if(MINGW) - set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "") - set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a" ".a" ".lib") - set(CMAKE_C_STANDARD_LIBRARIES_INIT "-lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32") - set(CMAKE_CXX_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}") -endif() +set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "") +set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a" ".a" ".lib") +set(CMAKE_C_STANDARD_LIBRARIES_INIT "-lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32") +set(CMAKE_CXX_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}") set(CMAKE_DL_LIBS "") set(CMAKE_LIBRARY_PATH_FLAG "-L") @@ -48,21 +46,19 @@ endif() macro(__windows_compiler_gnu lang) - if(MSYS OR MINGW) - # Create archiving rules to support large object file lists for static libraries. - set(CMAKE_${lang}_ARCHIVE_CREATE "<CMAKE_AR> qc <TARGET> <LINK_FLAGS> <OBJECTS>") - set(CMAKE_${lang}_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>") - set(CMAKE_${lang}_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>") - - # Initialize C link type selection flags. These flags are used when - # building a shared library, shared module, or executable that links - # to other libraries to select whether to use the static or shared - # versions of the libraries. - foreach(type SHARED_LIBRARY SHARED_MODULE EXE) - set(CMAKE_${type}_LINK_STATIC_${lang}_FLAGS "-Wl,-Bstatic") - set(CMAKE_${type}_LINK_DYNAMIC_${lang}_FLAGS "-Wl,-Bdynamic") - endforeach() - endif() + # Create archiving rules to support large object file lists for static libraries. + set(CMAKE_${lang}_ARCHIVE_CREATE "<CMAKE_AR> qc <TARGET> <LINK_FLAGS> <OBJECTS>") + set(CMAKE_${lang}_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>") + set(CMAKE_${lang}_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>") + + # Initialize C link type selection flags. These flags are used when + # building a shared library, shared module, or executable that links + # to other libraries to select whether to use the static or shared + # versions of the libraries. + foreach(type SHARED_LIBRARY SHARED_MODULE EXE) + set(CMAKE_${type}_LINK_STATIC_${lang}_FLAGS "-Wl,-Bstatic") + set(CMAKE_${type}_LINK_DYNAMIC_${lang}_FLAGS "-Wl,-Bdynamic") + endforeach() # No -fPIC on Windows set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "") diff --git a/Modules/Platform/Windows-Intel-C.cmake b/Modules/Platform/Windows-Intel-C.cmake index e4d9b93ee..152b27c30 100644 --- a/Modules/Platform/Windows-Intel-C.cmake +++ b/Modules/Platform/Windows-Intel-C.cmake @@ -1,7 +1,7 @@ include(Platform/Windows-Intel) __windows_compiler_intel(C) -set(CMAKE_DEPFILE_FLAGS_C "-QMD -QMT <DEP_TARGET> -QMF <DEP_FILE>") +set(CMAKE_DEPFILE_FLAGS_C "-QMMD -QMT <DEP_TARGET> -QMF <DEP_FILE>") set(CMAKE_C_DEPFILE_FORMAT gcc) if(CMAKE_GENERATOR MATCHES "^Ninja") diff --git a/Modules/Platform/Windows-Intel-CXX.cmake b/Modules/Platform/Windows-Intel-CXX.cmake index 6adbb6e19..ce33ae186 100644 --- a/Modules/Platform/Windows-Intel-CXX.cmake +++ b/Modules/Platform/Windows-Intel-CXX.cmake @@ -2,7 +2,7 @@ include(Platform/Windows-Intel) set(_COMPILE_CXX " /TP") __windows_compiler_intel(CXX) -set(CMAKE_DEPFILE_FLAGS_CXX "-QMD -QMT <DEP_TARGET> -QMF <DEP_FILE>") +set(CMAKE_DEPFILE_FLAGS_CXX "-QMMD -QMT <DEP_TARGET> -QMF <DEP_FILE>") set(CMAKE_CXX_DEPFILE_FORMAT gcc) if(CMAKE_GENERATOR MATCHES "^Ninja") diff --git a/Modules/Platform/Windows-IntelLLVM.cmake b/Modules/Platform/Windows-IntelLLVM.cmake index 8231e784b..b9ea03799 100644 --- a/Modules/Platform/Windows-IntelLLVM.cmake +++ b/Modules/Platform/Windows-IntelLLVM.cmake @@ -12,6 +12,6 @@ include(Platform/Windows-MSVC) macro(__windows_compiler_intel lang) __windows_compiler_msvc(${lang}) - set(CMAKE_DEPFILE_FLAGS_${lang} "-QMD -QMT <DEP_TARGET> -QMF <DEP_FILE>") + set(CMAKE_DEPFILE_FLAGS_${lang} "-QMMD -QMT <DEP_TARGET> -QMF <DEP_FILE>") set(CMAKE_${lang}_DEPFILE_FORMAT gcc) endmacro() diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index b48c33ce3..9808861cd 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -192,12 +192,17 @@ ensure generated files will receive the required settings. If set to ``TRUE``, implicit dependencies are generated by the ``swig`` tool itself. This property is only meaningful for :ref:`Makefile <Makefile Generators>`, - :ref:`Ninja <Ninja Generators>` and :generator:`Xcode` generators. Default - value is ``FALSE``. + :ref:`Ninja <Ninja Generators>`, :generator:`Xcode`, and + :ref:`Visual Studio <Visual Studio Generators>` + (:generator:`Visual Studio 11 2012` and above) generators. Default value is + ``FALSE``. .. versionadded:: 3.21 Added the support of :generator:`Xcode` generator. + .. versionadded:: 3.22 + Added the support of :ref:`Visual Studio Generators`. + ``SWIG_MODULE_NAME`` Specify the actual import name of the module in the target language. This is required if it cannot be scanned automatically from source @@ -342,8 +347,10 @@ as well as ``SWIG``: If set to ``TRUE``, implicit dependencies are generated by the ``swig`` tool itself. This variable is only meaningful for :ref:`Makefile <Makefile Generators>`, - :ref:`Ninja <Ninja Generators>` and :generator:`Xcode` generators. Default - value is ``FALSE``. + :ref:`Ninja <Ninja Generators>`, :generator:`Xcode`, and + :ref:`Visual Studio <Visual Studio Generators>` + (:generator:`Visual Studio 11 2012` and above) generators. Default value is + ``FALSE``. Source file property ``USE_SWIG_DEPENDENCIES``, if not defined, will be initialized with the value of this variable. @@ -351,6 +358,9 @@ as well as ``SWIG``: .. versionadded:: 3.21 Added the support of :generator:`Xcode` generator. + .. versionadded:: 3.22 + Added the support of :ref:`Visual Studio Generators`. + #]=======================================================================] cmake_policy(PUSH) @@ -515,7 +525,7 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) endif() set (use_swig_dependencies ${SWIG_USE_SWIG_DEPENDENCIES}) - if (CMAKE_GENERATOR MATCHES "Make|Ninja|Xcode") + if (CMAKE_GENERATOR MATCHES "Make|Ninja|Xcode|Visual Studio (1[1-9]|[2-9][0-9])") get_property(use_swig_dependencies_set SOURCE "${infile}" PROPERTY USE_SWIG_DEPENDENCIES SET) if (use_swig_dependencies_set) get_property(use_swig_dependencies SOURCE "${infile}" PROPERTY USE_SWIG_DEPENDENCIES) @@ -676,7 +686,7 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) ${swig_custom_products} ${swig_cleanup_command} # Let's create the ${outdir} at execution time, in case dir contains $(OutDir) - COMMAND "${CMAKE_COMMAND}" -E make_directory "${workingdir}" "${outdir}" "${outfiledir}" + COMMAND "${CMAKE_COMMAND}" -E make_directory ${outdir} ${outfiledir} ${swig_timestamp_command} COMMAND "${CMAKE_COMMAND}" -E env "SWIG_LIB=${SWIG_DIR}" "${SWIG_EXECUTABLE}" "-${SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG}" @@ -840,8 +850,9 @@ function(SWIG_ADD_LIBRARY name) set(SWIG_SOURCE_FILE_EXTENSIONS ".i") endif() - if (CMAKE_GENERATOR MATCHES "Make|Ninja|Xcode") - # For Makefiles and Ninja generators, use SWIG generated dependencies + if (CMAKE_GENERATOR MATCHES "Make|Ninja|Xcode|Visual Studio (1[1-9]|[2-9][0-9])") + # For Makefiles, Ninja, Xcode and Visual Studio generators, + # use SWIG generated dependencies if requested if (NOT DEFINED SWIG_USE_SWIG_DEPENDENCIES) set (SWIG_USE_SWIG_DEPENDENCIES OFF) endif() diff --git a/Modules/VTKCompatibility.cmake b/Modules/VTKCompatibility.cmake index 1b0815e85..4ee7643c2 100644 --- a/Modules/VTKCompatibility.cmake +++ b/Modules/VTKCompatibility.cmake @@ -1,6 +1,10 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. +# Not needed for "modern" VTK. +if (EXISTS "${VTK_SOURCE_DIR}/CMake/vtkModule.cmake") + return () +endif () if(APPLE) set(CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_C_CREATE_SHARED_LIBRARY}") |