diff options
Diffstat (limited to 'Modules')
57 files changed, 1107 insertions, 394 deletions
diff --git a/Modules/CMakeASM_MASMInformation.cmake b/Modules/CMakeASM_MASMInformation.cmake index 6d1e174..656b75e 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/CMakeCInformation.cmake b/Modules/CMakeCInformation.cmake index 6be1865..665f309 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/CMakeCUDAInformation.cmake b/Modules/CMakeCUDAInformation.cmake index a2946f4..e9cfed6 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/CMakeCXXInformation.cmake b/Modules/CMakeCXXInformation.cmake index 944d236..53abf37 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/CMakeDependentOption.cmake b/Modules/CMakeDependentOption.cmake index 96855d2..b7c478f 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 e8b9db7..a1814b7 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/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake index e360d31..342425c 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") diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 30b4aec..d54e2b0 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -687,7 +687,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 @@ -698,7 +698,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. diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index bb97f4a..27d9131 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -20,6 +20,9 @@ # on UNIX, cygwin and mingw +cmake_policy(PUSH) +cmake_policy(SET CMP0057 NEW) # if IN_LIST + # Resolve full path of CMAKE_TOOL from user-defined name and SEARCH_PATH. function(__resolve_tool_path CMAKE_TOOL SEARCH_PATH DOCSTRING) @@ -240,3 +243,5 @@ if("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" MATCHES "^xIAR$") set(CMAKE_IAR_LINKER "${CMAKE_LINKER}" CACHE FILEPATH "The IAR ILINK linker") mark_as_advanced(CMAKE_IAR_LINKER CMAKE_IAR_AR) endif() + +cmake_policy(POP) diff --git a/Modules/CMakeFindPackageMode.cmake b/Modules/CMakeFindPackageMode.cmake index 815dfc9..726e2a2 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/CMakeFortranCompilerABI.F90 b/Modules/CMakeFortranCompilerABI.F90 new file mode 100644 index 0000000..4a17153 --- /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 9a4ce63..0f71c6f 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/CMakeHIPInformation.cmake b/Modules/CMakeHIPInformation.cmake index 28c5f18..4c57677 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/CMakeOBJCInformation.cmake b/Modules/CMakeOBJCInformation.cmake index ac67d01..4c697da 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/CMakeOBJCXXInformation.cmake b/Modules/CMakeOBJCXXInformation.cmake index 70e8579..a6d824f 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 8f0909c..ecad1d5 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 f25788d..579f83f 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/CheckCXXSymbolExists.cmake b/Modules/CheckCXXSymbolExists.cmake index b4da4fa..7b13c3a 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 ad72e2f..8f1ca9d 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/CheckSymbolExists.cmake b/Modules/CheckSymbolExists.cmake index f8ca584..48ee3c4 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 0a64a8a..01c4cea 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 5dfb401..045b783 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/Clang-C.cmake b/Modules/Compiler/Clang-C.cmake index cf493d7..1b765ad 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 98828e0..84b05d7 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/Intel-C.cmake b/Modules/Compiler/Intel-C.cmake index ead9069..9884b58 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 37f339a..7c9cca9 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 d69d064..d7346f6 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 9799888..cae1f11 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 9a5104b..4ba1eea 100644 --- a/Modules/Compiler/MSVC-C.cmake +++ b/Modules/Compiler/MSVC-C.cmake @@ -29,6 +29,7 @@ endif() 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") # 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 @@ -63,3 +64,9 @@ endmacro() 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 f1c7450..9bb7722 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 @@ -79,3 +80,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/PGI.cmake b/Modules/Compiler/PGI.cmake index 4f8b90b..d111be9 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/FetchContent.cmake b/Modules/FetchContent.cmake index bd82a90..5ea8b2a 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,88 @@ 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: +.. command:: FetchContent_MakeAvailable -.. _`fetch-content-canonical-pattern`: + .. versionadded:: 3.14 -.. code-block:: cmake + .. code-block:: cmake - # 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>) + 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: - # Set custom variables, policies, etc. - # ... + .. code-block:: cmake - # Bring the populated content into the build - add_subdirectory(${${lcName}_SOURCE_DIR} ${${lcName}_BINARY_DIR}) - endif() + # WRONG: Should declare all details first + FetchContent_Declare(uses_other ...) + FetchContent_MakeAvailable(uses_other) + + FetchContent_Declare(other ...) # Will be ignored, uses_other beat us to it + FetchContent_MakeAvailable(other) # Would use details declared by 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. + .. 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 +263,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 +296,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 +319,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 +342,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 +352,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 +375,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 +388,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 +400,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: - - .. code-block:: cmake - - FetchContent_GetProperties(foobar) - if(NOT foobar_POPULATED) - FetchContent_Populate(foobar) - ... - endif() + :command:`FetchContent_MakeAvailable(name) <FetchContent_MakeAvailable>` or + :command:`FetchContent_Populate(name) <FetchContent_Populate>`. - 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 +522,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 diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index 726ff75..a44af4d 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -109,7 +109,8 @@ BLAS/LAPACK Vendors ``Goto`` GotoBLAS -``IBMESSL`` +``IBMESSL``, ``IBMESSL_SMP`` + IBM Engineering and Scientific Subroutine Library ``Intel`` @@ -150,7 +151,7 @@ BLAS/LAPACK Vendors ``PhiPACK`` Portable High Performance ANSI C (PHiPAC) -``SCSL`` +``SCSL``, ``SCSL_mp`` Scientific Computing Software Library ``SGIMATH`` @@ -386,6 +387,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() @@ -439,7 +442,7 @@ if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") 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 +504,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 +616,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 +632,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) @@ -734,14 +738,14 @@ 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") + set(_blas_armpl_lib "armpl_ilp64") else() - set(BLAS_armpl_LIB "armpl_lp64") + set(_blas_armpl_lib "armpl_lp64") 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") + set(_blas_armpl_lib "${_blas_armpl_lib}_mp") endif() if(NOT BLAS_LIBRARIES) @@ -750,13 +754,13 @@ if(BLA_VENDOR MATCHES "Arm" OR BLA_VENDOR STREQUAL "All") BLAS sgemm "" - "${BLAS_armpl_LIB}" + "${_blas_armpl_lib}" "" "" "" ) endif() - + unset(_blas_armpl_lib) endif() # FLAME's blis library? (https://github.com/flame/blis) @@ -859,19 +863,27 @@ 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(BLA_VENDOR MATCHES "_mp") + set(_blas_scsl_lib "${_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 +902,27 @@ 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") + set(_blas_essl_lib "${_blas_essl_lib}smp") + 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? @@ -1087,11 +1106,11 @@ endif() # Elbrus Math Library? if(BLA_VENDOR MATCHES "EML" OR BLA_VENDOR STREQUAL "All") - set(BLAS_EML_LIB "eml") + set(_blas_eml_lib "eml") # Check for OpenMP support, VIA BLA_VENDOR of eml_mt if(BLA_VENDOR MATCHES "_mt") - set(BLAS_EML_LIB "${BLAS_EML_LIB}_mt") + set(_blas_eml_lib "${_blas_eml_lib}_mt") endif() if(NOT BLAS_LIBRARIES) @@ -1100,13 +1119,13 @@ if(BLA_VENDOR MATCHES "EML" OR BLA_VENDOR STREQUAL "All") BLAS sgemm "" - "${BLAS_EML_LIB}" + "${_blas_eml_lib}" "" "" "" ) endif() - + unset(_blas_eml_lib) endif() # Fujitsu SSL2 Library? @@ -1163,3 +1182,5 @@ if(NOT BLA_F95) endif() _add_blas_target() +unset(_blas_fphsa_req_var) +unset(_BLAS_LIBRARIES) diff --git a/Modules/FindCUDAToolkit.cmake b/Modules/FindCUDAToolkit.cmake index 89b8c99..92042d2 100644 --- a/Modules/FindCUDAToolkit.cmake +++ b/Modules/FindCUDAToolkit.cmake @@ -844,14 +844,17 @@ 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}") + 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 bab7256..d54d2f6 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 2770c60..dd0975d 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/FindICU.cmake b/Modules/FindICU.cmake index 2bb49ad..1bae825 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/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 3146e06..f36acfd 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -298,7 +298,7 @@ if(NOT LAPACK_NOT_FOUND_MESSAGE) 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 +311,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 +350,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 +363,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 +388,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) @@ -485,6 +491,30 @@ if(NOT LAPACK_NOT_FOUND_MESSAGE) ) 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") + + # Check for OpenMP support, VIA BLA_VENDOR of scs_mp + if(BLA_VENDOR MATCHES "_mp") + set(_lapack_scsl_lib "${_lapack_scsl_lib}_mp") + endif() + + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "${_lapack_scsl_lib}" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) + unset(_lapack_scsl_lib) + endif() + # BLAS in acml library? if(BLA_VENDOR MATCHES "ACML" OR BLA_VENDOR STREQUAL "All") if(BLAS_LIBRARIES MATCHES ".+acml.+") @@ -580,6 +610,30 @@ if(NOT LAPACK_NOT_FOUND_MESSAGE) unset(_ssl2_suffix) endif() + # LAPACK in IBM ESSL library? + if(NOT LAPACK_LIBRARIES + AND (BLA_VENDOR MATCHES "IBMESSL" OR BLA_VENDOR STREQUAL "All")) + set(_lapack_essl_lib "essl") + + # Check for OpenMP support, VIA BLA_VENDOR of esslsmp + if(BLA_VENDOR MATCHES "_SMP") + set(_lapack_essl_lib "${_lapack_essl_lib}smp") + endif() + + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "${_lapack_essl_lib}" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) + unset(_lapack_essl_lib) + endif() + # NVHPC Library? if(NOT LAPACK_LIBRARIES AND (BLA_VENDOR MATCHES "NVHPC" OR BLA_VENDOR STREQUAL "All")) @@ -646,3 +700,5 @@ if(LAPACK_LIBRARIES STREQUAL "LAPACK_LIBRARIES-PLACEHOLDER-FOR-EMPTY-LIBRARIES") endif() _add_lapack_target() +unset(_lapack_fphsa_req_var) +unset(_LAPACK_LIBRARIES) diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index d8f0334..d4b4a34 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. @@ -333,6 +333,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 +493,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 +1466,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,6 +1546,29 @@ 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) @@ -1548,7 +1597,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 7c96d54..70d7e1d 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 c8df670..12a5fde 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 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1865,6 +1892,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 4108651..f4fe4a6 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 01ad5ac..4de5331 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -15,6 +15,8 @@ following variables will also be set: if pkg-config executable was found ``PKG_CONFIG_EXECUTABLE`` pathname of the pkg-config program +``PKG_CONFIG_ARGN`` + list of arguments to pass to pkg-config ``PKG_CONFIG_VERSION_STRING`` version of pkg-config (since CMake 2.8.8) @@ -29,13 +31,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 +54,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 +67,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 +117,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 +411,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 +426,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 +571,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) @@ -900,6 +930,18 @@ Variables Affecting Behavior .. versionadded:: 3.1 The ``PKG_CONFIG`` environment variable can be used as a hint. +.. variable:: PKG_CONFIG_ARGN + + .. versionadded:: 3.22 + + This can be set to a list of arguments to additionally pass to pkg-config + if needed. If not provided, it will be an empty string, however, if the + environment variable ``PKG_CONFIG`` is provided, this will be set to the + result of splitting the variable. + + The ``PKG_CONFIG`` environment variable can be used to provide both + ``PKG_CONFIG_EXECUTABLE`` and ``PKG_CONFIG_ARGN`` + .. variable:: PKG_CONFIG_USE_CMAKE_PREFIX_PATH .. versionadded:: 3.1 diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake index c6a3451..e4d6cf3 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 d480fc4..fd5ee53 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 ead55ca..1b9cfce 100644 --- a/Modules/GNUInstallDirs.cmake +++ b/Modules/GNUInstallDirs.cmake @@ -216,6 +216,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 @@ -237,11 +238,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}") @@ -251,7 +275,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) @@ -260,6 +285,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/GoogleTest.cmake b/Modules/GoogleTest.cmake index 80d8e23..a483c03 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,12 @@ 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 to ``--gtest_filter`` argument during test + discovery. + ``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 +418,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 +482,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}" @@ -515,6 +523,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 0f79c9a..6b3bf34 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 331623f..4d3bfe2 100644 --- a/Modules/InstallRequiredSystemLibraries.cmake +++ b/Modules/InstallRequiredSystemLibraries.cmake @@ -80,19 +80,34 @@ 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" + ) 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 967ad7b..c115f00 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 cbd748b..c72bf6d 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 0a9c487..8a0c972 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 0000000..ff35897 --- /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 0000000..8ebe19a --- /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-Initialize.cmake b/Modules/Platform/Android-Initialize.cmake index 50f0620..63bc949 100644 --- a/Modules/Platform/Android-Initialize.cmake +++ b/Modules/Platform/Android-Initialize.cmake @@ -56,11 +56,6 @@ if(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) endif() - # Don't search paths in PATH environment variable. - if(NOT DEFINED CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH) - set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF) - endif() - # Allows CMake to find headers in the architecture-specific include directories. set(CMAKE_LIBRARY_ARCHITECTURE "${CMAKE_ANDROID_ARCH_TRIPLE}") diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index 5c8f152..9808861 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) @@ -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 1b0815e..4ee7643 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}") |