diff options
Diffstat (limited to 'Modules')
131 files changed, 1459 insertions, 678 deletions
diff --git a/Modules/AndroidTestUtilities.cmake b/Modules/AndroidTestUtilities.cmake index 95e2ef7..ddccf58 100644 --- a/Modules/AndroidTestUtilities.cmake +++ b/Modules/AndroidTestUtilities.cmake @@ -5,6 +5,8 @@ AndroidTestUtilities ------------------------ +.. versionadded:: 3.7 + Create a test that automatically loads specified data onto an Android device. Introduction diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake index 2f3b9e1..f521d22 100644 --- a/Modules/BundleUtilities.cmake +++ b/Modules/BundleUtilities.cmake @@ -894,11 +894,16 @@ function(fixup_bundle_item resolved_embedded_item exepath dirs) # to install_name_tool: # if(changes) - set(cmd ${CMAKE_INSTALL_NAME_TOOL} ${changes} "${resolved_embedded_item}") - execute_process(COMMAND ${cmd} RESULT_VARIABLE install_name_tool_result) - if(NOT install_name_tool_result EQUAL 0) - string(REPLACE ";" "' '" msg "'${cmd}'") - message(FATAL_ERROR "Command failed:\n ${msg}") + # Check for a script by extension (.bat,.sh,...) or if the file starts with "#!" (shebang) + file(READ ${resolved_embedded_item} file_contents LIMIT 5) + if(NOT "${resolved_embedded_item}" MATCHES "\\.(bat|c?sh|bash|ksh|cmd)$" AND + NOT file_contents MATCHES "^#!") + set(cmd ${CMAKE_INSTALL_NAME_TOOL} ${changes} "${resolved_embedded_item}") + execute_process(COMMAND ${cmd} RESULT_VARIABLE install_name_tool_result) + if(NOT install_name_tool_result EQUAL 0) + string(REPLACE ";" "' '" msg "'${cmd}'") + message(FATAL_ERROR "Command failed:\n ${msg}") + endif() endif() endif() endfunction() diff --git a/Modules/CMakeASMInformation.cmake b/Modules/CMakeASMInformation.cmake index 03195cc..2dc1585 100644 --- a/Modules/CMakeASMInformation.cmake +++ b/Modules/CMakeASMInformation.cmake @@ -96,15 +96,5 @@ if(NOT CMAKE_EXECUTABLE_RPATH_LINK_ASM${ASM_DIALECT}_FLAG) set(CMAKE_EXECUTABLE_RPATH_LINK_ASM${ASM_DIALECT}_FLAG ${CMAKE_SHARED_LIBRARY_RPATH_LINK_ASM${ASM_DIALECT}_FLAG}) endif() -# to be done -if(NOT CMAKE_ASM${ASM_DIALECT}_CREATE_SHARED_LIBRARY) - set(CMAKE_ASM${ASM_DIALECT}_CREATE_SHARED_LIBRARY) -endif() - -if(NOT CMAKE_ASM${ASM_DIALECT}_CREATE_SHARED_MODULE) - set(CMAKE_ASM${ASM_DIALECT}_CREATE_SHARED_MODULE) -endif() - set(CMAKE_ASM${ASM_DIALECT}_INFOMATION_LOADED 1) - diff --git a/Modules/CMakeDependentOption.cmake b/Modules/CMakeDependentOption.cmake index 99d5070..96855d2 100644 --- a/Modules/CMakeDependentOption.cmake +++ b/Modules/CMakeDependentOption.cmake @@ -8,21 +8,34 @@ CMakeDependentOption 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. When the option is not presented a default value -is used, but any value set by the user is preserved for when the -option is presented again. Example invocation: +conditions are true. + +Usage: + +.. code-block:: cmake + + 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. + +Example invocation: .. code-block:: cmake - CMAKE_DEPENDENT_OPTION(USE_FOO "Use Foo" ON + 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. 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. Each element in the fourth parameter is -evaluated as an if-condition, so :ref:`Condition Syntax` can be used. +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. #]=======================================================================] macro(CMAKE_DEPENDENT_OPTION option doc default depends force) diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake index bc8b86b..a3e5a12 100644 --- a/Modules/CMakeDetermineASMCompiler.cmake +++ b/Modules/CMakeDetermineASMCompiler.cmake @@ -11,7 +11,7 @@ if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER) if(NOT $ENV{ASM${ASM_DIALECT}} STREQUAL "") get_filename_component(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT $ENV{ASM${ASM_DIALECT}} PROGRAM PROGRAM_ARGS CMAKE_ASM${ASM_DIALECT}_FLAGS_ENV_INIT) if(CMAKE_ASM${ASM_DIALECT}_FLAGS_ENV_INIT) - set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ARG1 "${CMAKE_ASM${ASM_DIALECT}_FLAGS_ENV_INIT}" CACHE STRING "First argument to ASM${ASM_DIALECT} compiler") + set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ARG1 "${CMAKE_ASM${ASM_DIALECT}_FLAGS_ENV_INIT}" CACHE STRING "Arguments to ASM${ASM_DIALECT} compiler") endif() if(NOT EXISTS ${CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT}) message(FATAL_ERROR "Could not find compiler set in environment variable ASM${ASM_DIALECT}:\n$ENV{ASM${ASM_DIALECT}}.") diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 86683d1..96f32e5 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -43,7 +43,7 @@ else() if(NOT $ENV{CC} STREQUAL "") get_filename_component(CMAKE_C_COMPILER_INIT $ENV{CC} PROGRAM PROGRAM_ARGS CMAKE_C_FLAGS_ENV_INIT) if(CMAKE_C_FLAGS_ENV_INIT) - set(CMAKE_C_COMPILER_ARG1 "${CMAKE_C_FLAGS_ENV_INIT}" CACHE STRING "First argument to C compiler") + set(CMAKE_C_COMPILER_ARG1 "${CMAKE_C_FLAGS_ENV_INIT}" CACHE STRING "Arguments to C compiler") endif() if(NOT EXISTS ${CMAKE_C_COMPILER_INIT}) message(FATAL_ERROR "Could not find compiler set in environment variable CC:\n$ENV{CC}.") @@ -87,7 +87,9 @@ else() "--target=arm-arm-none-eabi -mcpu=cortex-m3" ) endif() - +if(CMAKE_C_COMPILER_TARGET) + list(PREPEND CMAKE_C_COMPILER_ID_TEST_FLAGS "-c --target=${CMAKE_C_COMPILER_TARGET}") +endif() # Build a small source file to identify the compiler. if(NOT CMAKE_C_COMPILER_ID_RUN) set(CMAKE_C_COMPILER_ID_RUN 1) diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake index fa497cd..daca382 100644 --- a/Modules/CMakeDetermineCUDACompiler.cmake +++ b/Modules/CMakeDetermineCUDACompiler.cmake @@ -19,7 +19,7 @@ else() if(NOT $ENV{CUDACXX} STREQUAL "") get_filename_component(CMAKE_CUDA_COMPILER_INIT $ENV{CUDACXX} PROGRAM PROGRAM_ARGS CMAKE_CUDA_FLAGS_ENV_INIT) if(CMAKE_CUDA_FLAGS_ENV_INIT) - set(CMAKE_CUDA_COMPILER_ARG1 "${CMAKE_CUDA_FLAGS_ENV_INIT}" CACHE STRING "First argument to CXX compiler") + set(CMAKE_CUDA_COMPILER_ARG1 "${CMAKE_CUDA_FLAGS_ENV_INIT}" CACHE STRING "Arguments to CXX compiler") endif() if(NOT EXISTS ${CMAKE_CUDA_COMPILER_INIT}) message(FATAL_ERROR "Could not find compiler set in environment variable CUDACXX:\n$ENV{CUDACXX}.\n${CMAKE_CUDA_COMPILER_INIT}") @@ -232,7 +232,7 @@ if(NOT CMAKE_CUDA_COMPILER_ID_RUN) list(APPEND CMAKE_CUDA_COMPILER_ID_TEST_FLAGS_FIRST "${clang_test_flags}") # We perform compiler identification for a second time to extract implicit linking info and host compiler for NVCC. - # We also use it to verify that CMAKE_CUDA_ARCHITECTURES and additionaly on Clang that CUDA toolkit path works. + # We also use it to verify that CMAKE_CUDA_ARCHITECTURES and additionally on Clang that CUDA toolkit path works. # The latter could be done during compiler testing in the future to avoid doing this for Clang. # We need to unset the compiler ID otherwise CMAKE_DETERMINE_COMPILER_ID() doesn't work. set(CMAKE_CUDA_COMPILER_ID) diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index 662b831..2205c8f 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -42,7 +42,7 @@ else() if(NOT $ENV{CXX} STREQUAL "") get_filename_component(CMAKE_CXX_COMPILER_INIT $ENV{CXX} PROGRAM PROGRAM_ARGS CMAKE_CXX_FLAGS_ENV_INIT) if(CMAKE_CXX_FLAGS_ENV_INIT) - set(CMAKE_CXX_COMPILER_ARG1 "${CMAKE_CXX_FLAGS_ENV_INIT}" CACHE STRING "First argument to CXX compiler") + set(CMAKE_CXX_COMPILER_ARG1 "${CMAKE_CXX_FLAGS_ENV_INIT}" CACHE STRING "Arguments to CXX compiler") endif() if(NOT EXISTS ${CMAKE_CXX_COMPILER_INIT}) message(FATAL_ERROR "Could not find compiler set in environment variable CXX:\n$ENV{CXX}.\n${CMAKE_CXX_COMPILER_INIT}") @@ -83,6 +83,10 @@ else() ) endif() +if(CMAKE_CXX_COMPILER_TARGET) + list(PREPEND CMAKE_CXX_COMPILER_ID_TEST_FLAGS "-c --target=${CMAKE_CXX_COMPILER_TARGET}") +endif() + # Build a small source file to identify the compiler. if(NOT CMAKE_CXX_COMPILER_ID_RUN) set(CMAKE_CXX_COMPILER_ID_RUN 1) diff --git a/Modules/CMakeDetermineCompiler.cmake b/Modules/CMakeDetermineCompiler.cmake index cb1ab1d..2780399 100644 --- a/Modules/CMakeDetermineCompiler.cmake +++ b/Modules/CMakeDetermineCompiler.cmake @@ -107,16 +107,14 @@ macro(_cmake_find_compiler_path lang) if(CMAKE_${lang}_COMPILER) # we only get here if CMAKE_${lang}_COMPILER was specified using -D or a pre-made CMakeCache.txt # (e.g. via ctest) or set in CMAKE_TOOLCHAIN_FILE - # if CMAKE_${lang}_COMPILER is a list of length 2, use the first item as - # CMAKE_${lang}_COMPILER and the 2nd one as CMAKE_${lang}_COMPILER_ARG1 - list(LENGTH CMAKE_${lang}_COMPILER _CMAKE_${lang}_COMPILER_LIST_LENGTH) - if("${_CMAKE_${lang}_COMPILER_LIST_LENGTH}" EQUAL 2) - list(GET CMAKE_${lang}_COMPILER 1 CMAKE_${lang}_COMPILER_ARG1) - list(GET CMAKE_${lang}_COMPILER 0 CMAKE_${lang}_COMPILER) - endif() - unset(_CMAKE_${lang}_COMPILER_LIST_LENGTH) + # if CMAKE_${lang}_COMPILER is a list, use the first item as + # CMAKE_${lang}_COMPILER and the rest as CMAKE_${lang}_COMPILER_ARG1 + set(CMAKE_${lang}_COMPILER_ARG1 "${CMAKE_${lang}_COMPILER}") + list(POP_FRONT CMAKE_${lang}_COMPILER_ARG1 CMAKE_${lang}_COMPILER) + list(JOIN CMAKE_${lang}_COMPILER_ARG1 " " CMAKE_${lang}_COMPILER_ARG1) # find the compiler in the PATH if necessary + # if compiler (and arguments) comes from cache then synchronize cache with updated CMAKE_<LANG>_COMPILER get_filename_component(_CMAKE_USER_${lang}_COMPILER_PATH "${CMAKE_${lang}_COMPILER}" PATH) if(NOT _CMAKE_USER_${lang}_COMPILER_PATH) find_program(CMAKE_${lang}_COMPILER_WITH_PATH NAMES ${CMAKE_${lang}_COMPILER}) @@ -129,6 +127,12 @@ macro(_cmake_find_compiler_path lang) unset(_CMAKE_${lang}_COMPILER_CACHED) endif() unset(CMAKE_${lang}_COMPILER_WITH_PATH CACHE) + elseif (EXISTS ${CMAKE_${lang}_COMPILER}) + get_property(_CMAKE_${lang}_COMPILER_CACHED CACHE CMAKE_${lang}_COMPILER PROPERTY TYPE) + if(_CMAKE_${lang}_COMPILER_CACHED) + set(CMAKE_${lang}_COMPILER "${CMAKE_${lang}_COMPILER}" CACHE STRING "${lang} compiler" FORCE) + endif() + unset(_CMAKE_${lang}_COMPILER_CACHED) endif() endif() endmacro() diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 44332a6..d7a35e1 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -14,8 +14,10 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) # Make sure user-specified compiler flags are used. if(CMAKE_${lang}_FLAGS) set(CMAKE_${lang}_COMPILER_ID_FLAGS ${CMAKE_${lang}_FLAGS}) - else() + elseif(DEFINED ENV{${flagvar}}) set(CMAKE_${lang}_COMPILER_ID_FLAGS $ENV{${flagvar}}) + else(CMAKE_${lang}_FLAGS_INIT) + set(CMAKE_${lang}_COMPILER_ID_FLAGS ${CMAKE_${lang}_FLAGS_INIT}) endif() string(REPLACE " " ";" CMAKE_${lang}_COMPILER_ID_FLAGS_LIST "${CMAKE_${lang}_COMPILER_ID_FLAGS}") @@ -248,7 +250,7 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} set(id_PostBuildEvent_Command "") if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "^[Ll][Ll][Vv][Mm](_v[0-9]+(_xp)?)?$") set(id_cl_var "ClangClExecutable") - elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "^[Cc][Ll][Aa][Nn][Gg][Cc][Ll]$") + elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "^[Cc][Ll][Aa][Nn][Gg]([Cc][Ll]$|_[0-9])") set(id_cl "$(CLToolExe)") elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "v[0-9]+_clang_.*") set(id_cl clang.exe) @@ -310,17 +312,36 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} set(id_PreferredToolArchitecture "") endif() if(CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone") + set(id_keyword "Win32Proj") set(id_system "<ApplicationType>Windows Phone</ApplicationType>") elseif(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") + set(id_keyword "Win32Proj") set(id_system "<ApplicationType>Windows Store</ApplicationType>") + elseif(CMAKE_SYSTEM_NAME STREQUAL "Android") + set(id_keyword "Android") + set(id_system "<ApplicationType>Android</ApplicationType>") else() + set(id_keyword "Win32Proj") set(id_system "") endif() - if(id_system AND CMAKE_SYSTEM_VERSION MATCHES "^([0-9]+\\.[0-9]+)") + if(id_keyword STREQUAL "Android") + if(CMAKE_GENERATOR MATCHES "Visual Studio 14") + set(id_system_version "<ApplicationTypeRevision>2.0</ApplicationTypeRevision>") + elseif(CMAKE_GENERATOR MATCHES "Visual Studio 1[56]") + set(id_system_version "<ApplicationTypeRevision>3.0</ApplicationTypeRevision>") + else() + set(id_system_version "") + endif() + elseif(id_system AND CMAKE_SYSTEM_VERSION MATCHES "^([0-9]+\\.[0-9]+)") set(id_system_version "<ApplicationTypeRevision>${CMAKE_MATCH_1}</ApplicationTypeRevision>") else() set(id_system_version "") endif() + if(id_keyword STREQUAL "Android") + set(id_config_type "DynamicLibrary") + else() + set(id_config_type "Application") + endif() if(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION) set(id_WindowsTargetPlatformVersion "<WindowsTargetPlatformVersion>${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}</WindowsTargetPlatformVersion>") endif() @@ -333,9 +354,11 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} string(APPEND id_CustomGlobals "<${CMAKE_MATCH_1}>${CMAKE_MATCH_2}</${CMAKE_MATCH_1}>\n ") endif() endforeach() - if(id_platform STREQUAL ARM64) + if(id_keyword STREQUAL "Android") + set(id_WindowsSDKDesktopARMSupport "") + elseif(id_platform STREQUAL "ARM64") set(id_WindowsSDKDesktopARMSupport "<WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>") - elseif(id_platform STREQUAL ARM) + elseif(id_platform STREQUAL "ARM") set(id_WindowsSDKDesktopARMSupport "<WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>") else() set(id_WindowsSDKDesktopARMSupport "") @@ -702,7 +725,7 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) foreach(info ${CMAKE_${lang}_COMPILER_ID_STRINGS}) # The IAR-AVR compiler uses a binary format that places a '6' # character (0x34) before each character in the string. Strip - # out these characters without removing any legitamate characters. + # out these characters without removing any legitimate characters. if("${info}" MATCHES "(.)I.N.F.O.:.") string(REGEX REPLACE "${CMAKE_MATCH_1}(.)" "\\1" info "${info}") endif() diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake index 5f5a70a..8a57408 100644 --- a/Modules/CMakeDetermineFortranCompiler.cmake +++ b/Modules/CMakeDetermineFortranCompiler.cmake @@ -26,7 +26,7 @@ else() if(NOT $ENV{FC} STREQUAL "") get_filename_component(CMAKE_Fortran_COMPILER_INIT $ENV{FC} PROGRAM PROGRAM_ARGS CMAKE_Fortran_FLAGS_ENV_INIT) if(CMAKE_Fortran_FLAGS_ENV_INIT) - set(CMAKE_Fortran_COMPILER_ARG1 "${CMAKE_Fortran_FLAGS_ENV_INIT}" CACHE STRING "First argument to Fortran compiler") + set(CMAKE_Fortran_COMPILER_ARG1 "${CMAKE_Fortran_FLAGS_ENV_INIT}" CACHE STRING "Arguments to Fortran compiler") endif() if(EXISTS ${CMAKE_Fortran_COMPILER_INIT}) else() diff --git a/Modules/CMakeDetermineJavaCompiler.cmake b/Modules/CMakeDetermineJavaCompiler.cmake index 3092bb5..db456c0 100644 --- a/Modules/CMakeDetermineJavaCompiler.cmake +++ b/Modules/CMakeDetermineJavaCompiler.cmake @@ -11,7 +11,7 @@ if(NOT CMAKE_Java_COMPILER) if(NOT $ENV{JAVA_COMPILER} STREQUAL "") get_filename_component(CMAKE_Java_COMPILER_INIT $ENV{JAVA_COMPILER} PROGRAM PROGRAM_ARGS CMAKE_Java_FLAGS_ENV_INIT) if(CMAKE_Java_FLAGS_ENV_INIT) - set(CMAKE_Java_COMPILER_ARG1 "${CMAKE_Java_FLAGS_ENV_INIT}" CACHE STRING "First argument to Java compiler") + set(CMAKE_Java_COMPILER_ARG1 "${CMAKE_Java_FLAGS_ENV_INIT}" CACHE STRING "Arguments to Java compiler") endif() if(NOT EXISTS ${CMAKE_Java_COMPILER_INIT}) message(SEND_ERROR "Could not find compiler set in environment variable JAVA_COMPILER:\n$ENV{JAVA_COMPILER}.") diff --git a/Modules/CMakeDetermineOBJCCompiler.cmake b/Modules/CMakeDetermineOBJCCompiler.cmake index 11b47fd..709eb25 100644 --- a/Modules/CMakeDetermineOBJCCompiler.cmake +++ b/Modules/CMakeDetermineOBJCCompiler.cmake @@ -39,7 +39,7 @@ else() if($ENV{${var}} MATCHES ".+") get_filename_component(CMAKE_OBJC_COMPILER_INIT $ENV{${var}} PROGRAM PROGRAM_ARGS CMAKE_OBJC_FLAGS_ENV_INIT) if(CMAKE_OBJC_FLAGS_ENV_INIT) - set(CMAKE_OBJC_COMPILER_ARG1 "${CMAKE_OBJC_FLAGS_ENV_INIT}" CACHE STRING "First argument to Objective-C compiler") + set(CMAKE_OBJC_COMPILER_ARG1 "${CMAKE_OBJC_FLAGS_ENV_INIT}" CACHE STRING "Arguments to Objective-C compiler") endif() if(NOT EXISTS ${CMAKE_OBJC_COMPILER_INIT}) message(FATAL_ERROR "Could not find compiler set in environment variable ${var}:\n $ENV{${var}}") @@ -65,14 +65,11 @@ else() else() # we only get here if CMAKE_OBJC_COMPILER was specified using -D or a pre-made CMakeCache.txt # (e.g. via ctest) or set in CMAKE_TOOLCHAIN_FILE - # if CMAKE_OBJC_COMPILER is a list of length 2, use the first item as - # CMAKE_OBJC_COMPILER and the 2nd one as CMAKE_OBJC_COMPILER_ARG1 - - list(LENGTH CMAKE_OBJC_COMPILER _CMAKE_OBJC_COMPILER_LIST_LENGTH) - if("${_CMAKE_OBJC_COMPILER_LIST_LENGTH}" EQUAL 2) - list(GET CMAKE_OBJC_COMPILER 1 CMAKE_OBJC_COMPILER_ARG1) - list(GET CMAKE_OBJC_COMPILER 0 CMAKE_OBJC_COMPILER) - endif() + # if CMAKE_OBJC_COMPILER is a list, use the first item as + # CMAKE_OBJC_COMPILER and the rest as CMAKE_OBJC_COMPILER_ARG1 + set(CMAKE_OBJC_COMPILER_ARG1 "${CMAKE_OBJC_COMPILER}") + list(POP_FRONT CMAKE_OBJC_COMPILER_ARG1 CMAKE_OBJC_COMPILER) + list(JOIN CMAKE_OBJC_COMPILER_ARG1 " " CMAKE_OBJC_COMPILER_ARG1) # if a compiler was specified by the user but without path, # now try to find it with the full path diff --git a/Modules/CMakeDetermineOBJCXXCompiler.cmake b/Modules/CMakeDetermineOBJCXXCompiler.cmake index 99ad6c3..ffd0091 100644 --- a/Modules/CMakeDetermineOBJCXXCompiler.cmake +++ b/Modules/CMakeDetermineOBJCXXCompiler.cmake @@ -41,7 +41,7 @@ else() if($ENV{${var}} MATCHES ".+") get_filename_component(CMAKE_OBJCXX_COMPILER_INIT $ENV{${var}} PROGRAM PROGRAM_ARGS CMAKE_OBJCXX_FLAGS_ENV_INIT) if(CMAKE_OBJCXX_FLAGS_ENV_INIT) - set(CMAKE_OBJCXX_COMPILER_ARG1 "${CMAKE_OBJCXX_FLAGS_ENV_INIT}" CACHE STRING "First argument to Objective-C++ compiler") + set(CMAKE_OBJCXX_COMPILER_ARG1 "${CMAKE_OBJCXX_FLAGS_ENV_INIT}" CACHE STRING "Arguments to Objective-C++ compiler") endif() if(NOT EXISTS ${CMAKE_OBJCXX_COMPILER_INIT}) message(FATAL_ERROR "Could not find compiler set in environment variable ${var}:\n $ENV{${var}}") @@ -67,14 +67,11 @@ else() else() # we only get here if CMAKE_OBJCXX_COMPILER was specified using -D or a pre-made CMakeCache.txt # (e.g. via ctest) or set in CMAKE_TOOLCHAIN_FILE - # if CMAKE_OBJCXX_COMPILER is a list of length 2, use the first item as - # CMAKE_OBJCXX_COMPILER and the 2nd one as CMAKE_OBJCXX_COMPILER_ARG1 - - list(LENGTH CMAKE_OBJCXX_COMPILER _CMAKE_OBJCXX_COMPILER_LIST_LENGTH) - if("${_CMAKE_OBJCXX_COMPILER_LIST_LENGTH}" EQUAL 2) - list(GET CMAKE_OBJCXX_COMPILER 1 CMAKE_OBJCXX_COMPILER_ARG1) - list(GET CMAKE_OBJCXX_COMPILER 0 CMAKE_OBJCXX_COMPILER) - endif() + # if CMAKE_OBJCXX_COMPILER is a list, use the first item as + # CMAKE_OBJCXX_COMPILER and the rest as CMAKE_OBJCXX_COMPILER_ARG1 + set(CMAKE_OBJCXX_COMPILER_ARG1 "${CMAKE_OBJCXX_COMPILER}") + list(POP_FRONT CMAKE_OBJCXX_COMPILER_ARG1 CMAKE_OBJCXX_COMPILER) + list(JOIN CMAKE_OBJCXX_COMPILER_ARG1 " " CMAKE_OBJCXX_COMPILER_ARG1) # if a compiler was specified by the user but without path, # now try to find it with the full path diff --git a/Modules/CMakeDetermineRCCompiler.cmake b/Modules/CMakeDetermineRCCompiler.cmake index 8801e16..f8d55a5 100644 --- a/Modules/CMakeDetermineRCCompiler.cmake +++ b/Modules/CMakeDetermineRCCompiler.cmake @@ -13,7 +13,7 @@ if(NOT CMAKE_RC_COMPILER) if(NOT $ENV{RC} STREQUAL "") get_filename_component(CMAKE_RC_COMPILER_INIT $ENV{RC} PROGRAM PROGRAM_ARGS CMAKE_RC_FLAGS_ENV_INIT) if(CMAKE_RC_FLAGS_ENV_INIT) - set(CMAKE_RC_COMPILER_ARG1 "${CMAKE_RC_FLAGS_ENV_INIT}" CACHE STRING "First argument to RC compiler") + set(CMAKE_RC_COMPILER_ARG1 "${CMAKE_RC_FLAGS_ENV_INIT}" CACHE STRING "Arguments to RC compiler") endif() if(EXISTS ${CMAKE_RC_COMPILER_INIT}) else() diff --git a/Modules/CMakeDetermineSwiftCompiler.cmake b/Modules/CMakeDetermineSwiftCompiler.cmake index 688133f..aaad560 100644 --- a/Modules/CMakeDetermineSwiftCompiler.cmake +++ b/Modules/CMakeDetermineSwiftCompiler.cmake @@ -27,7 +27,7 @@ elseif("${CMAKE_GENERATOR}" MATCHES "^Ninja") PROGRAM_ARGS CMAKE_Swift_FLAGS_ENV_INIT) if(CMAKE_Swift_FLAGS_ENV_INIT) set(CMAKE_Swift_COMPILER_ARG1 "${CMAKE_Swift_FLAGS_ENV_INIT}" CACHE - STRING "First argument to the Swift compiler") + STRING "Arguments to the Swift compiler") endif() if(NOT EXISTS ${CMAKE_Swift_COMPILER_INIT}) message(FATAL_ERROR "Could not find compiler set in environment variable SWIFTC\n$ENV{SWIFTC}.\n${CMAKE_Swift_COMPILER_INIT}") diff --git a/Modules/CMakeIOSInstallCombined.cmake b/Modules/CMakeIOSInstallCombined.cmake index 418bafd..44bb622 100644 --- a/Modules/CMakeIOSInstallCombined.cmake +++ b/Modules/CMakeIOSInstallCombined.cmake @@ -80,6 +80,17 @@ function(_ios_install_combined_get_valid_archs sdk resultvar) cmake_policy(POP) endfunction() +# Make both arch lists a disjoint set by preferring the current SDK +# (starting with Xcode 12 arm64 is available as device and simulator arch on iOS) +function(_ios_install_combined_prune_common_archs corr_sdk corr_archs_var this_archs_var) + list(REMOVE_ITEM ${corr_archs_var} ${${this_archs_var}}) + + string(REPLACE ";" " " printable "${${corr_archs_var}}") + _ios_install_combined_message("Architectures (${corr_sdk}) after pruning: ${printable}") + + set("${corr_archs_var}" "${${corr_archs_var}}" PARENT_SCOPE) +endfunction() + # Final target can contain more architectures that specified by SDK. This # function will run 'lipo -info' and parse output. Result will be returned # as a CMake list. @@ -266,8 +277,9 @@ function(ios_install_combined target destination) _ios_install_combined_detect_sdks(this_sdk corr_sdk) # Get architectures of the target - _ios_install_combined_get_valid_archs("${corr_sdk}" corr_valid_archs) _ios_install_combined_get_valid_archs("${this_sdk}" this_valid_archs) + _ios_install_combined_get_valid_archs("${corr_sdk}" corr_valid_archs) + _ios_install_combined_prune_common_archs("${corr_sdk}" corr_valid_archs this_valid_archs) # Return if there are no valid architectures for the SDK. # (note that library already installed) diff --git a/Modules/CMakeParseImplicitIncludeInfo.cmake b/Modules/CMakeParseImplicitIncludeInfo.cmake index ff4c325..7cd7548 100644 --- a/Modules/CMakeParseImplicitIncludeInfo.cmake +++ b/Modules/CMakeParseImplicitIncludeInfo.cmake @@ -7,7 +7,7 @@ # for compilers that report them that way. on success we return the # list of dirs in id_var and set state_var to the 'done' state. function(cmake_parse_implicit_include_line line lang id_var log_var state_var) - # clear variables we append to (avoids possible polution from parent scopes) + # clear variables we append to (avoids possible pollution from parent scopes) unset(rv) set(log "") @@ -162,7 +162,7 @@ endfunction() function(cmake_parse_implicit_include_info text lang dir_var log_var state_var) set(state start) # values: start, loading, done - # clear variables we append to (avoids possible polution from parent scopes) + # clear variables we append to (avoids possible pollution from parent scopes) set(implicit_dirs_tmp) set(log "") diff --git a/Modules/CMakePlatformId.h.in b/Modules/CMakePlatformId.h.in index 40668a3..0b81c88 100644 --- a/Modules/CMakePlatformId.h.in +++ b/Modules/CMakePlatformId.h.in @@ -206,6 +206,24 @@ # else /* unknown architecture */ # define ARCHITECTURE_ID "" # endif + +#elif defined(__TI_COMPILER_VERSION__) +# if defined(__TI_ARM__) +# define ARCHITECTURE_ID "ARM" + +# elif defined(__MSP430__) +# define ARCHITECTURE_ID "MSP430" + +# elif defined(__TMS320C28XX__) +# define ARCHITECTURE_ID "TMS320C28x" + +# elif defined(__TMS320C6X__) || defined(_TMS320C6X) +# define ARCHITECTURE_ID "TMS320C6x" + +# else /* unknown architecture */ +# define ARCHITECTURE_ID "" +# endif + #else # define ARCHITECTURE_ID #endif @@ -283,4 +301,3 @@ char const info_simulate_version[] = { array rather than assigning a pointer to a static array. */ char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]"; char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]"; - diff --git a/Modules/CMakeTestCCompiler.cmake b/Modules/CMakeTestCCompiler.cmake index 3734ec4..03f2db2 100644 --- a/Modules/CMakeTestCCompiler.cmake +++ b/Modules/CMakeTestCCompiler.cmake @@ -11,7 +11,7 @@ endif() include(CMakeTestCompilerCommon) -# work around enforced code signing and / or missing exectuable target type +# work around enforced code signing and / or missing executable target type set(__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE}) if(_CMAKE_FEATURE_DETECTION_TARGET_TYPE) set(CMAKE_TRY_COMPILE_TARGET_TYPE ${_CMAKE_FEATURE_DETECTION_TARGET_TYPE}) diff --git a/Modules/CMakeTestCXXCompiler.cmake b/Modules/CMakeTestCXXCompiler.cmake index b9cb1dd..0d2d0b0 100644 --- a/Modules/CMakeTestCXXCompiler.cmake +++ b/Modules/CMakeTestCXXCompiler.cmake @@ -11,7 +11,7 @@ endif() include(CMakeTestCompilerCommon) -# work around enforced code signing and / or missing exectuable target type +# work around enforced code signing and / or missing executable target type set(__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE}) if(_CMAKE_FEATURE_DETECTION_TARGET_TYPE) set(CMAKE_TRY_COMPILE_TARGET_TYPE ${_CMAKE_FEATURE_DETECTION_TARGET_TYPE}) diff --git a/Modules/CMakeTestOBJCCompiler.cmake b/Modules/CMakeTestOBJCCompiler.cmake index 0e333c0..298272b 100644 --- a/Modules/CMakeTestOBJCCompiler.cmake +++ b/Modules/CMakeTestOBJCCompiler.cmake @@ -11,7 +11,7 @@ endif() include(CMakeTestCompilerCommon) -# work around enforced code signing and / or missing exectuable target type +# work around enforced code signing and / or missing executable target type set(__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE}) if(_CMAKE_FEATURE_DETECTION_TARGET_TYPE) set(CMAKE_TRY_COMPILE_TARGET_TYPE ${_CMAKE_FEATURE_DETECTION_TARGET_TYPE}) diff --git a/Modules/CMakeTestOBJCXXCompiler.cmake b/Modules/CMakeTestOBJCXXCompiler.cmake index dc153a7..36e3efc 100644 --- a/Modules/CMakeTestOBJCXXCompiler.cmake +++ b/Modules/CMakeTestOBJCXXCompiler.cmake @@ -11,7 +11,7 @@ endif() include(CMakeTestCompilerCommon) -# work around enforced code signing and / or missing exectuable target type +# work around enforced code signing and / or missing executable target type set(__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE}) if(_CMAKE_FEATURE_DETECTION_TARGET_TYPE) set(CMAKE_TRY_COMPILE_TARGET_TYPE ${_CMAKE_FEATURE_DETECTION_TARGET_TYPE}) diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index d0cfc2b..8a0ef30 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -22,9 +22,13 @@ section below for details. The generated binary installers will contain all files that have been installed via CMake's :command:`install` command (and the deprecated commands :command:`install_files`, :command:`install_programs`, and -:command:`install_targets`). Certain kinds of binary installers can be -configured such that users can select individual application components to -install. See the :module:`CPackComponent` module for further details. +:command:`install_targets`). Note that the ``DESTINATION`` option of the +:command:`install` command must be a relative path; otherwise installed files +are ignored by CPack. + +Certain kinds of binary installers can be configured such that users can select +individual application components to install. See the :module:`CPackComponent` +module for further details. Source packages (configured through ``CPackSourceConfig.cmake`` and generated by the :cpack_gen:`CPack Archive Generator`) will contain all source files in @@ -386,6 +390,21 @@ The following variables are for advanced uses of CPack: select the CPack generator(s) to be used when building the ``package`` target or when running :manual:`cpack <cpack(1)>` without the ``-G`` option. +.. variable:: CPACK_PRE_BUILD_SCRIPTS + + List of CMake scripts to execute after CPack has installed the files to + be packed into a staging directory and before producing the result + packages. + +.. variable:: CPACK_POST_BUILD_SCRIPTS + + List of CMake scripts to execute after CPack has produced the result + packages and before copying them back to a build directory. + +.. variable:: CPACK_PACKAGE_FILES + + List of resulting package files passed to the ``CPACK_POST_BUILD_SCRIPTS``. + #]=======================================================================] # Define this var in order to avoid (or warn) concerning multiple inclusion @@ -420,7 +439,7 @@ endmacro() # find any variable that starts with CPACK and create a variable # _CPACK_OTHER_VARIABLES_ that contains SET commands for # each cpack variable. _CPACK_OTHER_VARIABLES_ is then -# used as an @ replacment in configure_file for the CPackConfig. +# used as an @ replacement in configure_file for the CPackConfig. function(cpack_encode_variables) set(commands "") get_cmake_property(res VARIABLES) diff --git a/Modules/CPackIFW.cmake b/Modules/CPackIFW.cmake index 80a907f..58e6a37 100644 --- a/Modules/CPackIFW.cmake +++ b/Modules/CPackIFW.cmake @@ -5,6 +5,8 @@ CPackIFW -------- +.. versionadded:: 3.1 + This module looks for the location of the command-line utilities supplied with the `Qt Installer Framework <http://doc.qt.io/qtinstallerframework/index.html>`_ (QtIFW). diff --git a/Modules/CPackIFWConfigureFile.cmake b/Modules/CPackIFWConfigureFile.cmake index 0abe0da..296b13f 100644 --- a/Modules/CPackIFWConfigureFile.cmake +++ b/Modules/CPackIFWConfigureFile.cmake @@ -5,6 +5,8 @@ CPackIFWConfigureFile --------------------- +.. versionadded:: 3.8 + The module defines :command:`configure_file` similar command to configure file templates prepared in QtIFW/SDK/Creator style. diff --git a/Modules/CSharpUtilities.cmake b/Modules/CSharpUtilities.cmake index 6a4b5c7..dedb146 100644 --- a/Modules/CSharpUtilities.cmake +++ b/Modules/CSharpUtilities.cmake @@ -5,6 +5,8 @@ CSharpUtilities --------------- +.. versionadded:: 3.8 + Functions to make configuration of CSharp/.NET targets easier. A collection of CMake utility functions useful for dealing with CSharp diff --git a/Modules/CTestCoverageCollectGCOV.cmake b/Modules/CTestCoverageCollectGCOV.cmake index b1268be..a01a2fe 100644 --- a/Modules/CTestCoverageCollectGCOV.cmake +++ b/Modules/CTestCoverageCollectGCOV.cmake @@ -5,6 +5,8 @@ CTestCoverageCollectGCOV ------------------------ +.. versionadded:: 3.2 + This module provides the ``ctest_coverage_collect_gcov`` function. This function runs gcov on all .gcda files found in the binary tree diff --git a/Modules/CheckFortranCompilerFlag.cmake b/Modules/CheckFortranCompilerFlag.cmake index 299cd8c..b8fac97 100644 --- a/Modules/CheckFortranCompilerFlag.cmake +++ b/Modules/CheckFortranCompilerFlag.cmake @@ -5,6 +5,8 @@ CheckFortranCompilerFlag ------------------------ +.. versionadded:: 3.3 + Check whether the Fortran compiler supports a given flag. .. command:: check_fortran_compiler_flag diff --git a/Modules/CheckFortranSourceCompiles.cmake b/Modules/CheckFortranSourceCompiles.cmake index 3354bfb..d776b0c 100644 --- a/Modules/CheckFortranSourceCompiles.cmake +++ b/Modules/CheckFortranSourceCompiles.cmake @@ -5,6 +5,8 @@ CheckFortranSourceCompiles -------------------------- +.. versionadded:: 3.1 + Check if given Fortran source compiles and links into an executable. .. command:: check_fortran_source_compiles diff --git a/Modules/CheckFortranSourceRuns.cmake b/Modules/CheckFortranSourceRuns.cmake index f858b84..a710352 100644 --- a/Modules/CheckFortranSourceRuns.cmake +++ b/Modules/CheckFortranSourceRuns.cmake @@ -5,6 +5,8 @@ CheckFortranSourceRuns ---------------------- +.. versionadded:: 3.14 + Check if given Fortran source compiles and links into an executable and can subsequently be run. diff --git a/Modules/CheckIPOSupported.cmake b/Modules/CheckIPOSupported.cmake index 90a9f61..1dd951d 100644 --- a/Modules/CheckIPOSupported.cmake +++ b/Modules/CheckIPOSupported.cmake @@ -5,6 +5,8 @@ CheckIPOSupported ----------------- +.. versionadded:: 3.9 + Check whether the compiler supports an interprocedural optimization (IPO/LTO). Use this before enabling the :prop_tgt:`INTERPROCEDURAL_OPTIMIZATION` target property. diff --git a/Modules/CheckLanguage.cmake b/Modules/CheckLanguage.cmake index d67d8d3..44387d4 100644 --- a/Modules/CheckLanguage.cmake +++ b/Modules/CheckLanguage.cmake @@ -20,7 +20,7 @@ test project. The result is cached in :variable:`CMAKE_<LANG>_COMPILER` as the compiler that was found, or ``NOTFOUND`` if the language cannot be enabled. For CUDA which can have an explicit host compiler, the cache :variable:`CMAKE_CUDA_HOST_COMPILER` variable will be set if it was required -for compilation. +for compilation (and cleared if it was not). Example: diff --git a/Modules/CheckLinkerFlag.cmake b/Modules/CheckLinkerFlag.cmake index beda5fe..cd7301f 100644 --- a/Modules/CheckLinkerFlag.cmake +++ b/Modules/CheckLinkerFlag.cmake @@ -5,6 +5,8 @@ CheckLinkerFlag --------------- +.. versionadded:: 3.18 + Check whether the compiler supports a given link flag. .. command:: check_linker_flag diff --git a/Modules/CheckOBJCCompilerFlag.cmake b/Modules/CheckOBJCCompilerFlag.cmake index 1d975da..a98f429 100644 --- a/Modules/CheckOBJCCompilerFlag.cmake +++ b/Modules/CheckOBJCCompilerFlag.cmake @@ -5,6 +5,8 @@ CheckOBJCCompilerFlag --------------------- +.. versionadded:: 3.16 + Check whether the Objective-C compiler supports a given flag. .. command:: check_objc_compiler_flag diff --git a/Modules/CheckOBJCSourceCompiles.cmake b/Modules/CheckOBJCSourceCompiles.cmake index 601f1fa..502ed74 100644 --- a/Modules/CheckOBJCSourceCompiles.cmake +++ b/Modules/CheckOBJCSourceCompiles.cmake @@ -5,6 +5,8 @@ CheckOBJCSourceCompiles ----------------------- +.. versionadded:: 3.16 + Check if given Objective-C source compiles and links into an executable. .. command:: check_objc_source_compiles diff --git a/Modules/CheckOBJCSourceRuns.cmake b/Modules/CheckOBJCSourceRuns.cmake index 6684693..9d4fb1b 100644 --- a/Modules/CheckOBJCSourceRuns.cmake +++ b/Modules/CheckOBJCSourceRuns.cmake @@ -5,6 +5,8 @@ CheckOBJCSourceRuns ------------------- +.. versionadded:: 3.16 + Check if given Objective-C source compiles and links into an executable and can subsequently be run. diff --git a/Modules/CheckOBJCXXCompilerFlag.cmake b/Modules/CheckOBJCXXCompilerFlag.cmake index c32741b..7944ab0 100644 --- a/Modules/CheckOBJCXXCompilerFlag.cmake +++ b/Modules/CheckOBJCXXCompilerFlag.cmake @@ -5,6 +5,8 @@ CheckOBJCXXCompilerFlag ----------------------- +.. versionadded:: 3.16 + Check whether the Objective-C++ compiler supports a given flag. .. command:: check_objcxx_compiler_flag diff --git a/Modules/CheckOBJCXXSourceCompiles.cmake b/Modules/CheckOBJCXXSourceCompiles.cmake index 2ee79f4..7b839e4 100644 --- a/Modules/CheckOBJCXXSourceCompiles.cmake +++ b/Modules/CheckOBJCXXSourceCompiles.cmake @@ -5,6 +5,8 @@ CheckOBJCXXSourceCompiles ------------------------- +.. versionadded:: 3.16 + Check if given Objective-C++ source compiles and links into an executable. .. command:: check_objcxx_source_compiles diff --git a/Modules/CheckOBJCXXSourceRuns.cmake b/Modules/CheckOBJCXXSourceRuns.cmake index 7f7e04f..c327598 100644 --- a/Modules/CheckOBJCXXSourceRuns.cmake +++ b/Modules/CheckOBJCXXSourceRuns.cmake @@ -5,6 +5,8 @@ CheckOBJCXXSourceRuns --------------------- +.. versionadded:: 3.16 + Check if given Objective-C++ source compiles and links into an executable and can subsequently be run. diff --git a/Modules/CheckPIESupported.cmake b/Modules/CheckPIESupported.cmake index 6d63f0b..a99d8c4 100644 --- a/Modules/CheckPIESupported.cmake +++ b/Modules/CheckPIESupported.cmake @@ -5,6 +5,8 @@ CheckPIESupported ----------------- +.. versionadded:: 3.14 + Check whether the linker supports Position Independent Code (PIE) or No Position Independent Code (NO_PIE) for executables. Use this to ensure that the :prop_tgt:`POSITION_INDEPENDENT_CODE` target diff --git a/Modules/CheckTypeSize.cmake b/Modules/CheckTypeSize.cmake index 2b07b7c..17beadc 100644 --- a/Modules/CheckTypeSize.cmake +++ b/Modules/CheckTypeSize.cmake @@ -89,17 +89,38 @@ function(__check_type_size_impl type var map builtin language) message(CHECK_START "Check size of ${type}") endif() + # Perform language check + if(language STREQUAL "C") + set(src ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${var}.c) + elseif(language STREQUAL "CXX") + set(src ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${var}.cpp) + else() + message(FATAL_ERROR "Unknown language:\n ${language}\nSupported languages: C, CXX.\n") + endif() + # Include header files. set(headers) if(builtin) - if(HAVE_SYS_TYPES_H) - string(APPEND headers "#include <sys/types.h>\n") - endif() - if(HAVE_STDINT_H) - string(APPEND headers "#include <stdint.h>\n") - endif() - if(HAVE_STDDEF_H) - string(APPEND headers "#include <stddef.h>\n") + if(language STREQUAL "CXX" AND type MATCHES "^std::") + if(HAVE_SYS_TYPES_H) + string(APPEND headers "#include <sys/types.h>\n") + endif() + if(HAVE_CSTDINT) + string(APPEND headers "#include <cstdint>\n") + endif() + if(HAVE_CSTDDEF) + string(APPEND headers "#include <cstddef>\n") + endif() + else() + if(HAVE_SYS_TYPES_H) + string(APPEND headers "#include <sys/types.h>\n") + endif() + if(HAVE_STDINT_H) + string(APPEND headers "#include <stdint.h>\n") + endif() + if(HAVE_STDDEF_H) + string(APPEND headers "#include <stddef.h>\n") + endif() endif() endif() foreach(h ${CMAKE_EXTRA_INCLUDE_FILES}) @@ -107,14 +128,6 @@ function(__check_type_size_impl type var map builtin language) endforeach() # Perform the check. - - if(language STREQUAL "C") - set(src ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${var}.c) - elseif(language STREQUAL "CXX") - set(src ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${var}.cpp) - else() - message(FATAL_ERROR "Unknown language:\n ${language}\nSupported languages: C, CXX.\n") - endif() set(bin ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${var}.bin) configure_file(${__check_type_size_dir}/CheckTypeSize.c.in ${src} @ONLY) try_compile(HAVE_${var} ${CMAKE_BINARY_DIR} ${src} @@ -232,8 +245,13 @@ macro(CHECK_TYPE_SIZE TYPE VARIABLE) check_include_file(stddef.h HAVE_STDDEF_H) elseif(_language STREQUAL "CXX") check_include_file_cxx(sys/types.h HAVE_SYS_TYPES_H) - check_include_file_cxx(stdint.h HAVE_STDINT_H) - check_include_file_cxx(stddef.h HAVE_STDDEF_H) + if("${TYPE}" MATCHES "^std::") + check_include_file_cxx(cstdint HAVE_CSTDINT) + check_include_file_cxx(cstddef HAVE_CSTDDEF) + else() + check_include_file_cxx(stdint.h HAVE_STDINT_H) + check_include_file_cxx(stddef.h HAVE_STDDEF_H) + endif() endif() endif() unset(_CHECK_TYPE_SIZE_BUILTIN_TYPES_ONLY) diff --git a/Modules/Compiler/ARMClang.cmake b/Modules/Compiler/ARMClang.cmake index 01ce91d..70e6ffb 100644 --- a/Modules/Compiler/ARMClang.cmake +++ b/Modules/Compiler/ARMClang.cmake @@ -98,7 +98,7 @@ macro(__compiler_armclang lang) set(__mcpu_flag_set TRUE) endif() if(NOT __march_flag_set AND NOT __mcpu_flag_set) - message(FATAL_ERROR "Atleast one of the variables CMAKE_SYSTEM_PROCESSOR or CMAKE_SYSTEM_ARCH must be set for ARMClang\n" + message(FATAL_ERROR "At least one of the variables CMAKE_SYSTEM_PROCESSOR or CMAKE_SYSTEM_ARCH must be set for ARMClang\n" "Supported processor: ${CMAKE_${lang}_COMPILER_PROCESSOR_LIST}\n" " Supported Architecture: ${CMAKE_${lang}_COMPILER_ARCH_LIST}") endif() diff --git a/Modules/Compiler/AppleClang-C.cmake b/Modules/Compiler/AppleClang-C.cmake index 2794f52..26a4bbd 100644 --- a/Modules/Compiler/AppleClang-C.cmake +++ b/Modules/Compiler/AppleClang-C.cmake @@ -1,6 +1,8 @@ include(Compiler/Clang) __compiler_clang(C) +set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c) + if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.0) set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90") diff --git a/Modules/Compiler/AppleClang-CXX.cmake b/Modules/Compiler/AppleClang-CXX.cmake index 15edc21..611c674 100644 --- a/Modules/Compiler/AppleClang-CXX.cmake +++ b/Modules/Compiler/AppleClang-CXX.cmake @@ -1,6 +1,8 @@ include(Compiler/Clang) __compiler_clang(CXX) +set(CMAKE_CXX_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c++) + if(NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") endif() diff --git a/Modules/Compiler/Clang-C.cmake b/Modules/Compiler/Clang-C.cmake index 7c4a263..fb6ffa7 100644 --- a/Modules/Compiler/Clang-C.cmake +++ b/Modules/Compiler/Clang-C.cmake @@ -8,6 +8,8 @@ endif() if("x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC") set(CMAKE_C_CLANG_TIDY_DRIVER_MODE "cl") +elseif("x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU") + set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c) endif() if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4) diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake index 789e991..311d2b0 100644 --- a/Modules/Compiler/Clang-CXX.cmake +++ b/Modules/Compiler/Clang-CXX.cmake @@ -2,7 +2,9 @@ include(Compiler/Clang) __compiler_clang(CXX) __compiler_clang_cxx_standards(CXX) + if("x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU") + set(CMAKE_CXX_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c++) set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") endif() diff --git a/Modules/Compiler/GNU-C.cmake b/Modules/Compiler/GNU-C.cmake index ca286b3..8105a77 100644 --- a/Modules/Compiler/GNU-C.cmake +++ b/Modules/Compiler/GNU-C.cmake @@ -1,6 +1,8 @@ include(Compiler/GNU) __compiler_gnu(C) +set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c) + if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.5) set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90") diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake index fcaaeab..59ec056 100644 --- a/Modules/Compiler/GNU-CXX.cmake +++ b/Modules/Compiler/GNU-CXX.cmake @@ -1,6 +1,8 @@ include(Compiler/GNU) __compiler_gnu(CXX) +set(CMAKE_CXX_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c++) + if (WIN32) if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6) set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fno-keep-inline-dllexport") diff --git a/Modules/Compiler/Intel-C.cmake b/Modules/Compiler/Intel-C.cmake index ec3bfd8..322f63d 100644 --- a/Modules/Compiler/Intel-C.cmake +++ b/Modules/Compiler/Intel-C.cmake @@ -28,6 +28,8 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC") else() + set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c) + if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 15.0.0) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") diff --git a/Modules/Compiler/Intel-CXX.cmake b/Modules/Compiler/Intel-CXX.cmake index b71b946..42adfd1 100644 --- a/Modules/Compiler/Intel-CXX.cmake +++ b/Modules/Compiler/Intel-CXX.cmake @@ -42,6 +42,8 @@ if("x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") else() + set(CMAKE_CXX_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c++) + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0.0) set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std=c++20") set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std=gnu++20") diff --git a/Modules/Compiler/OpenWatcom.cmake b/Modules/Compiler/OpenWatcom.cmake index 9efbfc2..a962513 100644 --- a/Modules/Compiler/OpenWatcom.cmake +++ b/Modules/Compiler/OpenWatcom.cmake @@ -86,7 +86,7 @@ set(CMAKE_C_CREATE_STATIC_LIBRARY set(CMAKE_CXX_CREATE_STATIC_LIBRARY ${CMAKE_C_CREATE_STATIC_LIBRARY}) -# old CMake internaly used OpenWatcom version macros +# old CMake internally used OpenWatcom version macros # for backward compatibility if(NOT _CMAKE_WATCOM_VERSION) set(_CMAKE_WATCOM_VERSION 1) diff --git a/Modules/Compiler/PGI-CXX.cmake b/Modules/Compiler/PGI-CXX.cmake index c77de36..2d7a303 100644 --- a/Modules/Compiler/PGI-CXX.cmake +++ b/Modules/Compiler/PGI-CXX.cmake @@ -4,19 +4,19 @@ string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL_INIT " -DNDEBUG") string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " -DNDEBUG") if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12.10) - set(CMAKE_CXX98_STANDARD_COMPILE_OPTION -A) + set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "") set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION --gnu_extensions) set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON) if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.10) - set(CMAKE_CXX11_STANDARD_COMPILE_OPTION --c++11 -A) + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION --c++11) set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION --c++11 --gnu_extensions) set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON) if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15.7) - set(CMAKE_CXX14_STANDARD_COMPILE_OPTION --c++14 -A) + set(CMAKE_CXX14_STANDARD_COMPILE_OPTION --c++14) set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION --c++14 --gnu_extensions) set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON) if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 17.1) - set(CMAKE_CXX17_STANDARD_COMPILE_OPTION --c++17 -A) + set(CMAKE_CXX17_STANDARD_COMPILE_OPTION --c++17) set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION --c++17 --gnu_extensions) set(CMAKE_CXX17_STANDARD__HAS_FULL_SUPPORT ON) endif() diff --git a/Modules/Compiler/TI-ASM.cmake b/Modules/Compiler/TI-ASM.cmake index a566d70..01965d2 100644 --- a/Modules/Compiler/TI-ASM.cmake +++ b/Modules/Compiler/TI-ASM.cmake @@ -1,8 +1,4 @@ -set(CMAKE_LIBRARY_PATH_FLAG "--search_path=") -set(CMAKE_LINK_LIBRARY_FLAG "--library=") -set(CMAKE_INCLUDE_FLAG_ASM "--include_path=") - -set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> --compile_only --asm_file=<SOURCE> <DEFINES> <INCLUDES> <FLAGS> --output_file=<OBJECT>") -set(CMAKE_ASM_LINK_EXECUTABLE "<CMAKE_ASM_COMPILER> <OBJECTS> --run_linker --output_file=<TARGET> <CMAKE_ASM_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>") +include(Compiler/TI) +__compiler_ti(ASM) set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS asm;s;abs) diff --git a/Modules/Compiler/TI-C.cmake b/Modules/Compiler/TI-C.cmake index b060ee9..8ea01b5 100644 --- a/Modules/Compiler/TI-C.cmake +++ b/Modules/Compiler/TI-C.cmake @@ -1,22 +1,8 @@ -set(CMAKE_LIBRARY_PATH_FLAG "--search_path=") -set(CMAKE_LINK_LIBRARY_FLAG "--library=") -set(CMAKE_INCLUDE_FLAG_C "--include_path=") +include(Compiler/TI) +__compiler_ti(C) set(CMAKE_C90_STANDARD_COMPILE_OPTION "--c89") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "--c89 --relaxed_ansi") set(CMAKE_C99_STANDARD_COMPILE_OPTION "--c99") set(CMAKE_C99_EXTENSION_COMPILE_OPTION "--c99 --relaxed_ansi") - -set(CMAKE_DEPFILE_FLAGS_C "--preproc_with_compile --preproc_dependency=<DEPFILE>") - -set(CMAKE_C_CREATE_ASSEMBLY_SOURCE "<CMAKE_C_COMPILER> --compile_only --skip_assembler --c_file=<SOURCE> <DEFINES> <INCLUDES> <FLAGS> --output_file=<ASSEMBLY_SOURCE>") -set(CMAKE_C_CREATE_PREPROCESSED_SOURCE "<CMAKE_C_COMPILER> --preproc_only --c_file=<SOURCE> <DEFINES> <INCLUDES> <FLAGS> --output_file=<PREPROCESSED_SOURCE>") - -set(CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> --compile_only --c_file=<SOURCE> <DEFINES> <INCLUDES> <FLAGS> --output_file=<OBJECT>") -set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> qr <TARGET> <OBJECTS>") -set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> qa <TARGET> <OBJECTS>") -set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> --run_linker --output_file=<TARGET> --map_file=<TARGET_NAME>.map <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> <LINK_LIBRARIES>") -set(CMAKE_ASM_RESPONSE_FILE_FLAG "--cmd_file=") -set(CMAKE_C_RESPONSE_FILE_FLAG "--cmd_file=") -set(CMAKE_C_RESPONSE_FILE_LINK_FLAG " ") diff --git a/Modules/Compiler/TI-CXX.cmake b/Modules/Compiler/TI-CXX.cmake index 7836543..c08d9a1 100644 --- a/Modules/Compiler/TI-CXX.cmake +++ b/Modules/Compiler/TI-CXX.cmake @@ -1,15 +1,2 @@ -set(CMAKE_LIBRARY_PATH_FLAG "--search_path=") -set(CMAKE_LINK_LIBRARY_FLAG "--library=") -set(CMAKE_INCLUDE_FLAG_CXX "--include_path=") - -set(CMAKE_DEPFILE_FLAGS_CXX "--preproc_with_compile --preproc_dependency=<DEPFILE>") - -set(CMAKE_CXX_CREATE_ASSEMBLY_SOURCE "<CMAKE_CXX_COMPILER> --compile_only --skip_assembler --cpp_file=<SOURCE> <DEFINES> <INCLUDES> <FLAGS> --output_file=<ASSEMBLY_SOURCE>") -set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE "<CMAKE_CXX_COMPILER> --preproc_only --cpp_file=<SOURCE> <DEFINES> <INCLUDES> <FLAGS> --output_file=<PREPROCESSED_SOURCE>") - -set(CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> --compile_only --cpp_file=<SOURCE> <DEFINES> <INCLUDES> <FLAGS> --output_file=<OBJECT>") -set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> qr <TARGET> <OBJECTS>") -set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> qa <TARGET> <OBJECTS>") -set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> --run_linker --output_file=<TARGET> --map_file=<TARGET_NAME>.map <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> <LINK_LIBRARIES>") -set(CMAKE_CXX_RESPONSE_FILE_FLAG "--cmd_file=") -set(CMAKE_CXX_RESPONSE_FILE_LINK_FLAG " ") +include(Compiler/TI) +__compiler_ti(CXX) diff --git a/Modules/Compiler/TI.cmake b/Modules/Compiler/TI.cmake new file mode 100644 index 0000000..9f2e813 --- /dev/null +++ b/Modules/Compiler/TI.cmake @@ -0,0 +1,40 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + + +# This module is shared by multiple languages; use include blocker. +if(__COMPILER_TI) + return() +endif() +set(__COMPILER_TI 1) + +macro(__compiler_ti lang) + string(TOLOWER ${lang} prefix) + if("x${lang}" STREQUAL "xCXX") + set(prefix "cpp") + endif() + + set(CMAKE_${lang}_RESPONSE_FILE_FLAG "--cmd_file=") + + set(CMAKE_INCLUDE_FLAG_${lang} "--include_path=") + set(CMAKE_DEPFILE_FLAGS_${lang} "--preproc_with_compile --preproc_dependency=<DEPFILE>") + + set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> --preproc_only --${prefix}_file=<SOURCE> <DEFINES> <INCLUDES> <FLAGS> --output_file=<PREPROCESSED_SOURCE>") + set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> --compile_only --skip_assembler --${prefix}_file=<SOURCE> <DEFINES> <INCLUDES> <FLAGS> --output_file=<ASSEMBLY_SOURCE>") + + set(CMAKE_${lang}_COMPILE_OBJECT "<CMAKE_${lang}_COMPILER> --compile_only --${prefix}_file=<SOURCE> <DEFINES> <INCLUDES> <FLAGS> --output_file=<OBJECT>") + + set(CMAKE_${lang}_ARCHIVE_CREATE "<CMAKE_AR> qr <TARGET> <OBJECTS>") + set(CMAKE_${lang}_ARCHIVE_APPEND "<CMAKE_AR> qa <TARGET> <OBJECTS>") + set(CMAKE_${lang}_ARCHIVE_FINISH "") + + # After the --run_linker flag a response file is not possible + set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "") + set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_LIBRARIES 0) + set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS 0) + + set(CMAKE_${lang}_LINK_EXECUTABLE "<CMAKE_${lang}_COMPILER> <FLAGS> --run_linker --output_file=<TARGET> --map_file=<TARGET_NAME>.map <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> <LINK_LIBRARIES>") +endmacro() + +set(CMAKE_LIBRARY_PATH_FLAG "--search_path=") +set(CMAKE_LINK_LIBRARY_FLAG "--library=") diff --git a/Modules/Compiler/XL-C.cmake b/Modules/Compiler/XL-C.cmake index 2077bda..78c44d5 100644 --- a/Modules/Compiler/XL-C.cmake +++ b/Modules/Compiler/XL-C.cmake @@ -6,6 +6,8 @@ string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " -DNDEBUG") # -qthreaded = Ensures that all optimizations will be thread-safe string(APPEND CMAKE_C_FLAGS_INIT " -qthreaded") +set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -qsourcetype=c) + if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.1) set(CMAKE_C90_STANDARD_COMPILE_OPTION "-qlanglvl=stdc89") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-qlanglvl=extc89") diff --git a/Modules/Compiler/XL-CXX.cmake b/Modules/Compiler/XL-CXX.cmake index 41e3e11..3b911f3 100644 --- a/Modules/Compiler/XL-CXX.cmake +++ b/Modules/Compiler/XL-CXX.cmake @@ -6,6 +6,8 @@ string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL_INIT " -DNDEBUG") # -qthreaded = Ensures that all optimizations will be thread-safe string(APPEND CMAKE_CXX_FLAGS_INIT " -qthreaded") +set(CMAKE_CXX_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -+) + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10.1) if(CMAKE_SYSTEM MATCHES "Linux") set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "") @@ -32,6 +34,3 @@ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10.1) endif () __compiler_check_default_language_standard(CXX 10.1 98) - -set(CMAKE_CXX_COMPILE_OBJECT - "<CMAKE_CXX_COMPILER> -+ <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>") diff --git a/Modules/Compiler/XLClang-C.cmake b/Modules/Compiler/XLClang-C.cmake index 54c18a6..1668a4d 100644 --- a/Modules/Compiler/XLClang-C.cmake +++ b/Modules/Compiler/XLClang-C.cmake @@ -1,6 +1,8 @@ include(Compiler/XLClang) __compiler_xlclang(C) +set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c) + if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.1) set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c89") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu89") diff --git a/Modules/Compiler/XLClang-CXX.cmake b/Modules/Compiler/XLClang-CXX.cmake index 9ea3d7c..02638c7 100644 --- a/Modules/Compiler/XLClang-CXX.cmake +++ b/Modules/Compiler/XLClang-CXX.cmake @@ -1,6 +1,8 @@ include(Compiler/XLClang) __compiler_xlclang(CXX) +set(CMAKE_CXX_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c++) + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.1) set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "") set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "") diff --git a/Modules/CompilerId/VS-10.vcxproj.in b/Modules/CompilerId/VS-10.vcxproj.in index b48a332..3598fc7 100644 --- a/Modules/CompilerId/VS-10.vcxproj.in +++ b/Modules/CompilerId/VS-10.vcxproj.in @@ -9,7 +9,7 @@ <PropertyGroup Label="Globals"> <ProjectGuid>{CAE07175-D007-4FC3-BFE8-47B392814159}</ProjectGuid> <RootNamespace>CompilerId@id_lang@</RootNamespace> - <Keyword>Win32Proj</Keyword> + <Keyword>@id_keyword@</Keyword> @id_system@ @id_system_version@ @id_WindowsTargetPlatformVersion@ @@ -24,7 +24,7 @@ @id_PreferredToolArchitecture@ </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@id_platform@'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> + <ConfigurationType>@id_config_type@</ConfigurationType> @id_toolset@ <CharacterSet>MultiByte</CharacterSet> </PropertyGroup> diff --git a/Modules/ExternalProject-download.cmake.in b/Modules/ExternalProject-download.cmake.in index 99fb917..ff8c659 100644 --- a/Modules/ExternalProject-download.cmake.in +++ b/Modules/ExternalProject-download.cmake.in @@ -105,54 +105,65 @@ set(retry_number 5) message(STATUS "Downloading... dst='@LOCAL@' - timeout='@TIMEOUT_MSG@'" + timeout='@TIMEOUT_MSG@' + inactivity timeout='@INACTIVITY_TIMEOUT_MSG@'" ) - +set(download_retry_codes 7 6 8 15) +set(skip_url_list) +set(status_code) foreach(i RANGE ${retry_number}) - sleep_before_download(${i}) - + if(status_code IN_LIST download_retry_codes) + sleep_before_download(${i}) + endif() foreach(url @REMOTE@) - message(STATUS "Using src='${url}'") + if(NOT url IN_LIST skip_url_list) + message(STATUS "Using src='${url}'") - @TLS_VERIFY_CODE@ - @TLS_CAINFO_CODE@ - @NETRC_CODE@ - @NETRC_FILE_CODE@ + @TLS_VERIFY_CODE@ + @TLS_CAINFO_CODE@ + @NETRC_CODE@ + @NETRC_FILE_CODE@ - file( + file( DOWNLOAD "${url}" "@LOCAL@" @SHOW_PROGRESS@ @TIMEOUT_ARGS@ + @INACTIVITY_TIMEOUT_ARGS@ STATUS status LOG log @USERPWD_ARGS@ @HTTP_HEADERS_ARGS@ - ) - - list(GET status 0 status_code) - list(GET status 1 status_string) - - if(status_code EQUAL 0) - check_file_hash(has_hash hash_is_good) - if(has_hash AND NOT hash_is_good) - message(STATUS "Hash mismatch, removing...") - file(REMOVE "@LOCAL@") + ) + + list(GET status 0 status_code) + list(GET status 1 status_string) + + if(status_code EQUAL 0) + check_file_hash(has_hash hash_is_good) + if(has_hash AND NOT hash_is_good) + message(STATUS "Hash mismatch, removing...") + file(REMOVE "@LOCAL@") + else() + message(STATUS "Downloading... done") + return() + endif() else() - message(STATUS "Downloading... done") - return() + string(APPEND logFailedURLs "error: downloading '${url}' failed + status_code: ${status_code} + status_string: ${status_string} + log: + --- LOG BEGIN --- + ${log} + --- LOG END --- + " + ) + if(NOT status_code IN_LIST download_retry_codes) + list(APPEND skip_url_list "${url}") + break() endif() - else() - string(APPEND logFailedURLs "error: downloading '${url}' failed - status_code: ${status_code} - status_string: ${status_string} - log: - --- LOG BEGIN --- - ${log} - --- LOG END --- - " - ) endif() + endif() endforeach() endforeach() diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index fcff5dd..96edbef 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -179,6 +179,9 @@ External Project Definition ``TIMEOUT <seconds>`` Maximum time allowed for file download operations. + ``INACTIVITY_TIMEOUT <seconds>`` + Terminate the operation after a period of inactivity. + ``HTTP_USERNAME <username>`` Username for the download operation if authentication is required. @@ -1300,7 +1303,7 @@ function(_ep_write_gitupdate_script script_filename git_EXECUTABLE git_tag git_r ) endfunction() -function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout no_progress hash tls_verify tls_cainfo userpwd http_headers netrc netrc_file) +function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout inactivity_timeout no_progress hash tls_verify tls_cainfo userpwd http_headers netrc netrc_file) if(timeout) set(TIMEOUT_ARGS TIMEOUT ${timeout}) set(TIMEOUT_MSG "${timeout} seconds") @@ -1308,6 +1311,14 @@ function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout no_p set(TIMEOUT_ARGS "# no TIMEOUT") set(TIMEOUT_MSG "none") endif() + if(inactivity_timeout) + set(INACTIVITY_TIMEOUT_ARGS INACTIVITY_TIMEOUT ${inactivity_timeout}) + set(INACTIVITY_TIMEOUT_MSG "${inactivity_timeout} seconds") + else() + set(INACTIVITY_TIMEOUT_ARGS "# no INACTIVITY_TIMEOUT") + set(INACTIVITY_TIMEOUT_MSG "none") + endif() + if(no_progress) set(SHOW_PROGRESS "") @@ -2512,6 +2523,7 @@ function(_ep_add_download_command name) string(REPLACE ";" "-" fname "${fname}") set(file ${download_dir}/${fname}) get_property(timeout TARGET ${name} PROPERTY _EP_TIMEOUT) + get_property(inactivity_timeout TARGET ${name} PROPERTY _EP_INACTIVITY_TIMEOUT) get_property(no_progress TARGET ${name} PROPERTY _EP_DOWNLOAD_NO_PROGRESS) get_property(tls_verify TARGET ${name} PROPERTY _EP_TLS_VERIFY) get_property(tls_cainfo TARGET ${name} PROPERTY _EP_TLS_CAINFO) @@ -2521,7 +2533,7 @@ function(_ep_add_download_command name) get_property(http_password TARGET ${name} PROPERTY _EP_HTTP_PASSWORD) get_property(http_headers TARGET ${name} PROPERTY _EP_HTTP_HEADER) set(download_script "${stamp_dir}/download-${name}.cmake") - _ep_write_downloadfile_script("${download_script}" "${url}" "${file}" "${timeout}" "${no_progress}" "${hash}" "${tls_verify}" "${tls_cainfo}" "${http_username}:${http_password}" "${http_headers}" "${netrc}" "${netrc_file}") + _ep_write_downloadfile_script("${download_script}" "${url}" "${file}" "${timeout}" "${inactivity_timeout}" "${no_progress}" "${hash}" "${tls_verify}" "${tls_cainfo}" "${http_username}:${http_password}" "${http_headers}" "${netrc}" "${netrc_file}") set(cmd ${CMAKE_COMMAND} -P "${download_script}" COMMAND) if (no_extract) diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake index e05ca96..c85e2d8 100644 --- a/Modules/FetchContent.cmake +++ b/Modules/FetchContent.cmake @@ -5,6 +5,8 @@ FetchContent ------------------ +.. versionadded:: 3.11 + .. only:: html .. contents:: diff --git a/Modules/FindArmadillo.cmake b/Modules/FindArmadillo.cmake index 243b9e0..c8a31a0 100644 --- a/Modules/FindArmadillo.cmake +++ b/Modules/FindArmadillo.cmake @@ -84,6 +84,7 @@ if(_ARMA_USE_WRAPPER) # Link to the armadillo wrapper library. find_library(ARMADILLO_LIBRARY NAMES armadillo + NAMES_PER_DIR PATHS "$ENV{ProgramFiles}/Armadillo/lib" "$ENV{ProgramFiles}/Armadillo/lib64" diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index 60f178b..88a252d 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -36,7 +36,7 @@ The following variables may be set to influence this module's behavior: * ``SCSL`` * ``SGIMATH`` * ``IBMESSL`` - * ``Intel10_32`` (intel mkl v10 32 bit) + * ``Intel10_32`` (intel mkl v10 32 bit, threaded code) * ``Intel10_64lp`` (intel mkl v10+ 64 bit, threaded code, lp64 model) * ``Intel10_64lp_seq`` (intel mkl v10+ 64 bit, sequential code, lp64 model) * ``Intel10_64ilp`` (intel mkl v10+ 64 bit, threaded code, ilp64 model) @@ -208,6 +208,7 @@ macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _add if(_libraries_work) find_library(${_prefix}_${_library}_LIBRARY NAMES ${_library} + NAMES_PER_DIR PATHS ${_extaddlibdir} PATH_SUFFIXES ${_subdirs} ) @@ -397,6 +398,10 @@ if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") # Add threading/sequential libs set(BLAS_SEARCH_LIBS_WIN_THREAD "") + if(BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD + "libiomp5md mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") + endif() if(BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR STREQUAL "All") # old version list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD @@ -441,7 +446,7 @@ if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") "${BLAS_mkl_START_GROUP} mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_sequential mkl_core ${BLAS_mkl_END_GROUP}") endif() - #older vesions of intel mkl libs + #older versions of intel mkl libs if(BLA_VENDOR STREQUAL "Intel" OR BLA_VENDOR STREQUAL "All") list(APPEND BLAS_SEARCH_LIBS "mkl") @@ -483,7 +488,9 @@ if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") endif() set(BLAS_mkl_LIB_PATH_SUFFIXES "compiler/lib" "compiler/lib/${BLAS_mkl_ARCH_NAME}_${BLAS_mkl_OS_NAME}" + "compiler/lib/${BLAS_mkl_ARCH_NAME}" "mkl/lib" "mkl/lib/${BLAS_mkl_ARCH_NAME}_${BLAS_mkl_OS_NAME}" + "mkl/lib/${BLAS_mkl_ARCH_NAME}" "lib/${BLAS_mkl_ARCH_NAME}_${BLAS_mkl_OS_NAME}") foreach(IT ${BLAS_SEARCH_LIBS}) diff --git a/Modules/FindBZip2.cmake b/Modules/FindBZip2.cmake index 98ab72c..5704d1d 100644 --- a/Modules/FindBZip2.cmake +++ b/Modules/FindBZip2.cmake @@ -45,8 +45,8 @@ set(_BZIP2_PATHS PATHS find_path(BZIP2_INCLUDE_DIR bzlib.h ${_BZIP2_PATHS} PATH_SUFFIXES include) if (NOT BZIP2_LIBRARIES) - find_library(BZIP2_LIBRARY_RELEASE NAMES bz2 bzip2 libbz2 libbzip2 ${_BZIP2_PATHS} PATH_SUFFIXES lib) - find_library(BZIP2_LIBRARY_DEBUG NAMES bz2d bzip2d libbz2d libbzip2d ${_BZIP2_PATHS} PATH_SUFFIXES lib) + find_library(BZIP2_LIBRARY_RELEASE NAMES bz2 bzip2 libbz2 libbzip2 NAMES_PER_DIR ${_BZIP2_PATHS} PATH_SUFFIXES lib) + find_library(BZIP2_LIBRARY_DEBUG NAMES bz2d bzip2d libbz2d libbzip2d NAMES_PER_DIR ${_BZIP2_PATHS} PATH_SUFFIXES lib) include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) SELECT_LIBRARY_CONFIGURATIONS(BZIP2) diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 13981d3..ec087ad 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -305,7 +305,7 @@ function(_boost_get_canonical_target_name component target_var) endfunction() macro(_boost_set_in_parent_scope name value) - # Set a variable in parent scope and make it visibile in current scope + # Set a variable in parent scope and make it visible in current scope set(${name} "${value}" PARENT_SCOPE) set(${name} "${value}") endmacro() @@ -1270,10 +1270,8 @@ function(_Boost_COMPONENT_HEADERS component _hdrs) set(_Boost_UNIT_TEST_FRAMEWORK_HEADERS "boost/test/framework.hpp") set(_Boost_WAVE_HEADERS "boost/wave.hpp") set(_Boost_WSERIALIZATION_HEADERS "boost/archive/text_wiarchive.hpp") - if(WIN32) - set(_Boost_BZIP2_HEADERS "boost/iostreams/filter/bzip2.hpp") - set(_Boost_ZLIB_HEADERS "boost/iostreams/filter/zlib.hpp") - endif() + set(_Boost_BZIP2_HEADERS "boost/iostreams/filter/bzip2.hpp") + set(_Boost_ZLIB_HEADERS "boost/iostreams/filter/zlib.hpp") string(TOUPPER ${component} uppercomponent) set(${_hdrs} ${_Boost_${uppercomponent}_HEADERS} PARENT_SCOPE) diff --git a/Modules/FindCUDA/run_nvcc.cmake b/Modules/FindCUDA/run_nvcc.cmake index ba35433..17e12f8 100644 --- a/Modules/FindCUDA/run_nvcc.cmake +++ b/Modules/FindCUDA/run_nvcc.cmake @@ -155,7 +155,7 @@ macro(cuda_execute_process status command) # copy and paste a runnable command line. set(cuda_execute_process_string) foreach(arg ${ARGN}) - # If there are quotes, excape them, so they come through. + # If there are quotes, escape them, so they come through. string(REPLACE "\"" "\\\"" arg ${arg}) # Args with spaces need quotes around them to get them to be parsed as a single argument. if(arg MATCHES " ") diff --git a/Modules/FindCUDAToolkit.cmake b/Modules/FindCUDAToolkit.cmake index 47bc546..1054f60 100644 --- a/Modules/FindCUDAToolkit.cmake +++ b/Modules/FindCUDAToolkit.cmake @@ -5,6 +5,8 @@ FindCUDAToolkit --------------- +.. versionadded:: 3.17 + This script locates the NVIDIA CUDA toolkit and the associated libraries, but does not require the ``CUDA`` language be enabled for a given project. This module does not search for the NVIDIA CUDA Samples. @@ -12,8 +14,7 @@ module does not search for the NVIDIA CUDA Samples. Search Behavior ^^^^^^^^^^^^^^^ -Finding the CUDA Toolkit requires finding the ``nvcc`` executable, which is -searched for in the following order: +The CUDA Toolkit search behavior uses the following order: 1. If the ``CUDA`` language has been enabled we will use the directory containing the compiler as the first search location for ``nvcc``. @@ -24,13 +25,12 @@ searched for in the following order: configuration variable are specified, the *configuration* variable takes precedence. - The directory specified here must be such that the executable ``nvcc`` can be - found underneath the directory specified by ``CUDAToolkit_ROOT``. If - ``CUDAToolkit_ROOT`` is specified, but no ``nvcc`` is found underneath, this - package is marked as **not** found. No subsequent search attempts are - performed. + The directory specified here must be such that the executable ``nvcc`` or + the appropriate ``version.txt`` file can be found underneath the specified + directory. -3. If the CUDA_PATH environment variable is defined, it will be searched. +3. If the CUDA_PATH environment variable is defined, it will be searched + for ``nvcc``. 4. The user's path is searched for ``nvcc`` using :command:`find_program`. If this is found, no subsequent search attempts are performed. Users are @@ -402,7 +402,7 @@ Result variables ``CUDAToolkit_VERSION`` The exact version of the CUDA Toolkit found (as reported by - ``nvcc --version``). + ``nvcc --version`` or ``version.txt``). ``CUDAToolkit_VERSION_MAJOR`` The major version of the CUDA Toolkit. @@ -431,8 +431,8 @@ Result variables ``CUDAToolkit_TARGET_DIR`` The path to the CUDA Toolkit directory including the target architecture - when cross-compiling. When not cross-compiling this will be equivalant to - ``CUDAToolkit_ROOT_DIR``. + when cross-compiling. When not cross-compiling this will be equivalent to + the parent directory of ``CUDAToolkit_BIN_DIR``. ``CUDAToolkit_NVCC_EXECUTABLE`` The path to the NVIDIA CUDA compiler ``nvcc``. Note that this path may @@ -491,31 +491,81 @@ if(CMAKE_CUDA_COMPILER_TOOLKIT_ROOT) set(CUDAToolkit_BIN_DIR "${CUDAToolkit_ROOT_DIR}/bin") set(CUDAToolkit_NVCC_EXECUTABLE "${CUDAToolkit_BIN_DIR}/nvcc${CMAKE_EXECUTABLE_SUFFIX}") else() + + function(_CUDAToolkit_find_root_dir ) + cmake_parse_arguments(arg "" "" "SEARCH_PATHS;FIND_FLAGS" ${ARGN}) + + + if(NOT CUDAToolkit_BIN_DIR) + if(NOT CUDAToolkit_SENTINEL_FILE) + find_program(CUDAToolkit_NVCC_EXECUTABLE + NAMES nvcc nvcc.exe + PATHS ${arg_SEARCH_PATHS} + ${arg_FIND_FLAGS} + ) + endif() + + if(NOT CUDAToolkit_NVCC_EXECUTABLE) + find_file(CUDAToolkit_SENTINEL_FILE + NAMES version.txt + PATHS ${arg_SEARCH_PATHS} + NO_DEFAULT_PATH + ) + endif() + + if(CUDAToolkit_NVCC_EXECUTABLE) + get_filename_component(CUDAToolkit_BIN_DIR "${CUDAToolkit_NVCC_EXECUTABLE}" DIRECTORY) + + set(CUDAToolkit_BIN_DIR "${CUDAToolkit_BIN_DIR}" CACHE PATH "" FORCE) + mark_as_advanced(CUDAToolkit_BIN_DIR) + elseif(CUDAToolkit_SENTINEL_FILE) + get_filename_component(CUDAToolkit_BIN_DIR ${CUDAToolkit_SENTINEL_FILE} DIRECTORY ABSOLUTE) + set(CUDAToolkit_BIN_DIR "${CUDAToolkit_BIN_DIR}/bin") + + set(CUDAToolkit_BIN_DIR "${CUDAToolkit_BIN_DIR}" CACHE PATH "" FORCE) + mark_as_advanced(CUDAToolkit_BIN_DIR) + endif() + endif() + + if(CUDAToolkit_BIN_DIR) + get_filename_component(CUDAToolkit_ROOT_DIR ${CUDAToolkit_BIN_DIR} DIRECTORY ABSOLUTE) + set(CUDAToolkit_ROOT_DIR "${CUDAToolkit_ROOT_DIR}" PARENT_SCOPE) + endif() + + endfunction() + + function(_CUDAToolkit_find_version_file result_variable) + # We first check for a non-scattered installation to prefer it over a scattered installation. + if(CUDAToolkit_ROOT AND EXISTS "${CUDAToolkit_ROOT}/version.txt") + set(${result_variable} "${CUDAToolkit_ROOT}/version.txt" PARENT_SCOPE) + elseif(CUDAToolkit_ROOT_DIR AND EXISTS "${CUDAToolkit_ROOT_DIR}/version.txt") + set(${result_variable} "${CUDAToolkit_ROOT_DIR}/version.txt" PARENT_SCOPE) + elseif(CMAKE_SYSROOT_LINK AND EXISTS "${CMAKE_SYSROOT_LINK}/usr/lib/cuda/version.txt") + set(${result_variable} "${CMAKE_SYSROOT_LINK}/usr/lib/cuda/version.txt" PARENT_SCOPE) + elseif(EXISTS "${CMAKE_SYSROOT}/usr/lib/cuda/version.txt") + set(${result_variable} "${CMAKE_SYSROOT}/usr/lib/cuda/version.txt" PARENT_SCOPE) + endif() + endfunction() + # For NVCC we can easily deduce the SDK binary directory from the compiler path. if(CMAKE_CUDA_COMPILER_LOADED AND NOT CUDAToolkit_BIN_DIR AND CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA") get_filename_component(CUDAToolkit_BIN_DIR "${CMAKE_CUDA_COMPILER}" DIRECTORY) set(CUDAToolkit_BIN_DIR "${CUDAToolkit_BIN_DIR}" CACHE PATH "") + # Try language provided path first. + _CUDAToolkit_find_root_dir(SEARCH_PATHS "${CUDAToolkit_BIN_DIR}" FIND_FLAGS NO_DEFAULT_PATH) mark_as_advanced(CUDAToolkit_BIN_DIR) endif() - # Try language- or user-provided path first. - if(CUDAToolkit_BIN_DIR) - find_program(CUDAToolkit_NVCC_EXECUTABLE - NAMES nvcc nvcc.exe - PATHS ${CUDAToolkit_BIN_DIR} - NO_DEFAULT_PATH - ) + # Try user provided path + if(NOT CUDAToolkit_ROOT_DIR AND CUDAToolkit_ROOT) + _CUDAToolkit_find_root_dir(SEARCH_PATHS "${CUDAToolkit_ROOT}" FIND_FLAGS PATH_SUFFIXES bin NO_DEFAULT_PATH) + endif() + if(NOT CUDAToolkit_ROOT_DIR) + _CUDAToolkit_find_root_dir(FIND_FLAGS PATHS "ENV CUDA_PATH" PATH_SUFFIXES bin) endif() - # Search using CUDAToolkit_ROOT - find_program(CUDAToolkit_NVCC_EXECUTABLE - NAMES nvcc nvcc.exe - PATHS ENV CUDA_PATH - PATH_SUFFIXES bin - ) - - # If the user specified CUDAToolkit_ROOT but nvcc could not be found, this is an error. - if(NOT CUDAToolkit_NVCC_EXECUTABLE AND (DEFINED CUDAToolkit_ROOT OR DEFINED ENV{CUDAToolkit_ROOT})) + # If the user specified CUDAToolkit_ROOT but the toolkit could not be found, this is an error. + if(NOT CUDAToolkit_ROOT_DIR AND (DEFINED CUDAToolkit_ROOT OR DEFINED ENV{CUDAToolkit_ROOT})) # Declare error messages now, print later depending on find_package args. set(fail_base "Could not find nvcc executable in path specified by") set(cuda_root_fail "${fail_base} CUDAToolkit_ROOT=${CUDAToolkit_ROOT}") @@ -552,7 +602,7 @@ else() # We will also search the default symlink location /usr/local/cuda first since # if CUDAToolkit_ROOT is not specified, it is assumed that the symlinked # directory is the desired location. - if(NOT CUDAToolkit_NVCC_EXECUTABLE) + if(NOT CUDAToolkit_ROOT_DIR) if(UNIX) if(NOT APPLE) set(platform_base "/usr/local/cuda-") @@ -589,12 +639,8 @@ else() list(INSERT search_paths 0 "/usr/local/cuda") endif() - # Now search for nvcc again using the platform default search paths. - find_program(CUDAToolkit_NVCC_EXECUTABLE - NAMES nvcc nvcc.exe - PATHS ${search_paths} - PATH_SUFFIXES bin - ) + # Now search for the toolkit again using the platform default search paths. + _CUDAToolkit_find_root_dir(SEARCH_PATHS "${search_paths}" FIND_FLAGS PATH_SUFFIXES bin) # We are done with these variables now, cleanup for caller. unset(platform_base) @@ -602,7 +648,7 @@ else() unset(versions) unset(search_paths) - if(NOT CUDAToolkit_NVCC_EXECUTABLE) + if(NOT CUDAToolkit_ROOT_DIR) if(CUDAToolkit_FIND_REQUIRED) message(FATAL_ERROR "Could not find nvcc, please set CUDAToolkit_ROOT.") elseif(NOT CUDAToolkit_FIND_QUIETLY) @@ -614,24 +660,12 @@ else() endif() endif() - if(NOT CUDAToolkit_BIN_DIR AND CUDAToolkit_NVCC_EXECUTABLE) - get_filename_component(CUDAToolkit_BIN_DIR "${CUDAToolkit_NVCC_EXECUTABLE}" DIRECTORY) - set(CUDAToolkit_BIN_DIR "${CUDAToolkit_BIN_DIR}" CACHE PATH "" FORCE) - mark_as_advanced(CUDAToolkit_BIN_DIR) - endif() - - get_filename_component(CUDAToolkit_ROOT_DIR ${CUDAToolkit_BIN_DIR} DIRECTORY ABSOLUTE) - - # CUDAToolkit_LIBRARY_ROOT contains the device library and version file. - # In a non-scattered installation this is equivalent to CUDAToolkit_ROOT_DIR. - # We first check for a non-scattered installation to prefer it over a scattered installation. - if(EXISTS "${CUDAToolkit_ROOT_DIR}/version.txt") - set(CUDAToolkit_LIBRARY_ROOT "${CUDAToolkit_ROOT_DIR}") - elseif(CMAKE_SYSROOT_LINK AND EXISTS "${CMAKE_SYSROOT_LINK}/usr/lib/cuda/version.txt") - set(CUDAToolkit_LIBRARY_ROOT "${CMAKE_SYSROOT_LINK}/usr/lib/cuda") - elseif(EXISTS "${CMAKE_SYSROOT}/usr/lib/cuda/version.txt") - set(CUDAToolkit_LIBRARY_ROOT "${CMAKE_SYSROOT}/usr/lib/cuda") + _CUDAToolkit_find_version_file( _CUDAToolkit_version_file ) + if(_CUDAToolkit_version_file) + # CUDAToolkit_LIBRARY_ROOT contains the device library and version file. + get_filename_component(CUDAToolkit_LIBRARY_ROOT "${_CUDAToolkit_version_file}" DIRECTORY ABSOLUTE) endif() + unset(_CUDAToolkit_version_file) endif() # Handle cross compilation @@ -693,7 +727,7 @@ if(CUDAToolkit_NVCC_EXECUTABLE AND set(CUDAToolkit_VERSION_PATCH "${CMAKE_MATCH_3}") set(CUDAToolkit_VERSION "${CMAKE_CUDA_COMPILER_VERSION}") endif() -else() +elseif(CUDAToolkit_NVCC_EXECUTABLE) # Compute the version by invoking nvcc execute_process(COMMAND ${CUDAToolkit_NVCC_EXECUTABLE} "--version" OUTPUT_VARIABLE NVCC_OUT) if(NVCC_OUT MATCHES [=[ V([0-9]+)\.([0-9]+)\.([0-9]+)]=]) @@ -703,6 +737,17 @@ else() set(CUDAToolkit_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}") endif() unset(NVCC_OUT) +else() + _CUDAToolkit_find_version_file(version_file) + if(version_file) + file(READ "${version_file}" VERSION_INFO) + if(VERSION_INFO MATCHES [=[CUDA Version ([0-9]+)\.([0-9]+)\.([0-9]+)]=]) + set(CUDAToolkit_VERSION_MAJOR "${CMAKE_MATCH_1}") + set(CUDAToolkit_VERSION_MINOR "${CMAKE_MATCH_2}") + set(CUDAToolkit_VERSION_PATCH "${CMAKE_MATCH_3}") + set(CUDAToolkit_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}") + endif() + endif() endif() # Find the CUDA Runtime Library libcudart @@ -719,7 +764,6 @@ if(NOT CUDA_CUDART AND NOT CUDAToolkit_FIND_QUIETLY) message(STATUS "Unable to find cudart library.") endif() -unset(CUDAToolkit_ROOT_DIR) if(_CUDAToolkit_Pop_Prefix) list(REMOVE_AT CMAKE_PREFIX_PATH -1) unset(_CUDAToolkit_Pop_Prefix) @@ -732,13 +776,16 @@ find_package_handle_standard_args(CUDAToolkit REQUIRED_VARS CUDAToolkit_INCLUDE_DIR CUDA_CUDART - CUDAToolkit_NVCC_EXECUTABLE + CUDAToolkit_BIN_DIR VERSION_VAR CUDAToolkit_VERSION ) + +unset(CUDAToolkit_ROOT_DIR) mark_as_advanced(CUDA_CUDART CUDAToolkit_INCLUDE_DIR CUDAToolkit_NVCC_EXECUTABLE + CUDAToolkit_SENTINEL_FILE ) #----------------------------------------------------------------------------- diff --git a/Modules/FindCURL.cmake b/Modules/FindCURL.cmake index be7e16e..74b36c6 100644 --- a/Modules/FindCURL.cmake +++ b/Modules/FindCURL.cmake @@ -92,6 +92,7 @@ if(NOT CURL_LIBRARY) curllib_static # Windows older "Win32 - MSVC" prebuilts (libcurl.lib, e.g. libcurl-7.15.5-win32-msvc.zip): libcurl + NAMES_PER_DIR HINTS ${PC_CURL_LIBRARY_DIRS} ) mark_as_advanced(CURL_LIBRARY_RELEASE) @@ -100,6 +101,7 @@ if(NOT CURL_LIBRARY) # Windows MSVC CMake builds in debug configuration on vcpkg: libcurl-d_imp libcurl-d + NAMES_PER_DIR HINTS ${PC_CURL_LIBRARY_DIRS} ) mark_as_advanced(CURL_LIBRARY_DEBUG) diff --git a/Modules/FindCurses.cmake b/Modules/FindCurses.cmake index ba56078..cde3a4d 100644 --- a/Modules/FindCurses.cmake +++ b/Modules/FindCurses.cmake @@ -156,7 +156,9 @@ if(CURSES_USE_NCURSES) CHECK_LIBRARY_EXISTS("${CURSES_NCURSES_LIBRARY}" cbreak "" CURSES_NCURSES_HAS_CBREAK) - if(NOT CURSES_NCURSES_HAS_CBREAK) + CHECK_LIBRARY_EXISTS("${CURSES_NCURSES_LIBRARY}" + nodelay "" CURSES_NCURSES_HAS_NODELAY) + if(NOT CURSES_NCURSES_HAS_CBREAK OR NOT CURSES_NCURSES_HAS_NODELAY) find_library(CURSES_EXTRA_LIBRARY "${CURSES_TINFO_LIBRARY_NAME}" HINTS "${_cursesLibDir}") find_library(CURSES_EXTRA_LIBRARY "${CURSES_TINFO_LIBRARY_NAME}" ) diff --git a/Modules/FindEXPAT.cmake b/Modules/FindEXPAT.cmake index 15b419a..b0bb02a 100644 --- a/Modules/FindEXPAT.cmake +++ b/Modules/FindEXPAT.cmake @@ -38,7 +38,7 @@ pkg_check_modules(PC_EXPAT QUIET expat) find_path(EXPAT_INCLUDE_DIR NAMES expat.h HINTS ${PC_EXPAT_INCLUDE_DIRS}) # Look for the library. -find_library(EXPAT_LIBRARY NAMES expat libexpat HINTS ${PC_EXPAT_LIBRARY_DIRS}) +find_library(EXPAT_LIBRARY NAMES expat libexpat NAMES_PER_DIR HINTS ${PC_EXPAT_LIBRARY_DIRS}) if (EXPAT_INCLUDE_DIR AND EXISTS "${EXPAT_INCLUDE_DIR}/expat.h") file(STRINGS "${EXPAT_INCLUDE_DIR}/expat.h" expat_version_str diff --git a/Modules/FindEnvModules.cmake b/Modules/FindEnvModules.cmake index 4dd5116..a4ac0b4 100644 --- a/Modules/FindEnvModules.cmake +++ b/Modules/FindEnvModules.cmake @@ -5,6 +5,8 @@ FindEnvModules -------------- +.. versionadded:: 3.15 + Locate an environment module implementation and make commands available to CMake scripts to use them. This is compatible with both Lua-based Lmod and TCL-based EnvironmentModules. diff --git a/Modules/FindFontconfig.cmake b/Modules/FindFontconfig.cmake index a6f0180..5228831 100644 --- a/Modules/FindFontconfig.cmake +++ b/Modules/FindFontconfig.cmake @@ -5,6 +5,8 @@ FindFontconfig -------------- +.. versionadded:: 3.14 + Find Fontconfig headers and library. Imported Targets diff --git a/Modules/FindGIF.cmake b/Modules/FindGIF.cmake index d5a143e..cea9cd8 100644 --- a/Modules/FindGIF.cmake +++ b/Modules/FindGIF.cmake @@ -60,6 +60,7 @@ set(POTENTIAL_GIF_LIBS gif libgif ungif libungif giflib giflib4) find_library(GIF_LIBRARY NAMES ${POTENTIAL_GIF_LIBS} + NAMES_PER_DIR HINTS ENV GIF_DIR PATH_SUFFIXES lib diff --git a/Modules/FindGLEW.cmake b/Modules/FindGLEW.cmake index 27ffa13..080371a 100644 --- a/Modules/FindGLEW.cmake +++ b/Modules/FindGLEW.cmake @@ -139,11 +139,13 @@ __glew_set_find_library_suffix(SHARED) find_library(GLEW_SHARED_LIBRARY_RELEASE NAMES GLEW glew glew32 + NAMES_PER_DIR PATH_SUFFIXES lib lib64 libx32 lib/Release/${_arch} PATHS ENV GLEW_ROOT) find_library(GLEW_SHARED_LIBRARY_DEBUG NAMES GLEWd glewd glew32d + NAMES_PER_DIR PATH_SUFFIXES lib lib64 PATHS ENV GLEW_ROOT) @@ -152,11 +154,13 @@ __glew_set_find_library_suffix(STATIC) find_library(GLEW_STATIC_LIBRARY_RELEASE NAMES GLEW glew glew32s + NAMES_PER_DIR PATH_SUFFIXES lib lib64 libx32 lib/Release/${_arch} PATHS ENV GLEW_ROOT) find_library(GLEW_STATIC_LIBRARY_DEBUG NAMES GLEWds glewds glew32ds + NAMES_PER_DIR PATH_SUFFIXES lib lib64 PATHS ENV GLEW_ROOT) diff --git a/Modules/FindGSL.cmake b/Modules/FindGSL.cmake index da1b3c4..3d4e7f9 100644 --- a/Modules/FindGSL.cmake +++ b/Modules/FindGSL.cmake @@ -5,6 +5,8 @@ FindGSL -------- +.. versionadded:: 3.2 + Find the native GNU Scientific Library (GSL) includes and libraries. The GNU Scientific Library (GSL) is a numerical library for C and C++ diff --git a/Modules/FindGTest.cmake b/Modules/FindGTest.cmake index 53cab1a..10e31b2 100644 --- a/Modules/FindGTest.cmake +++ b/Modules/FindGTest.cmake @@ -96,6 +96,27 @@ function(__gtest_find_library _name) mark_as_advanced(${_name}) endfunction() +function(__gtest_find_library_configuration _name _lib _cfg_suffix) + set(_libs ${_lib}) + if(MSVC AND GTEST_MSVC_SEARCH STREQUAL "MD") + # The provided /MD project files for Google Test add -md suffixes to the + # library names. + list(INSERT _libs 0 ${_lib}-md) + endif() + list(TRANSFORM _libs APPEND "${_cfg_suffix}") + + __gtest_find_library(${_name} ${_libs}) +endfunction() + +include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) +function(__gtest_find_and_select_library_configurations _basename _lib) + __gtest_find_library_configuration(${_basename}_LIBRARY_RELEASE ${_lib} "") + __gtest_find_library_configuration(${_basename}_LIBRARY_DEBUG ${_lib} "d") + + select_library_configurations(${_basename}) + set(${_basename}_LIBRARY ${${_basename}_LIBRARY} PARENT_SCOPE) +endfunction() + macro(__gtest_determine_windows_library_type _var) if(EXISTS "${${_var}}") file(TO_NATIVE_PATH "${${_var}}" _lib_path) @@ -187,18 +208,13 @@ find_path(GTEST_INCLUDE_DIR gtest/gtest.h ) mark_as_advanced(GTEST_INCLUDE_DIR) -if(MSVC AND GTEST_MSVC_SEARCH STREQUAL "MD") - # The provided /MD project files for Google Test add -md suffixes to the - # library names. - __gtest_find_library(GTEST_LIBRARY gtest-md gtest) - __gtest_find_library(GTEST_LIBRARY_DEBUG gtest-mdd gtestd) - __gtest_find_library(GTEST_MAIN_LIBRARY gtest_main-md gtest_main) - __gtest_find_library(GTEST_MAIN_LIBRARY_DEBUG gtest_main-mdd gtest_maind) -else() - __gtest_find_library(GTEST_LIBRARY gtest) - __gtest_find_library(GTEST_LIBRARY_DEBUG gtestd) - __gtest_find_library(GTEST_MAIN_LIBRARY gtest_main) - __gtest_find_library(GTEST_MAIN_LIBRARY_DEBUG gtest_maind) +# Allow GTEST_LIBRARY and GTEST_MAIN_LIBRARY to be set manually, as the +# locations of the gtest and gtest_main libraries, respectively. +if(NOT GTEST_LIBRARY) + __gtest_find_and_select_library_configurations(GTEST gtest) +endif() +if(NOT GTEST_MAIN_LIBRARY) + __gtest_find_and_select_library_configurations(GTEST_MAIN gtest_main) endif() include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index c9d1598..0a92c71 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -110,6 +110,18 @@ also be defined. With all components enabled, the following variables will be d ``HDF5_DIFF_EXECUTABLE`` path to the HDF5 dataset comparison tool +With all components enabled, the following targets will be defined: + +:: + + ``hdf5::hdf5`` + ``hdf5::hdf5_hl_cpp`` + ``hdf5::hdf5_fortran`` + ``hdf5::hdf5_hl`` + ``hdf5::hdf5_hl_cpp`` + ``hdf5::hdf5_hl_fortran`` + ``hdf5::h5diff`` + Hints ^^^^^ @@ -125,11 +137,14 @@ The following variables can be set to guide the search for HDF5 libraries and in Set ``true`` to skip trying to find ``hdf5-config.cmake``. #]=======================================================================] -# This module is maintained by Will Dicharry <wdicharry@stellarscience.com>. - include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +# We haven't found HDF5 yet. Clear its state in case it is set in the parent +# scope somewhere else. We can't rely on it because different components may +# have been requested for this call. +set(HDF5_FOUND OFF) + # List of the valid HDF5 components set(HDF5_VALID_LANGUAGE_BINDINGS C CXX Fortran) @@ -197,9 +212,7 @@ macro(_HDF5_remove_duplicates_from_beginning _list_name) endif() endmacro() - # Test first if the current compilers automatically wrap HDF5 - function(_HDF5_test_regular_compiler_C success version is_parallel) set(scratch_directory ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hdf5) @@ -346,6 +359,7 @@ function( _HDF5_invoke_compiler language output_var return_value_var version_var # wrapper exists, but not the compiler. E.g. Miniconda / Anaconda Python execute_process( COMMAND ${HDF5_${language}_COMPILER_EXECUTABLE} ${test_file} + WORKING_DIRECTORY ${scratch_dir} RESULT_VARIABLE return_value ) if(return_value) @@ -354,6 +368,7 @@ function( _HDF5_invoke_compiler language output_var return_value_var version_var else() execute_process( COMMAND ${HDF5_${language}_COMPILER_EXECUTABLE} -show ${lib_type_args} ${test_file} + WORKING_DIRECTORY ${scratch_dir} OUTPUT_VARIABLE output ERROR_VARIABLE output RESULT_VARIABLE return_value @@ -971,6 +986,138 @@ if( HDF5_FOUND AND NOT HDF5_DIR) mark_as_advanced(HDF5_DIR) endif() +if (HDF5_FOUND) + if (NOT TARGET HDF5::HDF5) + add_library(HDF5::HDF5 INTERFACE IMPORTED) + string(REPLACE "-D" "" _hdf5_definitions "${HDF5_DEFINITIONS}") + set_target_properties(HDF5::HDF5 PROPERTIES + INTERFACE_LINK_LIBRARIES "${HDF5_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${HDF5_INCLUDE_DIRS}" + INTERFACE_COMPILE_DEFINITIONS "${_hdf5_definitions}") + unset(_hdf5_definitions) + endif () + + foreach (hdf5_lang IN LISTS HDF5_LANGUAGE_BINDINGS) + if (hdf5_lang STREQUAL "C") + set(hdf5_target_name "hdf5") + elseif (hdf5_lang STREQUAL "CXX") + set(hdf5_target_name "hdf5_cpp") + elseif (hdf5_lang STREQUAL "Fortran") + set(hdf5_target_name "hdf5_fortran") + else () + continue () + endif () + + if (NOT TARGET "hdf5::${hdf5_target_name}") + if (HDF5_COMPILER_NO_INTERROGATE) + add_library("hdf5::${hdf5_target_name}" INTERFACE IMPORTED) + string(REPLACE "-D" "" _hdf5_definitions "${HDF5_${hdf5_lang}_DEFINITIONS}") + set_target_properties("hdf5::${hdf5_target_name}" PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${HDF5_${hdf5_lang}_INCLUDE_DIRS}" + INTERFACE_COMPILE_DEFINITIONS "${_hdf5_definitions}") + else() + if (DEFINED "HDF5_${hdf5_target_name}_LIBRARY") + set(_hdf5_location "${HDF5_${hdf5_target_name}_LIBRARY}") + elseif (DEFINED "HDF5_${hdf5_lang}_LIBRARY") + set(_hdf5_location "${HDF5_${hdf5_lang}_LIBRARY}") + elseif (DEFINED "HDF5_${hdf5_lang}_LIBRARY_${hdf5_target_name}") + set(_hdf5_location "${HDF5_${hdf5_lang}_LIBRARY_${hdf5_target_name}}") + else () + # Error if we still don't have the location. + message(SEND_ERROR + "HDF5 was found, but a different variable was set which contains " + "its location.") + endif () + add_library("hdf5::${hdf5_target_name}" UNKNOWN IMPORTED) + string(REPLACE "-D" "" _hdf5_definitions "${HDF5_${hdf5_lang}_DEFINITIONS}") + if (NOT HDF5_${hdf5_lang}_INCLUDE_DIRS) + set(HDF5_${hdf5_lang}_INCLUDE_DIRS ${HDF5_INCLUDE_DIRS}) + endif () + set_target_properties("hdf5::${hdf5_target_name}" PROPERTIES + IMPORTED_LOCATION "${_hdf5_location}" + IMPORTED_IMPLIB "${_hdf5_location}" + INTERFACE_INCLUDE_DIRECTORIES "${HDF5_${hdf5_lang}_INCLUDE_DIRS}" + INTERFACE_COMPILE_DEFINITIONS "${_hdf5_definitions}") + if (_hdf5_libtype STREQUAL "SHARED") + set_property(TARGET "hdf5::${hdf5_target_name}" APPEND + PROPERTY + INTERFACE_COMPILE_DEFINITIONS H5_BUILT_AS_DYNAMIC_LIB) + elseif (_hdf5_libtype STREQUAL "STATIC") + set_property(TARGET "hdf5::${hdf5_target_name}" APPEND + PROPERTY + INTERFACE_COMPILE_DEFINITIONS H5_BUILT_AS_STATIC_LIB) + endif () + unset(_hdf5_definitions) + unset(_hdf5_libtype) + unset(_hdf5_location) + endif () + endif () + + if (NOT HDF5_FIND_HL) + continue () + endif () + + if (hdf5_lang STREQUAL "C") + set(hdf5_target_name "hdf5_hl") + elseif (hdf5_lang STREQUAL "CXX") + set(hdf5_target_name "hdf5_hl_cpp") + elseif (hdf5_lang STREQUAL "Fortran") + set(hdf5_target_name "hdf5_hl_fortran") + else () + continue () + endif () + + if (NOT TARGET "hdf5::${hdf5_target_name}") + if (HDF5_COMPILER_NO_INTERROGATE) + add_library("hdf5::${hdf5_target_name}" INTERFACE IMPORTED) + string(REPLACE "-D" "" _hdf5_definitions "${HDF5_${hdf5_lang}_HL_DEFINITIONS}") + set_target_properties("hdf5::${hdf5_target_name}" PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${HDF5_${hdf5_lang}_HL_INCLUDE_DIRS}" + INTERFACE_COMPILE_DEFINITIONS "${_hdf5_definitions}") + else() + if (DEFINED "HDF5_${hdf5_target_name}_LIBRARY") + set(_hdf5_location "${HDF5_${hdf5_target_name}_LIBRARY}") + elseif (DEFINED "HDF5_${hdf5_lang}_HL_LIBRARY") + set(_hdf5_location "${HDF5_${hdf5_lang}_HL_LIBRARY}") + elseif (DEFINED "HDF5_${hdf5_lang}_LIBRARY_${hdf5_target_name}") + set(_hdf5_location "${HDF5_${hdf5_lang}_LIBRARY_${hdf5_target_name}}") + else () + # Error if we still don't have the location. + message(SEND_ERROR + "HDF5 was found, but a different variable was set which contains " + "its location.") + endif () + add_library("hdf5::${hdf5_target_name}" UNKNOWN IMPORTED) + string(REPLACE "-D" "" _hdf5_definitions "${HDF5_${hdf5_lang}_HL_DEFINITIONS}") + set_target_properties("hdf5::${hdf5_target_name}" PROPERTIES + IMPORTED_LOCATION "${_hdf5_location}" + IMPORTED_IMPLIB "${_hdf5_location}" + INTERFACE_INCLUDE_DIRECTORIES "${HDF5_${hdf5_lang}_HL_INCLUDE_DIRS}" + INTERFACE_COMPILE_DEFINITIONS "${_hdf5_definitions}") + if (_hdf5_libtype STREQUAL "SHARED") + set_property(TARGET "hdf5::${hdf5_target_name}" APPEND + PROPERTY + INTERFACE_COMPILE_DEFINITIONS H5_BUILT_AS_DYNAMIC_LIB) + elseif (_hdf5_libtype STREQUAL "STATIC") + set_property(TARGET "hdf5::${hdf5_target_name}" APPEND + PROPERTY + INTERFACE_COMPILE_DEFINITIONS H5_BUILT_AS_STATIC_LIB) + endif () + unset(_hdf5_definitions) + unset(_hdf5_libtype) + unset(_hdf5_location) + endif () + endif () + endforeach () + unset(hdf5_lang) + + if (HDF5_DIFF_EXECUTABLE AND NOT TARGET hdf5::h5diff) + add_executable(hdf5::h5diff IMPORTED) + set_target_properties(hdf5::h5diff PROPERTIES + IMPORTED_LOCATION "${HDF5_DIFF_EXECUTABLE}") + endif () +endif () + if (HDF5_FIND_DEBUG) message(STATUS "HDF5_DIR: ${HDF5_DIR}") message(STATUS "HDF5_DEFINITIONS: ${HDF5_DEFINITIONS}") diff --git a/Modules/FindICU.cmake b/Modules/FindICU.cmake index 38081f5..c8b3e1f 100644 --- a/Modules/FindICU.cmake +++ b/Modules/FindICU.cmake @@ -5,6 +5,8 @@ FindICU ------- +.. versionadded:: 3.7 + Find the International Components for Unicode (ICU) libraries and programs. diff --git a/Modules/FindIce.cmake b/Modules/FindIce.cmake index 5ce2b42..0f821e8 100644 --- a/Modules/FindIce.cmake +++ b/Modules/FindIce.cmake @@ -5,6 +5,8 @@ FindIce ------- +.. versionadded:: 3.1 + Find the ZeroC Internet Communication Engine (ICE) programs, libraries and datafiles. diff --git a/Modules/FindIconv.cmake b/Modules/FindIconv.cmake index bf20f6f..41b7550 100644 --- a/Modules/FindIconv.cmake +++ b/Modules/FindIconv.cmake @@ -5,6 +5,8 @@ FindIconv --------- +.. versionadded:: 3.11 + This module finds the ``iconv()`` POSIX.1 functions on the system. These functions might be provided in the regular C library or externally in the form of an additional library. @@ -110,6 +112,7 @@ endif() find_library(Iconv_LIBRARY NAMES ${Iconv_LIBRARY_NAMES} + NAMES_PER_DIR DOC "iconv library (potentially the C library)") mark_as_advanced(Iconv_INCLUDE_DIR) diff --git a/Modules/FindIntl.cmake b/Modules/FindIntl.cmake index 3818d45..1a09a60 100644 --- a/Modules/FindIntl.cmake +++ b/Modules/FindIntl.cmake @@ -5,6 +5,8 @@ FindIntl -------- +.. versionadded:: 3.2 + Find the Gettext libintl headers and libraries. This module reports information about the Gettext libintl @@ -40,7 +42,7 @@ find_path(Intl_INCLUDE_DIR mark_as_advanced(Intl_INCLUDE_DIR) # Find all Intl libraries -find_library(Intl_LIBRARY "intl" +find_library(Intl_LIBRARY "intl" NAMES_PER_DIR DOC "libintl libraries (if not in the C library)") mark_as_advanced(Intl_LIBRARY) diff --git a/Modules/FindJPEG.cmake b/Modules/FindJPEG.cmake index 0bb6989..632fc9a 100644 --- a/Modules/FindJPEG.cmake +++ b/Modules/FindJPEG.cmake @@ -58,8 +58,8 @@ foreach(name ${jpeg_names}) endforeach() if(NOT JPEG_LIBRARY) - find_library(JPEG_LIBRARY_RELEASE NAMES ${jpeg_names}) - find_library(JPEG_LIBRARY_DEBUG NAMES ${jpeg_names_debug}) + find_library(JPEG_LIBRARY_RELEASE NAMES ${jpeg_names} NAMES_PER_DIR) + find_library(JPEG_LIBRARY_DEBUG NAMES ${jpeg_names_debug} NAMES_PER_DIR) include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) select_library_configurations(JPEG) mark_as_advanced(JPEG_LIBRARY_RELEASE JPEG_LIBRARY_DEBUG) diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 31e7de6..438551e 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -28,7 +28,7 @@ The following variables may be set to influence this module's behavior: * ``OpenBLAS`` * ``FLAME`` - * ``Intel10_32`` (intel mkl v10 32 bit) + * ``Intel10_32`` (intel mkl v10 32 bit, threaded code) * ``Intel10_64lp`` (intel mkl v10+ 64 bit, threaded code, lp64 model) * ``Intel10_64lp_seq`` (intel mkl v10+ 64 bit, sequential code, lp64 model) * ``Intel10_64ilp`` (intel mkl v10+ 64 bit, threaded code, ilp64 model) @@ -86,42 +86,38 @@ This module defines the following variables: find_package(LAPACK) #]=======================================================================] -# Check the language being used -if(NOT (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED OR CMAKE_Fortran_COMPILER_LOADED)) - if(LAPACK_FIND_REQUIRED) - message(FATAL_ERROR "FindLAPACK requires Fortran, C, or C++ to be enabled.") - else() - message(STATUS "Looking for LAPACK... - NOT found (Unsupported languages)") - return() - endif() -endif() - if(CMAKE_Fortran_COMPILER_LOADED) include(${CMAKE_CURRENT_LIST_DIR}/CheckFortranFunctionExists.cmake) else() include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake) endif() include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -cmake_push_check_state() -set(CMAKE_REQUIRED_QUIET ${LAPACK_FIND_QUIETLY}) +macro(_lapack_find_library_setup) + cmake_push_check_state() + set(CMAKE_REQUIRED_QUIET ${LAPACK_FIND_QUIETLY}) -set(LAPACK_FOUND FALSE) -set(LAPACK95_FOUND FALSE) - -set(_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) -if(BLA_STATIC) - if(WIN32) - set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set(_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + if(BLA_STATIC) + if(WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) + else() + set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + endif() else() - set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) - endif() -else() - if(CMAKE_SYSTEM_NAME STREQUAL "Linux") - # for ubuntu's libblas3gf and liblapack3gf packages - set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf) + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + # for ubuntu's libblas3gf and liblapack3gf packages + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf) + endif() endif() -endif() +endmacro() + +macro(_lapack_find_library_teardown) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) + unset(_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES) + cmake_pop_check_state() +endmacro() # TODO: move this stuff to a separate module @@ -162,6 +158,7 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _a if(_libraries_work) find_library(${_prefix}_${_library}_LIBRARY NAMES ${_library} + NAMES_PER_DIR PATHS ${_extaddlibdir} PATH_SUFFIXES ${_subdirs} ) @@ -172,6 +169,7 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _a endif() endif() endforeach() + unset(_library) if(_libraries_work) # Test this combination of libraries. @@ -195,185 +193,210 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _a else() set(${LIBRARIES} FALSE) endif() + + unset(_extaddlibdir) + unset(_libraries_work) + unset(_combined_name) #message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}") endmacro() +macro(_lapack_find_dependency dep) + set(_lapack_quiet_arg) + if(LAPACK_FIND_QUIETLY) + set(_lapack_quiet_arg QUIET) + endif() + set(_lapack_required_arg) + if(LAPACK_FIND_REQUIRED) + set(_lapack_required_arg REQUIRED) + endif() + find_package(${dep} ${ARGN} + ${_lapack_quiet_arg} + ${_lapack_required_arg} + ) + if (NOT ${dep}_FOUND) + set(LAPACK_NOT_FOUND_MESSAGE "LAPACK could not be found because dependency ${dep} could not be found.") + endif() + + set(_lapack_required_arg) + set(_lapack_quiet_arg) +endmacro() + +_lapack_find_library_setup() + set(LAPACK_LINKER_FLAGS) set(LAPACK_LIBRARIES) set(LAPACK95_LIBRARIES) -if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) - find_package(BLAS) -else() - find_package(BLAS REQUIRED) +# Check the language being used +if(NOT (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED OR CMAKE_Fortran_COMPILER_LOADED)) + set(LAPACK_NOT_FOUND_MESSAGE + "FindLAPACK requires Fortran, C, or C++ to be enabled.") +endif() + +# Load BLAS +if(NOT LAPACK_NOT_FOUND_MESSAGE) + _lapack_find_dependency(BLAS) endif() -if(BLAS_FOUND) +# Search for different LAPACK distributions if BLAS is found +if(NOT LAPACK_NOT_FOUND_MESSAGE) set(LAPACK_LINKER_FLAGS ${BLAS_LINKER_FLAGS}) if(NOT $ENV{BLA_VENDOR} STREQUAL "") set(BLA_VENDOR $ENV{BLA_VENDOR}) - else() - if(NOT BLA_VENDOR) - set(BLA_VENDOR "All") - endif() + elseif(NOT BLA_VENDOR) + set(BLA_VENDOR "All") endif() # LAPACK in the Intel MKL 10+ library? - if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - if(CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED) - # System-specific settings - if(NOT WIN32) - set(LAPACK_mkl_LM "-lm") - set(LAPACK_mkl_LDL "-ldl") - endif() - - if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) - find_package(Threads) - else() - find_package(Threads REQUIRED) - endif() - - if(BLA_VENDOR MATCHES "_64ilp") - set(LAPACK_mkl_ILP_MODE "ilp64") - else() - set(LAPACK_mkl_ILP_MODE "lp64") - endif() - - set(LAPACK_SEARCH_LIBS "") - - if(BLA_F95) - set(LAPACK_mkl_SEARCH_SYMBOL "cheev_f95") - set(_LIBRARIES LAPACK95_LIBRARIES) - set(_BLAS_LIBRARIES ${BLAS95_LIBRARIES}) - - # old - list(APPEND LAPACK_SEARCH_LIBS - "mkl_lapack95") - # new >= 10.3 - list(APPEND LAPACK_SEARCH_LIBS - "mkl_intel_c") - list(APPEND LAPACK_SEARCH_LIBS - "mkl_lapack95_${LAPACK_mkl_ILP_MODE}") - else() - set(LAPACK_mkl_SEARCH_SYMBOL "cheev") - set(_LIBRARIES LAPACK_LIBRARIES) - set(_BLAS_LIBRARIES ${BLAS_LIBRARIES}) - - # old and new >= 10.3 - list(APPEND LAPACK_SEARCH_LIBS - "mkl_lapack") - endif() - - # MKL uses a multitude of partially platform-specific subdirectories: - if(BLA_VENDOR STREQUAL "Intel10_32") - set(LAPACK_mkl_ARCH_NAME "ia32") - else() - set(LAPACK_mkl_ARCH_NAME "intel64") - endif() - if(WIN32) - set(LAPACK_mkl_OS_NAME "win") - elseif(APPLE) - set(LAPACK_mkl_OS_NAME "mac") - else() - set(LAPACK_mkl_OS_NAME "lin") - endif() - if(DEFINED ENV{MKLROOT}) - file(TO_CMAKE_PATH "$ENV{MKLROOT}" LAPACK_mkl_MKLROOT) - # If MKLROOT points to the subdirectory 'mkl', use the parent directory instead - # so we can better detect other relevant libraries in 'compiler' or 'tbb': - get_filename_component(LAPACK_mkl_MKLROOT_LAST_DIR "${LAPACK_mkl_MKLROOT}" NAME) - if(LAPACK_mkl_MKLROOT_LAST_DIR STREQUAL "mkl") - get_filename_component(LAPACK_mkl_MKLROOT "${LAPACK_mkl_MKLROOT}" DIRECTORY) - endif() - endif() - set(LAPACK_mkl_LIB_PATH_SUFFIXES - "compiler/lib" "compiler/lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}" - "mkl/lib" "mkl/lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}" - "lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}") - - # First try empty lapack libs - if(NOT ${_LIBRARIES}) - check_lapack_libraries( - ${_LIBRARIES} - LAPACK - ${LAPACK_mkl_SEARCH_SYMBOL} - "" - "" - "${CMAKE_THREAD_LIBS_INIT};${LAPACK_mkl_LM};${LAPACK_mkl_LDL}" - "${LAPACK_mkl_MKLROOT}" - "${LAPACK_mkl_LIB_PATH_SUFFIXES}" - "${_BLAS_LIBRARIES}" - ) - endif() - - # Then try the search libs - foreach(IT ${LAPACK_SEARCH_LIBS}) - string(REPLACE " " ";" SEARCH_LIBS ${IT}) - if(NOT ${_LIBRARIES}) - check_lapack_libraries( - ${_LIBRARIES} - LAPACK - ${LAPACK_mkl_SEARCH_SYMBOL} - "" - "${SEARCH_LIBS}" - "${CMAKE_THREAD_LIBS_INIT};${LAPACK_mkl_LM};${LAPACK_mkl_LDL}" - "${LAPACK_mkl_MKLROOT}" - "${LAPACK_mkl_LIB_PATH_SUFFIXES}" - "${_BLAS_LIBRARIES}" - ) - endif() - endforeach() - - unset(LAPACK_mkl_ILP_MODE) - unset(LAPACK_mkl_SEARCH_SYMBOL) - unset(LAPACK_mkl_LM) - unset(LAPACK_mkl_LDL) - unset(LAPACK_mkl_MKLROOT) - unset(LAPACK_mkl_ARCH_NAME) - unset(LAPACK_mkl_OS_NAME) - unset(LAPACK_mkl_LIB_PATH_SUFFIXES) - endif() + if(NOT LAPACK_LIBRARIES + AND (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") + AND (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED)) + # System-specific settings + if(NOT WIN32) + set(LAPACK_mkl_LM "-lm") + set(LAPACK_mkl_LDL "-ldl") endif() - endif() - # gotoblas? (http://www.tacc.utexas.edu/tacc-projects/gotoblas2) - if(BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) + _lapack_find_dependency(Threads) + + if(BLA_VENDOR MATCHES "_64ilp") + set(LAPACK_mkl_ILP_MODE "ilp64") + else() + set(LAPACK_mkl_ILP_MODE "lp64") + endif() + + set(LAPACK_SEARCH_LIBS "") + + if(BLA_F95) + set(LAPACK_mkl_SEARCH_SYMBOL "cheev_f95") + set(_LIBRARIES LAPACK95_LIBRARIES) + set(_BLAS_LIBRARIES ${BLAS95_LIBRARIES}) + + # old + list(APPEND LAPACK_SEARCH_LIBS + "mkl_lapack95") + # new >= 10.3 + list(APPEND LAPACK_SEARCH_LIBS + "mkl_intel_c") + list(APPEND LAPACK_SEARCH_LIBS + "mkl_lapack95_${LAPACK_mkl_ILP_MODE}") + else() + set(LAPACK_mkl_SEARCH_SYMBOL "cheev") + set(_LIBRARIES LAPACK_LIBRARIES) + set(_BLAS_LIBRARIES ${BLAS_LIBRARIES}) + + # old and new >= 10.3 + list(APPEND LAPACK_SEARCH_LIBS + "mkl_lapack") + endif() + + # MKL uses a multitude of partially platform-specific subdirectories: + if(BLA_VENDOR STREQUAL "Intel10_32") + set(LAPACK_mkl_ARCH_NAME "ia32") + else() + set(LAPACK_mkl_ARCH_NAME "intel64") + endif() + if(WIN32) + set(LAPACK_mkl_OS_NAME "win") + elseif(APPLE) + set(LAPACK_mkl_OS_NAME "mac") + else() + set(LAPACK_mkl_OS_NAME "lin") + endif() + if(DEFINED ENV{MKLROOT}) + file(TO_CMAKE_PATH "$ENV{MKLROOT}" LAPACK_mkl_MKLROOT) + # If MKLROOT points to the subdirectory 'mkl', use the parent directory instead + # so we can better detect other relevant libraries in 'compiler' or 'tbb': + get_filename_component(LAPACK_mkl_MKLROOT_LAST_DIR "${LAPACK_mkl_MKLROOT}" NAME) + if(LAPACK_mkl_MKLROOT_LAST_DIR STREQUAL "mkl") + get_filename_component(LAPACK_mkl_MKLROOT "${LAPACK_mkl_MKLROOT}" DIRECTORY) + endif() + endif() + set(LAPACK_mkl_LIB_PATH_SUFFIXES + "compiler/lib" "compiler/lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}" + "compiler/lib/${LAPACK_mkl_ARCH_NAME}" + "mkl/lib" "mkl/lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}" + "mkl/lib/${LAPACK_mkl_ARCH_NAME}" + "lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}") + + # First try empty lapack libs + if(NOT ${_LIBRARIES}) check_lapack_libraries( - LAPACK_LIBRARIES + ${_LIBRARIES} LAPACK - cheev - "" - "goto2" + ${LAPACK_mkl_SEARCH_SYMBOL} "" "" - "" - "${BLAS_LIBRARIES}" + "${CMAKE_THREAD_LIBS_INIT};${LAPACK_mkl_LM};${LAPACK_mkl_LDL}" + "${LAPACK_mkl_MKLROOT}" + "${LAPACK_mkl_LIB_PATH_SUFFIXES}" + "${_BLAS_LIBRARIES}" ) endif() + + # Then try the search libs + foreach(IT ${LAPACK_SEARCH_LIBS}) + string(REPLACE " " ";" SEARCH_LIBS ${IT}) + if(NOT ${_LIBRARIES}) + check_lapack_libraries( + ${_LIBRARIES} + LAPACK + ${LAPACK_mkl_SEARCH_SYMBOL} + "" + "${SEARCH_LIBS}" + "${CMAKE_THREAD_LIBS_INIT};${LAPACK_mkl_LM};${LAPACK_mkl_LDL}" + "${LAPACK_mkl_MKLROOT}" + "${LAPACK_mkl_LIB_PATH_SUFFIXES}" + "${_BLAS_LIBRARIES}" + ) + endif() + endforeach() + + unset(LAPACK_mkl_ILP_MODE) + unset(LAPACK_mkl_SEARCH_SYMBOL) + unset(LAPACK_mkl_LM) + unset(LAPACK_mkl_LDL) + unset(LAPACK_mkl_MKLROOT) + unset(LAPACK_mkl_ARCH_NAME) + unset(LAPACK_mkl_OS_NAME) + unset(LAPACK_mkl_LIB_PATH_SUFFIXES) + endif() + + # gotoblas? (http://www.tacc.utexas.edu/tacc-projects/gotoblas2) + if(NOT LAPACK_LIBRARIES + AND (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All")) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "goto2" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) endif() # OpenBLAS? (http://www.openblas.net) - if(BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "openblas" - "" - "" - "" - "${BLAS_LIBRARIES}" - ) - endif() + if(NOT LAPACK_LIBRARIES + AND (BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All")) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "openblas" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) endif() # ArmPL? (https://developer.arm.com/tools-and-software/server-and-hpc/compile/arm-compiler-for-linux/arm-performance-libraries) - if(BLA_VENDOR MATCHES "Arm" OR BLA_VENDOR STREQUAL "All") - + if(NOT LAPACK_LIBRARIES + AND (BLA_VENDOR MATCHES "Arm" OR BLA_VENDOR STREQUAL "All")) # Check for 64bit Integer support if(BLA_VENDOR MATCHES "_ilp64") set(LAPACK_armpl_LIB "armpl_ilp64") @@ -386,36 +409,33 @@ if(BLAS_FOUND) set(LAPACK_armpl_LIB "${LAPACK_armpl_LIB}_mp") endif() - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "${LAPACK_armpl_LIB}" - "" - "" - "" - "${BLAS_LIBRARIES}" - ) - endif() + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "${LAPACK_armpl_LIB}" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) endif() # FLAME's blis library? (https://github.com/flame/blis) - if(BLA_VENDOR STREQUAL "FLAME" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "flame" - "" - "" - "" - "${BLAS_LIBRARIES}" - ) - endif() + if(NOT LAPACK_LIBRARIES + AND (BLA_VENDOR STREQUAL "FLAME" OR BLA_VENDOR STREQUAL "All")) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "flame" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) endif() # BLAS in acml library? @@ -426,106 +446,70 @@ if(BLAS_FOUND) endif() # Apple LAPACK library? - if(BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "Accelerate" - "" - "" - "" - "${BLAS_LIBRARIES}" - ) - endif() + if(NOT LAPACK_LIBRARIES + AND (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All")) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "Accelerate" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) endif() # Apple NAS (vecLib) library? - if(BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "vecLib" - "" - "" - "" - "${BLAS_LIBRARIES}" - ) - endif() + if(NOT LAPACK_LIBRARIES + AND (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All")) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "vecLib" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) endif() # Generic LAPACK library? - if(BLA_VENDOR STREQUAL "Generic" OR - BLA_VENDOR STREQUAL "ATLAS" OR - BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "lapack" - "" - "" - "" - "${BLAS_LIBRARIES}" - ) - endif() + if(NOT LAPACK_LIBRARIES + AND (BLA_VENDOR STREQUAL "Generic" + OR BLA_VENDOR STREQUAL "ATLAS" + OR BLA_VENDOR STREQUAL "All")) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "lapack" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) endif() -else() - message(STATUS "LAPACK requires BLAS") endif() if(BLA_F95) - if(LAPACK95_LIBRARIES) - set(LAPACK95_FOUND TRUE) - else() - set(LAPACK95_FOUND FALSE) - endif() - if(NOT LAPACK_FIND_QUIETLY) - if(LAPACK95_FOUND) - message(STATUS "A library with LAPACK95 API found.") - else() - if(LAPACK_FIND_REQUIRED) - message(FATAL_ERROR - "A required library with LAPACK95 API not found. Please specify library location." - ) - else() - message(STATUS - "A library with LAPACK95 API not found. Please specify library location." - ) - endif() - endif() - endif() - set(LAPACK_FOUND "${LAPACK95_FOUND}") set(LAPACK_LIBRARIES "${LAPACK95_LIBRARIES}") -else() - if(LAPACK_LIBRARIES) - set(LAPACK_FOUND TRUE) - else() - set(LAPACK_FOUND FALSE) - endif() +endif() - if(NOT LAPACK_FIND_QUIETLY) - if(LAPACK_FOUND) - message(STATUS "A library with LAPACK API found.") - else() - if(LAPACK_FIND_REQUIRED) - message(FATAL_ERROR - "A required library with LAPACK API not found. Please specify library location." - ) - else() - message(STATUS - "A library with LAPACK API not found. Please specify library location." - ) - endif() - endif() - endif() +if(LAPACK_NOT_FOUND_MESSAGE) + set(LAPACK_NOT_FOUND_MESSAGE + REASON_FAILURE_MESSAGE ${LAPACK_NOT_FOUND_MESSAGE}) +endif() +find_package_handle_standard_args(LAPACK REQUIRED_VARS LAPACK_LIBRARIES + ${LAPACK_NOT_FOUND_MESSAGE}) +unset(LAPACK_NOT_FOUND_MESSAGE) + +if(BLA_F95) + set(LAPACK95_FOUND ${LAPACK_FOUND}) endif() # On compilers that implicitly link LAPACK (such as ftn, cc, and CC on Cray HPC machines) @@ -534,7 +518,7 @@ if(LAPACK_LIBRARIES STREQUAL "LAPACK_LIBRARIES-PLACEHOLDER-FOR-EMPTY-LIBRARIES") set(LAPACK_LIBRARIES "") endif() -if(NOT TARGET LAPACK::LAPACK) +if(LAPACK_FOUND AND NOT TARGET LAPACK::LAPACK) add_library(LAPACK::LAPACK INTERFACE IMPORTED) set(_lapack_libs "${LAPACK_LIBRARIES}") if(_lapack_libs AND TARGET BLAS::BLAS) @@ -551,5 +535,4 @@ if(NOT TARGET LAPACK::LAPACK) unset(_lapack_libs) endif() -cmake_pop_check_state() -set(CMAKE_FIND_LIBRARY_SUFFIXES ${_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) +_lapack_find_library_teardown() diff --git a/Modules/FindLTTngUST.cmake b/Modules/FindLTTngUST.cmake index 9cd17eb..f478e4d 100644 --- a/Modules/FindLTTngUST.cmake +++ b/Modules/FindLTTngUST.cmake @@ -5,6 +5,8 @@ FindLTTngUST ------------ +.. versionadded:: 3.6 + Find `Linux Trace Toolkit Next Generation (LTTng-UST) <http://lttng.org/>`__ library. diff --git a/Modules/FindLibLZMA.cmake b/Modules/FindLibLZMA.cmake index 200d6bf..4a79a10 100644 --- a/Modules/FindLibLZMA.cmake +++ b/Modules/FindLibLZMA.cmake @@ -43,8 +43,8 @@ This module will set the following variables in your project: find_path(LIBLZMA_INCLUDE_DIR lzma.h ) if(NOT LIBLZMA_LIBRARY) - find_library(LIBLZMA_LIBRARY_RELEASE NAMES lzma liblzma PATH_SUFFIXES lib) - find_library(LIBLZMA_LIBRARY_DEBUG NAMES lzmad liblzmad PATH_SUFFIXES lib) + find_library(LIBLZMA_LIBRARY_RELEASE NAMES lzma liblzma NAMES_PER_DIR PATH_SUFFIXES lib) + find_library(LIBLZMA_LIBRARY_DEBUG NAMES lzmad liblzmad NAMES_PER_DIR PATH_SUFFIXES lib) include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) select_library_configurations(LIBLZMA) else() diff --git a/Modules/FindLibinput.cmake b/Modules/FindLibinput.cmake index c1fe455..88d5b2f 100644 --- a/Modules/FindLibinput.cmake +++ b/Modules/FindLibinput.cmake @@ -5,6 +5,8 @@ FindLibinput ------------ +.. versionadded:: 3.14 + Find libinput headers and library. Imported Targets diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index bbd40a4..b531e47 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -760,7 +760,7 @@ function (_MPI_interrogate_compiler LANG) # Save the explicitly given link directories set(MPI_LINK_DIRECTORIES_LEFTOVER "${MPI_LINK_DIRECTORIES_WORK}") - # An MPI compiler wrapper could have its MPI libraries in the implictly + # An MPI compiler wrapper could have its MPI libraries in the implicitly # linked directories of the compiler itself. if(DEFINED CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES) list(APPEND MPI_LINK_DIRECTORIES_WORK "${CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES}") diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake index e42c206..05ec3ae 100644 --- a/Modules/FindMatlab.cmake +++ b/Modules/FindMatlab.cmake @@ -992,7 +992,10 @@ function(matlab_add_mex) endif() endif() - if(NOT Matlab_VERSION_STRING VERSION_LESS "9.4") # For 9.4 (R2018a) and newer, add API macro + # For 9.4 (R2018a) and newer, add API macro. + # Add it for unknown versions too, just in case. + if(NOT Matlab_VERSION_STRING VERSION_LESS "9.4" + OR Matlab_VERSION_STRING STREQUAL "unknown") if(${${prefix}_R2018a}) set(MEX_API_MACRO "MATLAB_DEFAULT_RELEASE=R2018a") else() diff --git a/Modules/FindODBC.cmake b/Modules/FindODBC.cmake index 3f710db..884653c 100644 --- a/Modules/FindODBC.cmake +++ b/Modules/FindODBC.cmake @@ -5,6 +5,8 @@ FindODBC -------- +.. versionadded:: 3.12 + Find an Open Database Connectivity (ODBC) include directory and library. On Windows, when building with Visual Studio, this module assumes the ODBC diff --git a/Modules/FindOpenACC.cmake b/Modules/FindOpenACC.cmake index 398dcf5..ed52e35 100644 --- a/Modules/FindOpenACC.cmake +++ b/Modules/FindOpenACC.cmake @@ -5,6 +5,8 @@ FindOpenACC ----------- +.. versionadded:: 3.10 + Detect OpenACC support by the compiler. This module can be used to detect OpenACC support in a compiler. diff --git a/Modules/FindOpenCL.cmake b/Modules/FindOpenCL.cmake index 34a203e..b3e5a9f 100644 --- a/Modules/FindOpenCL.cmake +++ b/Modules/FindOpenCL.cmake @@ -5,6 +5,8 @@ FindOpenCL ---------- +.. versionadded:: 3.1 + Finds Open Computing Language (OpenCL) IMPORTED Targets diff --git a/Modules/FindOpenGL.cmake b/Modules/FindOpenGL.cmake index 17ffe85..110e7f9 100644 --- a/Modules/FindOpenGL.cmake +++ b/Modules/FindOpenGL.cmake @@ -132,19 +132,7 @@ endforeach() set(_OpenGL_CACHE_VARS) -if (CYGWIN) - find_path(OPENGL_INCLUDE_DIR GL/gl.h ) - list(APPEND _OpenGL_REQUIRED_VARS OPENGL_INCLUDE_DIR) - - find_library(OPENGL_gl_LIBRARY opengl32 ) - find_library(OPENGL_glu_LIBRARY glu32 ) - - list(APPEND _OpenGL_CACHE_VARS - OPENGL_INCLUDE_DIR - OPENGL_gl_LIBRARY - OPENGL_glu_LIBRARY - ) -elseif (WIN32) +if (WIN32) if(BORLAND) set (OPENGL_gl_LIBRARY import32 CACHE STRING "OpenGL library for win32") diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index ee40696..91a65fd 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -27,11 +27,11 @@ This module defines the following :prop_tgt:`IMPORTED` targets: projects under MSVC. This target is available only if found OpenSSL version is not less than 0.9.8. By linking this target the above OpenSSL targets can be linked even if the project has different MSVC runtime configurations with - the above OpenSSL targets. This target has no effect on plaforms other than + the above OpenSSL targets. This target has no effect on platforms other than MSVC. NOTE: Due to how ``INTERFACE_SOURCES`` are consumed by the consuming target, -unless you certainly know what you are doing, it is always prefered to link +unless you certainly know what you are doing, it is always preferred to link ``OpenSSL::applink`` target as ``PRIVATE`` and to make sure that this target is linked at most once for the whole dependency graph of any library or executable: @@ -193,12 +193,18 @@ if(WIN32 AND NOT CYGWIN) endif() if(OPENSSL_USE_STATIC_LIBS) + set(_OPENSSL_STATIC_SUFFIX + "_static" + ) set(_OPENSSL_PATH_SUFFIXES "lib/VC/static" "VC/static" "lib" ) else() + set(_OPENSSL_STATIC_SUFFIX + "" + ) set(_OPENSSL_PATH_SUFFIXES "lib/VC" "VC" @@ -208,6 +214,17 @@ if(WIN32 AND NOT CYGWIN) find_library(LIB_EAY_DEBUG NAMES + # When OpenSSL is built with default options, the static library name is suffixed with "_static". + # Looking the "libcrypto_static.lib" with a higher priority than "libcrypto.lib" which is the + # import library of "libcrypto.dll". + libcrypto${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d + libcrypto${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d + libcrypto${_OPENSSL_STATIC_SUFFIX}d + libeay32${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d + libeay32${_OPENSSL_STATIC_SUFFIX}d + crypto${_OPENSSL_STATIC_SUFFIX}d + # When OpenSSL is built with the "-static" option, only the static build is produced, + # and it is not suffixed with "_static". libcrypto${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d libcrypto${_OPENSSL_MSVC_RT_MODE}d libcryptod @@ -222,6 +239,17 @@ if(WIN32 AND NOT CYGWIN) find_library(LIB_EAY_RELEASE NAMES + # When OpenSSL is built with default options, the static library name is suffixed with "_static". + # Looking the "libcrypto_static.lib" with a higher priority than "libcrypto.lib" which is the + # import library of "libcrypto.dll". + libcrypto${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE} + libcrypto${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE} + libcrypto${_OPENSSL_STATIC_SUFFIX} + libeay32${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE} + libeay32${_OPENSSL_STATIC_SUFFIX} + crypto${_OPENSSL_STATIC_SUFFIX} + # When OpenSSL is built with the "-static" option, only the static build is produced, + # and it is not suffixed with "_static". libcrypto${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE} libcrypto${_OPENSSL_MSVC_RT_MODE} libcrypto @@ -236,6 +264,17 @@ if(WIN32 AND NOT CYGWIN) find_library(SSL_EAY_DEBUG NAMES + # When OpenSSL is built with default options, the static library name is suffixed with "_static". + # Looking the "libssl_static.lib" with a higher priority than "libssl.lib" which is the + # import library of "libssl.dll". + libssl${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d + libssl${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d + libssl${_OPENSSL_STATIC_SUFFIX}d + ssleay32${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d + ssleay32${_OPENSSL_STATIC_SUFFIX}d + ssl${_OPENSSL_STATIC_SUFFIX}d + # When OpenSSL is built with the "-static" option, only the static build is produced, + # and it is not suffixed with "_static". libssl${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d libssl${_OPENSSL_MSVC_RT_MODE}d libssld @@ -250,6 +289,17 @@ if(WIN32 AND NOT CYGWIN) find_library(SSL_EAY_RELEASE NAMES + # When OpenSSL is built with default options, the static library name is suffixed with "_static". + # Looking the "libssl_static.lib" with a higher priority than "libssl.lib" which is the + # import library of "libssl.dll". + libssl${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE} + libssl${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE} + libssl${_OPENSSL_STATIC_SUFFIX} + ssleay32${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE} + ssleay32${_OPENSSL_STATIC_SUFFIX} + ssl${_OPENSSL_STATIC_SUFFIX} + # When OpenSSL is built with the "-static" option, only the static build is produced, + # and it is not suffixed with "_static". libssl${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE} libssl${_OPENSSL_MSVC_RT_MODE} libssl diff --git a/Modules/FindPNG.cmake b/Modules/FindPNG.cmake index f1fe89a..fd0e4e9 100644 --- a/Modules/FindPNG.cmake +++ b/Modules/FindPNG.cmake @@ -76,8 +76,8 @@ if(ZLIB_FOUND) # For compatibility with versions prior to this multi-config search, honor # any PNG_LIBRARY that is already specified and skip the search. if(NOT PNG_LIBRARY) - find_library(PNG_LIBRARY_RELEASE NAMES ${PNG_NAMES}) - find_library(PNG_LIBRARY_DEBUG NAMES ${PNG_NAMES_DEBUG}) + find_library(PNG_LIBRARY_RELEASE NAMES ${PNG_NAMES} NAMES_PER_DIR) + find_library(PNG_LIBRARY_DEBUG NAMES ${PNG_NAMES_DEBUG} NAMES_PER_DIR) include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) select_library_configurations(PNG) mark_as_advanced(PNG_LIBRARY_RELEASE PNG_LIBRARY_DEBUG) diff --git a/Modules/FindPatch.cmake b/Modules/FindPatch.cmake index 4998839..4108651 100644 --- a/Modules/FindPatch.cmake +++ b/Modules/FindPatch.cmake @@ -5,6 +5,8 @@ FindPatch --------- +.. versionadded:: 3.10 + The module defines the following variables: ``Patch_EXECUTABLE`` diff --git a/Modules/FindPerlLibs.cmake b/Modules/FindPerlLibs.cmake index 7e27f31..d576b86 100644 --- a/Modules/FindPerlLibs.cmake +++ b/Modules/FindPerlLibs.cmake @@ -108,6 +108,9 @@ if (PERL_EXECUTABLE) if (NOT PERL_POSSIBLE_LIBRARY_NAMES) set(PERL_POSSIBLE_LIBRARY_NAMES perl${PERL_VERSION_STRING} perl) endif() + if(CMAKE_SYSTEM_NAME MATCHES "CYGWIN") + list (APPEND PERL_POSSIBLE_LIBRARY_NAMES perl${PERL_VERSION_STRING}) + endif() if (CMAKE_SYSTEM_NAME MATCHES "MSYS|CYGWIN") # on MSYS and CYGWIN environments, current perl -V:libperl gives shared library name # rather than the import library. So, extends possible library names diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake index e09717d..f6d8fe3 100644 --- a/Modules/FindProtobuf.cmake +++ b/Modules/FindProtobuf.cmake @@ -376,11 +376,13 @@ function(_protobuf_find_libraries name filename) else() find_library(${name}_LIBRARY_RELEASE NAMES ${filename} + NAMES_PER_DIR PATHS ${Protobuf_SRC_ROOT_FOLDER}/vsprojects/${_PROTOBUF_ARCH_DIR}Release) mark_as_advanced(${name}_LIBRARY_RELEASE) find_library(${name}_LIBRARY_DEBUG NAMES ${filename}d ${filename} + NAMES_PER_DIR PATHS ${Protobuf_SRC_ROOT_FOLDER}/vsprojects/${_PROTOBUF_ARCH_DIR}Debug) mark_as_advanced(${name}_LIBRARY_DEBUG) diff --git a/Modules/FindPython.cmake b/Modules/FindPython.cmake index 01b82c4..d89029a 100644 --- a/Modules/FindPython.cmake +++ b/Modules/FindPython.cmake @@ -5,6 +5,8 @@ FindPython ---------- +.. versionadded:: 3.12 + Find Python interpreter, compiler and development environment (include directories and libraries). @@ -44,7 +46,7 @@ To manage concurrent versions 3 and 2 of Python, use :module:`FindPython3` and If components ``Interpreter`` and ``Development`` (or one of its sub-components) are both specified, this module search only for interpreter with same platform architecture as the one defined by ``CMake`` - configuration. This contraint does not apply if only ``Interpreter`` + configuration. This constraint does not apply if only ``Interpreter`` component is specified. Imported Targets @@ -155,7 +157,7 @@ This module will set the following variables in your project ``Python_NumPy_FOUND`` System has the NumPy. ``Python_NumPy_INCLUDE_DIRS`` - The NumPy include directries. + The NumPy include directories. ``Python_NumPy_VERSION`` The NumPy version. @@ -189,7 +191,7 @@ Hints * ``ON``: Corresponding flag is selected. * ``OFF``: Corresponding flag is not selected. - * ``ANY``: The two posibilties (``ON`` and ``OFF``) will be searched. + * ``ANY``: The two possibilities (``ON`` and ``OFF``) will be searched. From this 3-tuple, various ABIs will be searched starting from the most specialized to the most general. Moreover, ``debug`` versions will be @@ -347,7 +349,7 @@ setting the following variables: When an artifact is specified, all ``HINTS`` will be ignored and no search will be performed for this artifact. - If more than one artifact is specified, it is the user's responsability to + If more than one artifact is specified, it is the user's responsibility to ensure the consistency of the various artifacts. By default, this module supports multiple calls in different directories of a @@ -355,7 +357,7 @@ project with different version/component requirements while providing correct and consistent results for each call. To support this behavior, ``CMake`` cache is not used in the traditional way which can be problematic for interactive specification. So, to enable also interactive specification, module behavior -can be controled with the following variable: +can be controlled with the following variable: ``Python_ARTIFACTS_INTERACTIVE`` Selects the behavior of the module. This is a boolean variable: diff --git a/Modules/FindPython2.cmake b/Modules/FindPython2.cmake index 84c0c73..f5ad454 100644 --- a/Modules/FindPython2.cmake +++ b/Modules/FindPython2.cmake @@ -5,6 +5,8 @@ FindPython2 ----------- +.. versionadded:: 3.12 + Find Python 2 interpreter, compiler and development environment (include directories and libraries). @@ -45,7 +47,7 @@ for you. If components ``Interpreter`` and ``Development`` (or one of its sub-components) are both specified, this module search only for interpreter with same platform architecture as the one defined by ``CMake`` - configuration. This contraint does not apply if only ``Interpreter`` + configuration. This constraint does not apply if only ``Interpreter`` component is specified. Imported Targets @@ -147,7 +149,7 @@ This module will set the following variables in your project ``Python2_NumPy_FOUND`` System has the NumPy. ``Python2_NumPy_INCLUDE_DIRS`` - The NumPy include directries. + The NumPy include directories. ``Python2_NumPy_VERSION`` The NumPy version. @@ -294,7 +296,7 @@ setting the following variables: When an artifact is specified, all ``HINTS`` will be ignored and no search will be performed for this artifact. - If more than one artifact is specified, it is the user's responsability to + If more than one artifact is specified, it is the user's responsibility to ensure the consistency of the various artifacts. By default, this module supports multiple calls in different directories of a @@ -302,7 +304,7 @@ project with different version/component requirements while providing correct and consistent results for each call. To support this behavior, ``CMake`` cache is not used in the traditional way which can be problematic for interactive specification. So, to enable also interactive specification, module behavior -can be controled with the following variable: +can be controlled with the following variable: ``Python2_ARTIFACTS_INTERACTIVE`` Selects the behavior of the module. This is a boolean variable: diff --git a/Modules/FindPython3.cmake b/Modules/FindPython3.cmake index f142c07..bacdc42 100644 --- a/Modules/FindPython3.cmake +++ b/Modules/FindPython3.cmake @@ -5,6 +5,8 @@ FindPython3 ----------- +.. versionadded:: 3.12 + Find Python 3 interpreter, compiler and development environment (include directories and libraries). @@ -45,7 +47,7 @@ for you. If components ``Interpreter`` and ``Development`` (or one of its sub-components) are both specified, this module search only for interpreter with same platform architecture as the one defined by ``CMake`` - configuration. This contraint does not apply if only ``Interpreter`` + configuration. This constraint does not apply if only ``Interpreter`` component is specified. Imported Targets @@ -156,7 +158,7 @@ This module will set the following variables in your project ``Python3_NumPy_FOUND`` System has the NumPy. ``Python3_NumPy_INCLUDE_DIRS`` - The NumPy include directries. + The NumPy include directories. ``Python3_NumPy_VERSION`` The NumPy version. @@ -186,7 +188,7 @@ Hints * ``ON``: Corresponding flag is selected. * ``OFF``: Corresponding flag is not selected. - * ``ANY``: The two posibilties (``ON`` and ``OFF``) will be searched. + * ``ANY``: The two possibilities (``ON`` and ``OFF``) will be searched. From this 3-tuple, various ABIs will be searched starting from the most specialized to the most general. Moreover, ``debug`` versions will be @@ -344,7 +346,7 @@ setting the following variables: When an artifact is specified, all ``HINTS`` will be ignored and no search will be performed for this artifact. - If more than one artifact is specified, it is the user's responsability to + If more than one artifact is specified, it is the user's responsibility to ensure the consistency of the various artifacts. By default, this module supports multiple calls in different directories of a @@ -352,7 +354,7 @@ project with different version/component requirements while providing correct and consistent results for each call. To support this behavior, ``CMake`` cache is not used in the traditional way which can be problematic for interactive specification. So, to enable also interactive specification, module behavior -can be controled with the following variable: +can be controlled with the following variable: ``Python3_ARTIFACTS_INTERACTIVE`` Selects the behavior of the module. This is a boolean variable: diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index 2e3da74..ec0f453 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -147,7 +147,7 @@ more-manual way. Several macros are available to add targets for such uses. in: directories sources ts_files options: flags to pass to lupdate, such as -extensions to specify extensions for a directory scan. - generates commands to create .ts (vie lupdate) and .qm + generates commands to create .ts (via lupdate) and .qm (via lrelease) - files from directories and/or sources. The ts files are created and/or updated in the source tree (unless given with full paths). The qm files are generated in the build tree. diff --git a/Modules/FindSDL.cmake b/Modules/FindSDL.cmake index 8d793a9..59eddbb 100644 --- a/Modules/FindSDL.cmake +++ b/Modules/FindSDL.cmake @@ -5,24 +5,54 @@ FindSDL ------- -Locate SDL library +Locate the SDL library -This module defines -:: +Imported targets +^^^^^^^^^^^^^^^^ - SDL_LIBRARY, the name of the library to link against - SDL_FOUND, if false, do not try to link to SDL - SDL_INCLUDE_DIR, where to find SDL.h - SDL_VERSION_STRING, human-readable string containing the version of SDL +This module defines the following :prop_tgt:`IMPORTED` target: +``SDL::SDL`` + The SDL library, if found +Result variables +^^^^^^^^^^^^^^^^ -This module responds to the flag: +This module will set the following variables in your project: + +``SDL_INCLUDE_DIRS`` + where to find SDL.h +``SDL_LIBRARIES`` + the name of the library to link against +``SDL_FOUND`` + if false, do not try to link to SDL +``SDL_VERSION`` + the human-readable string containing the version of SDL if found +``SDL_VERSION_MAJOR`` + SDL major version +``SDL_VERSION_MINOR`` + SDL minor version +``SDL_VERSION_PATCH`` + SDL patch version + +Cache variables +^^^^^^^^^^^^^^^ + +These variables may optionally be set to help this module find the correct files: -:: +``SDL_INCLUDE_DIR`` + where to find SDL.h +``SDL_LIBRARY`` + the name of the library to link against + + +Variables for locating SDL +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This module responds to the flag: - SDL_BUILDING_LIBRARY +``SDL_BUILDING_LIBRARY`` If this is defined, then no SDL_main will be linked in because only applications need main(). Otherwise, it is assumed you are building an application and this @@ -30,6 +60,15 @@ This module responds to the flag: as part of the returned SDL_LIBRARY variable. +Obsolete variables +^^^^^^^^^^^^^^^^^^ + +These variables are obsolete and provided for backwards compatibility: + +``SDL_VERSION_STRING`` + the human-readable string containing the version of SDL if found. + Identical to SDL_VERSION + Don't forget to include SDLmain.h and SDLmain.m your project for the OS X framework based version. (Other versions link to -lSDLmain which @@ -52,15 +91,6 @@ does not get created. $SDLDIR is an environment variable that would correspond to the ./configure --prefix=$SDLDIR used in building SDL. l.e.galup 9-20-02 -Modified by Eric Wing. Added code to assist with automated building -by using environmental variables and providing a more -controlled/consistent search behavior. Added new modifications to -recognize OS X frameworks and additional Unix paths (FreeBSD, etc). -Also corrected the header search path to follow "proper" SDL -guidelines. Added a search for SDLmain which is needed by some -platforms. Added a search for threads which is needed by some -platforms. Added needed compile switches for MinGW. - On OSX, this will prefer the Framework version (if found) over others. People will have to manually change the cache values of SDL_LIBRARY to override this selection or set the CMake environment @@ -174,13 +204,11 @@ if(SDL_INCLUDE_DIR AND EXISTS "${SDL_INCLUDE_DIR}/SDL_version.h") string(REGEX REPLACE "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_VERSION_MAJOR "${SDL_VERSION_MAJOR_LINE}") string(REGEX REPLACE "^#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_VERSION_MINOR "${SDL_VERSION_MINOR_LINE}") string(REGEX REPLACE "^#define[ \t]+SDL_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL_VERSION_PATCH "${SDL_VERSION_PATCH_LINE}") - set(SDL_VERSION_STRING ${SDL_VERSION_MAJOR}.${SDL_VERSION_MINOR}.${SDL_VERSION_PATCH}) unset(SDL_VERSION_MAJOR_LINE) unset(SDL_VERSION_MINOR_LINE) unset(SDL_VERSION_PATCH_LINE) - unset(SDL_VERSION_MAJOR) - unset(SDL_VERSION_MINOR) - unset(SDL_VERSION_PATCH) + set(SDL_VERSION ${SDL_VERSION_MAJOR}.${SDL_VERSION_MINOR}.${SDL_VERSION_PATCH}) + set(SDL_VERSION_STRING ${SDL_VERSION}) endif() include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) @@ -188,3 +216,14 @@ include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL REQUIRED_VARS SDL_LIBRARY SDL_INCLUDE_DIR VERSION_VAR SDL_VERSION_STRING) + +if(SDL_FOUND) + set(SDL_LIBRARIES ${SDL_LIBRARY}) + set(SDL_INCLUDE_DIRS ${SDL_INCLUDE_DIR}) + if(NOT TARGET SDL::SDL) + add_library(SDL::SDL INTERFACE IMPORTED) + set_target_properties(SDL::SDL PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${SDL_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "${SDL_LIBRARY}") + endif() +endif() diff --git a/Modules/FindSQLite3.cmake b/Modules/FindSQLite3.cmake index 374d7af..88c7dd2 100644 --- a/Modules/FindSQLite3.cmake +++ b/Modules/FindSQLite3.cmake @@ -5,6 +5,8 @@ FindSQLite3 ----------- +.. versionadded:: 3.14 + Find the SQLite libraries, v3 IMPORTED targets diff --git a/Modules/FindTIFF.cmake b/Modules/FindTIFF.cmake index 00a3a41..3b74c94 100644 --- a/Modules/FindTIFF.cmake +++ b/Modules/FindTIFF.cmake @@ -5,7 +5,14 @@ FindTIFF -------- -Find the TIFF library (``libtiff``). +Find the TIFF library (``libtiff``, https://libtiff.gitlab.io/libtiff/). + +Optional COMPONENTS +^^^^^^^^^^^^^^^^^^^ + +This module supports the optional component `CXX`, for use with the COMPONENTS +argument of the :command:`find_package` command. This component has an associated +imported target, as described below. Imported targets ^^^^^^^^^^^^^^^^ @@ -15,6 +22,11 @@ This module defines the following :prop_tgt:`IMPORTED` targets: ``TIFF::TIFF`` The TIFF library, if found. +``TIFF::CXX`` + The C++ wrapper libtiffxx, if requested by the `COMPONENTS CXX` option, + if the compiler is not MSVC (which includes the C++ wrapper in libtiff), + and if found. + Result variables ^^^^^^^^^^^^^^^^ @@ -36,10 +48,19 @@ The following cache variables may also be set: ``TIFF_INCLUDE_DIR`` the directory containing the TIFF headers -``TIFF_LIBRARY`` - the path to the TIFF library +``TIFF_LIBRARY_RELEASE`` + the path to the TIFF library for release configurations +``TIFF_LIBRARY_DEBUG`` + the path to the TIFF library for debug configurations +``TIFFXX_LIBRARY_RELEASE`` + the path to the TIFFXX library for release configurations +``TIFFXX_LIBRARY_DEBUG`` + the path to the TIFFXX library for debug configurations #]=======================================================================] +cmake_policy(PUSH) +cmake_policy(SET CMP0057 NEW) + find_path(TIFF_INCLUDE_DIR tiff.h) set(TIFF_NAMES ${TIFF_NAMES} tiff libtiff tiff3 libtiff3) @@ -54,8 +75,6 @@ if(NOT TIFF_LIBRARY) select_library_configurations(TIFF) mark_as_advanced(TIFF_LIBRARY_RELEASE TIFF_LIBRARY_DEBUG) endif() -unset(TIFF_NAMES) -unset(TIFF_NAMES_DEBUG) if(TIFF_INCLUDE_DIR AND EXISTS "${TIFF_INCLUDE_DIR}/tiffvers.h") file(STRINGS "${TIFF_INCLUDE_DIR}/tiffvers.h" tiff_version_str @@ -66,13 +85,46 @@ if(TIFF_INCLUDE_DIR AND EXISTS "${TIFF_INCLUDE_DIR}/tiffvers.h") unset(tiff_version_str) endif() +foreach(_comp IN LISTS TIFF_FIND_COMPONENTS) + if(_comp STREQUAL "CXX") + if(MSVC) + # C++ bindings are built into the main tiff library. + set(TIFF_CXX_FOUND 1) + else() + foreach(name ${TIFF_NAMES}) + list(APPEND TIFFXX_NAMES "${name}xx") + list(APPEND TIFFXX_NAMES_DEBUG "${name}xxd") + endforeach() + find_library(TIFFXX_LIBRARY_RELEASE NAMES ${TIFFXX_NAMES}) + find_library(TIFFXX_LIBRARY_DEBUG NAMES ${TIFFXX_NAMES_DEBUG}) + include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) + select_library_configurations(TIFFXX) + mark_as_advanced(TIFFXX_LIBRARY_RELEASE TIFFXX_LIBRARY_DEBUG) + unset(TIFFXX_NAMES) + unset(TIFFXX_NAMES_DEBUG) + if(TIFFXX_LIBRARY) + set(TIFF_CXX_FOUND 1) + endif() + endif() + endif() +endforeach() +unset(_comp) + +unset(TIFF_NAMES) +unset(TIFF_NAMES_DEBUG) + include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(TIFF + HANDLE_COMPONENTS REQUIRED_VARS TIFF_LIBRARY TIFF_INCLUDE_DIR VERSION_VAR TIFF_VERSION_STRING) if(TIFF_FOUND) set(TIFF_LIBRARIES ${TIFF_LIBRARY}) + if("CXX" IN_LIST TIFF_FIND_COMPONENTS AND NOT MSVC) + list(APPEND TIFF_LIBRARIES ${TIFFXX_LIBRARY}) + endif() + set(TIFF_INCLUDE_DIRS "${TIFF_INCLUDE_DIR}") if(NOT TARGET TIFF::TIFF) @@ -101,6 +153,41 @@ if(TIFF_FOUND) IMPORTED_LOCATION_DEBUG "${TIFF_LIBRARY_DEBUG}") endif() endif() + + if(NOT TARGET TIFF::CXX) + if(MSVC) + add_library(TIFF::CXX INTERFACE IMPORTED) + set_property(TARGET TIFF::CXX PROPERTY INTERFACE_LINK_LIBRARIES TIFF::TIFF) + else() + add_library(TIFF::CXX UNKNOWN IMPORTED) + set_property(TARGET TIFF::CXX PROPERTY INTERFACE_LINK_LIBRARIES TIFF::TIFF) + if(TIFF_INCLUDE_DIRS) + set_target_properties(TIFF::CXX PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${TIFF_INCLUDE_DIRS}") + endif() + if(EXISTS "${TIFFXX_LIBRARY}") + set_target_properties(TIFF::CXX PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${TIFFXX_LIBRARY}") + endif() + if(EXISTS "${TIFFXX_LIBRARY_RELEASE}") + set_property(TARGET TIFF::CXX APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(TIFF::CXX PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX" + IMPORTED_LOCATION_RELEASE "${TIFFXX_LIBRARY_RELEASE}") + endif() + if(EXISTS "${TIFFXX_LIBRARY_DEBUG}") + set_property(TARGET TIFF::CXX APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(TIFF::CXX PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX" + IMPORTED_LOCATION_DEBUG "${TIFFXX_LIBRARY_DEBUG}") + endif() + endif() + endif() + endif() -mark_as_advanced(TIFF_INCLUDE_DIR TIFF_LIBRARY) +mark_as_advanced(TIFF_INCLUDE_DIR) +cmake_policy(POP) diff --git a/Modules/FindTclsh.cmake b/Modules/FindTclsh.cmake index 5555d59..594d0ec 100644 --- a/Modules/FindTclsh.cmake +++ b/Modules/FindTclsh.cmake @@ -15,15 +15,8 @@ library is. This code sets the following variables: TCLSH_FOUND = TRUE if tclsh has been found TCL_TCLSH = the path to the tclsh executable - -In cygwin, look for the cygwin version first. Don't look for it later -to avoid finding the cygwin version on a Win32 build. #]=======================================================================] -if(CYGWIN) - find_program(TCL_TCLSH NAMES cygtclsh83 cygtclsh80) -endif() - get_filename_component(TK_WISH_PATH "${TK_WISH}" PATH) get_filename_component(TK_WISH_PATH_PARENT "${TK_WISH_PATH}" PATH) string(REGEX REPLACE diff --git a/Modules/FindVulkan.cmake b/Modules/FindVulkan.cmake index 4b999b6..0ec6013 100644 --- a/Modules/FindVulkan.cmake +++ b/Modules/FindVulkan.cmake @@ -5,6 +5,8 @@ FindVulkan ---------- +.. versionadded:: 3.7 + Find Vulkan, which is a low-overhead, cross-platform 3D graphics and computing API. @@ -14,6 +16,9 @@ IMPORTED Targets This module defines :prop_tgt:`IMPORTED` target ``Vulkan::Vulkan``, if Vulkan has been found. +This module defines :prop_tgt:`IMPORTED` target ``Vulkan::glslc``, if +Vulkan and the GLSLC SPIR-V compiler has been found. + Result Variables ^^^^^^^^^^^^^^^^ @@ -23,10 +28,11 @@ This module defines the following variables:: Vulkan_INCLUDE_DIRS - include directories for Vulkan Vulkan_LIBRARIES - link against this library to use Vulkan -The module will also define two cache variables:: +The module will also define three cache variables:: - Vulkan_INCLUDE_DIR - the Vulkan include directory - Vulkan_LIBRARY - the path to the Vulkan library + Vulkan_INCLUDE_DIR - the Vulkan include directory + Vulkan_LIBRARY - the path to the Vulkan library + Vulkan_GLSLC_EXECUTABLE - the path to the GLSL SPIR-V compiler Hints ^^^^^ @@ -53,6 +59,11 @@ if(WIN32) "$ENV{VULKAN_SDK}/Lib" "$ENV{VULKAN_SDK}/Bin" ) + find_program(Vulkan_GLSLC_EXECUTABLE + NAMES glslc + HINTS + "$ENV{VULKAN_SDK}/Bin" + ) elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) find_library(Vulkan_LIBRARY NAMES vulkan-1 @@ -60,6 +71,11 @@ if(WIN32) "$ENV{VULKAN_SDK}/Lib32" "$ENV{VULKAN_SDK}/Bin32" ) + find_program(Vulkan_GLSLC_EXECUTABLE + NAMES glslc + HINTS + "$ENV{VULKAN_SDK}/Bin32" + ) endif() else() find_path(Vulkan_INCLUDE_DIR @@ -68,6 +84,9 @@ else() find_library(Vulkan_LIBRARY NAMES vulkan HINTS "$ENV{VULKAN_SDK}/lib") + find_program(Vulkan_GLSLC_EXECUTABLE + NAMES glslc + HINTS "$ENV{VULKAN_SDK}/bin") endif() set(Vulkan_LIBRARIES ${Vulkan_LIBRARY}) @@ -78,7 +97,7 @@ find_package_handle_standard_args(Vulkan DEFAULT_MSG Vulkan_LIBRARY Vulkan_INCLUDE_DIR) -mark_as_advanced(Vulkan_INCLUDE_DIR Vulkan_LIBRARY) +mark_as_advanced(Vulkan_INCLUDE_DIR Vulkan_LIBRARY Vulkan_GLSLC_EXECUTABLE) if(Vulkan_FOUND AND NOT TARGET Vulkan::Vulkan) add_library(Vulkan::Vulkan UNKNOWN IMPORTED) @@ -86,3 +105,8 @@ if(Vulkan_FOUND AND NOT TARGET Vulkan::Vulkan) IMPORTED_LOCATION "${Vulkan_LIBRARIES}" INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") endif() + +if(Vulkan_FOUND AND Vulkan_GLSLC_EXECUTABLE AND NOT TARGET Vulkan::glslc) + add_executable(Vulkan::glslc IMPORTED) + set_property(TARGET Vulkan::glslc PROPERTY IMPORTED_LOCATION "${Vulkan_GLSLC_EXECUTABLE}") +endif() diff --git a/Modules/FindX11.cmake b/Modules/FindX11.cmake index ccd0252..a865597 100644 --- a/Modules/FindX11.cmake +++ b/Modules/FindX11.cmake @@ -28,6 +28,8 @@ and also the following more fine grained variables and targets: X11_xcb_INCLUDE_PATH, X11_xcb_LIB, X11_xcb_FOUND, X11::xcb X11_X11_xcb_INCLUDE_PATH, X11_X11_xcb_LIB, X11_X11_xcb_FOUND, X11::X11_xcb X11_xcb_icccm_INCLUDE_PATH, X11_xcb_icccm_LIB, X11_xcb_icccm_FOUND, X11::xcb_icccm + X11_xcb_util_INCLUDE_PATH, X11_xcb_util_LIB, X11_xcb_util_FOUND, X11::xcb_util + X11_xcb_xfixes_INCLUDE_PATH, X11_xcb_xfixes_LIB, X11_xcb_xfixes_FOUND, X11::xcb_xfixes X11_xcb_xkb_INCLUDE_PATH, X11_xcb_xkb_LIB, X11_xcb_xkb_FOUND, X11::xcb_xkb X11_Xcomposite_INCLUDE_PATH, X11_Xcomposite_LIB, X11_Xcomposite_FOUND, X11::Xcomposite X11_Xcursor_INCLUDE_PATH, X11_Xcursor_LIB, X11_Xcursor_FOUND, X11::Xcursor @@ -59,6 +61,7 @@ and also the following more fine grained variables and targets: X11_XShm_INCLUDE_PATH, (in X11_Xext_LIB), X11_XShm_FOUND X11_Xshape_INCLUDE_PATH, (in X11_Xext_LIB), X11_Xshape_FOUND X11_XSync_INCLUDE_PATH, (in X11_Xext_LIB), X11_XSync_FOUND + X11_Xaw_INCLUDE_PATH, X11_Xaw_LIB X11_Xaw_FOUND X11::Xaw #]=======================================================================] if (UNIX) @@ -100,9 +103,12 @@ if (UNIX) find_path(X11_Xaccessrules_INCLUDE_PATH X11/extensions/XKBrules.h ${X11_INC_SEARCH_PATH}) find_path(X11_Xaccessstr_INCLUDE_PATH X11/extensions/XKBstr.h ${X11_INC_SEARCH_PATH}) find_path(X11_Xau_INCLUDE_PATH X11/Xauth.h ${X11_INC_SEARCH_PATH}) + find_path(X11_Xaw_INCLUDE_PATH X11/Xaw/Intrinsic.h ${X11_INC_SEARCH_PATH}) find_path(X11_xcb_INCLUDE_PATH xcb/xcb.h ${X11_INC_SEARCH_PATH}) find_path(X11_X11_xcb_INCLUDE_PATH X11/Xlib-xcb.h ${X11_INC_SEARCH_PATH}) find_path(X11_xcb_icccm_INCLUDE_PATH xcb/xcb_icccm.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_util_INCLUDE_PATH xcb/xcb_aux.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_xfixes_INCLUDE_PATH xcb/xfixes.h ${X11_INC_SEARCH_PATH}) find_path(X11_Xcomposite_INCLUDE_PATH X11/extensions/Xcomposite.h ${X11_INC_SEARCH_PATH}) find_path(X11_Xcursor_INCLUDE_PATH X11/Xcursor/Xcursor.h ${X11_INC_SEARCH_PATH}) find_path(X11_Xdamage_INCLUDE_PATH X11/extensions/Xdamage.h ${X11_INC_SEARCH_PATH}) @@ -134,6 +140,8 @@ if (UNIX) find_path(X11_Xv_INCLUDE_PATH X11/extensions/Xvlib.h ${X11_INC_SEARCH_PATH}) find_path(X11_XSync_INCLUDE_PATH X11/extensions/sync.h ${X11_INC_SEARCH_PATH}) + + # Backwards compatibility. set(X11_Xinput_INCLUDE_PATH "${X11_Xi_INCLUDE_PATH}") set(X11_xf86misc_INCLUDE_PATH "${X11_Xxf86misc_INCLUDE_PATH}") @@ -148,9 +156,12 @@ if (UNIX) find_library(X11_ICE_LIB ICE ${X11_LIB_SEARCH_PATH}) find_library(X11_SM_LIB SM ${X11_LIB_SEARCH_PATH}) find_library(X11_Xau_LIB Xau ${X11_LIB_SEARCH_PATH}) + find_library(X11_Xaw_LIB Xaw ${X11_LIB_SEARCH_PATH}) find_library(X11_xcb_LIB xcb ${X11_LIB_SEARCH_PATH}) find_library(X11_X11_xcb_LIB X11-xcb ${X11_LIB_SEARCH_PATH}) find_library(X11_xcb_icccm_LIB xcb-icccm ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_util_LIB xcb-util ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_xfixes_LIB xcb-xfixes ${X11_LIB_SEARCH_PATH}) find_library(X11_xcb_xkb_LIB xcb-xkb ${X11_LIB_SEARCH_PATH}) find_library(X11_Xcomposite_LIB Xcomposite ${X11_LIB_SEARCH_PATH}) find_library(X11_Xcursor_LIB Xcursor ${X11_LIB_SEARCH_PATH}) @@ -250,6 +261,14 @@ if (UNIX) set(X11_xcb_icccm_FOUND TRUE) endif () + if (X11_xcb_util_LIB AND X11_xcb_util_INCLUDE_PATH) + set(X11_xcb_util_FOUND TRUE) + endif () + + if (X11_xcb_xfixes_LIB) + set(X11_xcb_xfixes_FOUND TRUE) + endif () + if (X11_xcb_xkb_LIB) set(X11_xcb_xkb_FOUND TRUE) endif () @@ -392,6 +411,10 @@ if (UNIX) set(X11_SM_FOUND TRUE) endif() + if(X11_Xaw_LIB AND X11_Xaw_INCLUDE_PATH) + set(X11_Xaw_FOUND TRUE) + endif() + # Most of the X11 headers will be in the same directories, avoid # creating a huge list of duplicates. if (X11_INCLUDE_DIR) @@ -527,6 +550,14 @@ if (UNIX) INTERFACE_INCLUDE_DIRECTORIES "${X11_Xau_INCLUDE_PATH}") endif () + if (X11_Xaw_FOUND AND NOT TARGET X11::Xaw) + add_library(X11::Xaw UNKNOWN IMPORTED) + set_target_properties(X11::Xaw PROPERTIES + IMPORTED_LOCATION "${X11_Xaw_LIB}" + INTERFACE_INCLUDE_DIRECTORIES "${X11_Xaw_INCLUDE_PATH}" + INTERFACE_LINK_LIBRARIES "X11::Xext;X11::Xmu;X11::Xt;X11::Xpm;X11::X11") + endif () + if (X11_xcb_FOUND AND NOT TARGET X11::xcb) add_library(X11::xcb UNKNOWN IMPORTED) set_target_properties(X11::xcb PROPERTIES @@ -549,6 +580,20 @@ if (UNIX) INTERFACE_LINK_LIBRARIES "X11::xcb") endif () + if (X11_xcb_util_FOUND AND NOT TARGET X11::xcb_util) + add_library(X11::xcb_util UNKNOWN IMPORTED) + set_target_properties(X11::xcb_util PROPERTIES + IMPORTED_LOCATION "${X11_xcb_util_LIB}" + INTERFACE_LINK_LIBRARIES "X11::xcb") + endif () + + if (X11_xcb_xfixes_FOUND AND NOT TARGET X11::xcb_xfixes) + add_library(X11::xcb_xfixes UNKNOWN IMPORTED) + set_target_properties(X11::xcb_xfixes PROPERTIES + IMPORTED_LOCATION "${X11_xcb_xfixes_LIB}" + INTERFACE_LINK_LIBRARIES "X11::xcb") + endif () + if (X11_xcb_xkb_FOUND AND NOT TARGET X11::xcb_xkb) add_library(X11::xcb_xkb UNKNOWN IMPORTED) set_target_properties(X11::xcb_xkb PROPERTIES @@ -825,6 +870,8 @@ if (UNIX) X11_SM_LIB X11_SM_INCLUDE_PATH X11_XSync_INCLUDE_PATH + X11_Xaw_LIB + X11_Xaw_INCLUDE_PATH ) set(CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK_SAVE}) set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE}) diff --git a/Modules/FindXCTest.cmake b/Modules/FindXCTest.cmake index 15721e1..1f6e825 100644 --- a/Modules/FindXCTest.cmake +++ b/Modules/FindXCTest.cmake @@ -5,6 +5,8 @@ FindXCTest ---------- +.. versionadded:: 3.3 + Functions to help creating and executing XCTest bundles. An XCTest bundle is a CFBundle with a special product-type diff --git a/Modules/FindXalanC.cmake b/Modules/FindXalanC.cmake index 54783e3..a7fb766 100644 --- a/Modules/FindXalanC.cmake +++ b/Modules/FindXalanC.cmake @@ -5,6 +5,8 @@ FindXalanC ----------- +.. versionadded:: 3.5 + Find the Apache Xalan-C++ XSL transform processor headers and libraries. Imported targets diff --git a/Modules/FindXercesC.cmake b/Modules/FindXercesC.cmake index db78b61..abe18c0 100644 --- a/Modules/FindXercesC.cmake +++ b/Modules/FindXercesC.cmake @@ -5,6 +5,8 @@ FindXercesC ----------- +.. versionadded:: 3.1 + Find the Apache Xerces-C++ validating XML parser headers and libraries. Imported targets diff --git a/Modules/FindwxWindows.cmake b/Modules/FindwxWindows.cmake index 35840f5..07fbc1b 100644 --- a/Modules/FindwxWindows.cmake +++ b/Modules/FindwxWindows.cmake @@ -307,7 +307,7 @@ if(WIN32_STYLE_FIND) else () ## WX is built as multiple small pieces libraries instead of monolithic - ## DEPECATED (jw) replaced by more general WXWINDOWS_USE_MONOLITHIC ON/OFF + ## DEPRECATED (jw) replaced by more general WXWINDOWS_USE_MONOLITHIC ON/OFF # option(WXWINDOWS_SEPARATE_LIBS_BUILD "Is wxWindows build with separate libs?" OFF) ## HACK: This is very dirty. diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake index 5c8c196..c99c772 100644 --- a/Modules/GetPrerequisites.cmake +++ b/Modules/GetPrerequisites.cmake @@ -61,7 +61,7 @@ is the name of a CMake variable to contain the results. exclude "system" prerequisites. If <recurse> is set to 1 all prerequisites will be found recursively, if set to 0 only direct prerequisites are listed. <exepath> is the path to the top level -executable used for @executable_path replacment on the Mac. <dirs> is +executable used for @executable_path replacement on the Mac. <dirs> is a list of paths where libraries might be found: these paths are searched first when a target without any path info is given. Then standard system locations are also searched: PATH, Framework diff --git a/Modules/GoogleTest.cmake b/Modules/GoogleTest.cmake index b210a77..057b29d 100644 --- a/Modules/GoogleTest.cmake +++ b/Modules/GoogleTest.cmake @@ -5,6 +5,8 @@ GoogleTest ---------- +.. versionadded:: 3.9 + This module defines functions to help use the Google Test infrastructure. Two mechanisms for adding tests are provided. :command:`gtest_add_tests` has been around for some time, originally via ``find_package(GTest)``. @@ -493,7 +495,7 @@ function(gtest_discover_tests TARGET) string(CONCAT ctest_include_content "if(EXISTS \"$<TARGET_FILE:${TARGET}>\")" "\n" " if(\"$<TARGET_FILE:${TARGET}>\" IS_NEWER_THAN \"${ctest_tests_file}\")" "\n" - " include(GoogleTestAddTests)" "\n" + " include(\"${_GOOGLETEST_DISCOVER_TESTS_SCRIPT}\")" "\n" " gtest_discover_tests_impl(" "\n" " TEST_EXECUTABLE" " [==[" "$<TARGET_FILE:${TARGET}>" "]==]" "\n" " TEST_EXECUTOR" " [==[" "${crosscompiling_emulator}" "]==]" "\n" diff --git a/Modules/Internal/CPack/CPackDeb.cmake b/Modules/Internal/CPack/CPackDeb.cmake index db35e3a..431b074 100644 --- a/Modules/Internal/CPack/CPackDeb.cmake +++ b/Modules/Internal/CPack/CPackDeb.cmake @@ -547,8 +547,8 @@ function(cpack_deb_prepare_package_vars) message(FATAL_ERROR _description_failure_message) endif() - # Ok, description has set. According to the `Debian Policy Manual`_ the frist - # line is a pacakge summary. Try to get it as well... + # Ok, description has set. According to the `Debian Policy Manual`_ the first + # line is a package summary. Try to get it as well... # See also: https://www.debian.org/doc/debian-policy/ch-controlfields.html#description elseif(CPACK_PACKAGE_DESCRIPTION_SUMMARY AND NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY STREQUAL CPACK_DEFAULT_PACKAGE_DESCRIPTION_SUMMARY) diff --git a/Modules/Internal/CPack/WIX.template.in b/Modules/Internal/CPack/WIX.template.in index c4fc83a..c0bf935 100644 --- a/Modules/Internal/CPack/WIX.template.in +++ b/Modules/Internal/CPack/WIX.template.in @@ -2,7 +2,7 @@ <?include "cpack_variables.wxi"?> -<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" +<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" @CPACK_WIX_CUSTOM_XMLNS_EXPANDED@ RequiredVersion="3.6.3303.0"> <Product Id="$(var.CPACK_WIX_PRODUCT_GUID)" diff --git a/Modules/Platform/Android-Clang.cmake b/Modules/Platform/Android-Clang.cmake index 759448b..160eada 100644 --- a/Modules/Platform/Android-Clang.cmake +++ b/Modules/Platform/Android-Clang.cmake @@ -53,4 +53,7 @@ macro(__android_compiler_clang lang) endif() list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "--target=${CMAKE_${lang}_COMPILER_TARGET}") endif() + if(CMAKE_GENERATOR MATCHES "Visual Studio") + set(_ANDROID_STL_NOSTDLIBXX 1) + endif() endmacro() diff --git a/Modules/Platform/Android-Determine.cmake b/Modules/Platform/Android-Determine.cmake index 2225897..11a0504 100644 --- a/Modules/Platform/Android-Determine.cmake +++ b/Modules/Platform/Android-Determine.cmake @@ -7,8 +7,8 @@ # Support for NVIDIA Nsight Tegra Visual Studio Edition was previously # implemented in the CMake VS IDE generators. Avoid interfering with -# that functionality for now. Later we may try to integrate this. -if(CMAKE_GENERATOR MATCHES "Visual Studio") +# that functionality for now. +if(CMAKE_GENERATOR_PLATFORM STREQUAL "Tegra-Android") return() endif() @@ -27,6 +27,63 @@ endif() cmake_policy(PUSH) cmake_policy(SET CMP0057 NEW) # if IN_LIST +# If using Android tools for Visual Studio, compile a sample project to get the +# sysroot. +if(CMAKE_GENERATOR MATCHES "Visual Studio") + if(NOT CMAKE_SYSROOT) + set(vcx_platform ${CMAKE_GENERATOR_PLATFORM}) + if(CMAKE_GENERATOR MATCHES "Visual Studio 1[45]") + set(vcx_sysroot_var "Sysroot") + else() + set(vcx_sysroot_var "SysrootLink") + endif() + if(CMAKE_GENERATOR MATCHES "Visual Studio 14") + set(vcx_revision "2.0") + elseif(CMAKE_GENERATOR MATCHES "Visual Studio 1[56]") + set(vcx_revision "3.0") + else() + set(vcx_revision "") + endif() + configure_file(${CMAKE_ROOT}/Modules/Platform/Android/VCXProjInspect.vcxproj.in + ${CMAKE_PLATFORM_INFO_DIR}/VCXProjInspect.vcxproj @ONLY) + execute_process( + COMMAND "${CMAKE_VS_MSBUILD_COMMAND}" "VCXProjInspect.vcxproj" + "/p:Configuration=Debug" "/p:Platform=${vcx_platform}" + WORKING_DIRECTORY ${CMAKE_PLATFORM_INFO_DIR} + OUTPUT_VARIABLE VCXPROJ_INSPECT_OUTPUT + ERROR_VARIABLE VCXPROJ_INSPECT_OUTPUT + RESULT_VARIABLE VCXPROJ_INSPECT_RESULT + ) + if(NOT CMAKE_SYSROOT AND VCXPROJ_INSPECT_OUTPUT MATCHES "CMAKE_SYSROOT=([^%\r\n]+)[\r\n]") + # Strip VS diagnostic output from the end of the line. + string(REGEX REPLACE " \\(TaskId:[0-9]*\\)$" "" _sysroot "${CMAKE_MATCH_1}") + if(EXISTS "${_sysroot}") + file(TO_CMAKE_PATH "${_sysroot}" CMAKE_SYSROOT) + endif() + endif() + if(VCXPROJ_INSPECT_RESULT) + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining the sysroot for the Android NDK failed. +The output was: +${VCXPROJ_INSPECT_RESULT} +${VCXPROJ_INSPECT_OUTPUT} + +") + else() + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining the sysroot for the Android NDK succeeded. +The output was: +${VCXPROJ_INSPECT_RESULT} +${VCXPROJ_INSPECT_OUTPUT} + +") + endif() + endif() + if(NOT CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION) + set(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION "clang") + endif() +endif() + # If the user provided CMAKE_SYSROOT for us, extract information from it. set(_ANDROID_SYSROOT_NDK "") set(_ANDROID_SYSROOT_API "") diff --git a/Modules/Platform/Android-Initialize.cmake b/Modules/Platform/Android-Initialize.cmake index b90dd7a..5019c28 100644 --- a/Modules/Platform/Android-Initialize.cmake +++ b/Modules/Platform/Android-Initialize.cmake @@ -6,7 +6,7 @@ # Support for NVIDIA Nsight Tegra Visual Studio Edition was previously # implemented in the CMake VS IDE generators. Avoid interfering with -# that functionality for now. Later we may try to integrate this. +# that functionality for now. if(CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android") return() endif() diff --git a/Modules/Platform/Android/Determine-Compiler-NDK.cmake b/Modules/Platform/Android/Determine-Compiler-NDK.cmake index f56e1d5..a4d67c4 100644 --- a/Modules/Platform/Android/Determine-Compiler-NDK.cmake +++ b/Modules/Platform/Android/Determine-Compiler-NDK.cmake @@ -184,7 +184,7 @@ foreach(line IN LISTS _ANDROID_TOOL_SETUP) # We just matched the gcc toolchain name without version number. Save it for later. set(_ANDROID_TOOL_NAME_ONLY "${CMAKE_MATCH_1}") elseif(line MATCHES [[^TOOLCHAIN_PREFIX +:= +.*/bin/(\$\(TOOLCHAIN_NAME\)-) *$]]) - # We just matched the toolchain prefix with a name placholder, so substitute it. + # We just matched the toolchain prefix with a name placeholder, so substitute it. # The gcc toolchain name will have already been extracted without version number from a TOOLCHAIN_NAME line. string(REPLACE "$(TOOLCHAIN_NAME)" "${_ANDROID_TOOL_NAME_ONLY}" _ANDROID_TOOL_PREFIX "${CMAKE_MATCH_1}") elseif(line MATCHES [[^LLVM_VERSION +:= +([0-9.]+)$]]) diff --git a/Modules/Platform/Android/VCXProjInspect.vcxproj.in b/Modules/Platform/Android/VCXProjInspect.vcxproj.in new file mode 100644 index 0000000..6919d2c --- /dev/null +++ b/Modules/Platform/Android/VCXProjInspect.vcxproj.in @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|@vcx_platform@"> + <Configuration>Debug</Configuration> + <Platform>@vcx_platform@</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{14D44772-ECF7-47BD-9E29-BC62FAF940A5}</ProjectGuid> + <RootNamespace>VCXProjInspect</RootNamespace> + <Keyword>Android</Keyword> + <ApplicationType>Android</ApplicationType> + <ApplicationTypeRevision>@vcx_revision@</ApplicationTypeRevision> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@vcx_platform@'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <PropertyGroup> + <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|@vcx_platform@'">false</LinkIncremental> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@vcx_platform@'"> + <PostBuildEvent> + <Command>%40echo CMAKE_SYSROOT=$(@vcx_sysroot_var@)</Command> + </PostBuildEvent> + </ItemDefinitionGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project> diff --git a/Modules/Platform/Darwin-Initialize.cmake b/Modules/Platform/Darwin-Initialize.cmake index 80e9a40..d087412 100644 --- a/Modules/Platform/Darwin-Initialize.cmake +++ b/Modules/Platform/Darwin-Initialize.cmake @@ -62,45 +62,36 @@ elseif("${CMAKE_GENERATOR}" MATCHES Xcode # Find installed SDKs in either Xcode-4.3+ or pre-4.3 SDKs directory. set(_CMAKE_OSX_SDKS_DIR "") if(OSX_DEVELOPER_ROOT) - foreach(d Platforms/MacOSX.platform/Developer/SDKs SDKs) - file(GLOB _CMAKE_OSX_SDKS ${OSX_DEVELOPER_ROOT}/${d}/*) + foreach(_d Platforms/MacOSX.platform/Developer/SDKs SDKs) + file(GLOB _CMAKE_OSX_SDKS ${OSX_DEVELOPER_ROOT}/${_d}/*) if(_CMAKE_OSX_SDKS) - set(_CMAKE_OSX_SDKS_DIR ${OSX_DEVELOPER_ROOT}/${d}) + set(_CMAKE_OSX_SDKS_DIR ${OSX_DEVELOPER_ROOT}/${_d}) break() endif() endforeach() endif() if(_CMAKE_OSX_SDKS_DIR) - # Select SDK for current OSX version accounting for the known - # specially named SDKs. - set(_CMAKE_OSX_SDKS_VER_SUFFIX_10.4 "u") - set(_CMAKE_OSX_SDKS_VER_SUFFIX_10.3 ".9") - - # find the latest SDK + # Find the latest SDK as recommended by Apple (Technical Q&A QA1806) set(_CMAKE_OSX_LATEST_SDK_VERSION "0.0") file(GLOB _CMAKE_OSX_SDKS RELATIVE "${_CMAKE_OSX_SDKS_DIR}" "${_CMAKE_OSX_SDKS_DIR}/MacOSX*.sdk") foreach(_SDK ${_CMAKE_OSX_SDKS}) - if(_SDK MATCHES "MacOSX([0-9]+\\.[0-9]+)[^/]*\\.sdk" AND CMAKE_MATCH_1 VERSION_GREATER ${_CMAKE_OSX_LATEST_SDK_VERSION}) + if(IS_DIRECTORY "${_CMAKE_OSX_SDKS_DIR}/${_SDK}" + AND _SDK MATCHES "MacOSX([0-9]+\\.[0-9]+)[^/]*\\.sdk" + AND CMAKE_MATCH_1 VERSION_GREATER ${_CMAKE_OSX_LATEST_SDK_VERSION}) set(_CMAKE_OSX_LATEST_SDK_VERSION "${CMAKE_MATCH_1}") endif() endforeach() - # pick an SDK that works - set(_CMAKE_OSX_SYSROOT_DEFAULT) - foreach(ver ${CMAKE_OSX_DEPLOYMENT_TARGET} - ${_CURRENT_OSX_VERSION} - ${_CMAKE_OSX_LATEST_SDK_VERSION}) - set(_CMAKE_OSX_DEPLOYMENT_TARGET ${ver}) - set(_CMAKE_OSX_SDKS_VER ${_CMAKE_OSX_DEPLOYMENT_TARGET}${_CMAKE_OSX_SDKS_VER_SUFFIX_${_CMAKE_OSX_DEPLOYMENT_TARGET}}) - set(_CMAKE_OSX_SYSROOT_CHECK "${_CMAKE_OSX_SDKS_DIR}/MacOSX${_CMAKE_OSX_SDKS_VER}.sdk") - if(IS_DIRECTORY "${_CMAKE_OSX_SYSROOT_CHECK}") - set(_CMAKE_OSX_SYSROOT_DEFAULT "${_CMAKE_OSX_SYSROOT_CHECK}") - break() - endif() - endforeach() + if(NOT _CMAKE_OSX_LATEST_SDK_VERSION STREQUAL "0.0") + set(_CMAKE_OSX_SYSROOT_DEFAULT "${_CMAKE_OSX_SDKS_DIR}/MacOSX${_CMAKE_OSX_LATEST_SDK_VERSION}.sdk") + else() + message(WARNING "Could not find any valid SDKs in ${_CMAKE_OSX_SDKS_DIR}") + endif() - if(NOT CMAKE_CROSSCOMPILING AND NOT CMAKE_OSX_DEPLOYMENT_TARGET AND _CURRENT_OSX_VERSION VERSION_LESS _CMAKE_OSX_DEPLOYMENT_TARGET) + if(NOT CMAKE_CROSSCOMPILING AND NOT CMAKE_OSX_DEPLOYMENT_TARGET + AND (_CURRENT_OSX_VERSION VERSION_LESS _CMAKE_OSX_LATEST_SDK_VERSION + OR _CMAKE_OSX_LATEST_SDK_VERSION STREQUAL "0.0")) set(CMAKE_OSX_DEPLOYMENT_TARGET ${_CURRENT_OSX_VERSION} CACHE STRING "Minimum OS X version to target for deployment (at runtime); newer APIs weak linked. Set to empty string for default value." FORCE) endif() @@ -113,8 +104,8 @@ endif() # Set cache variable - end user may change this during ccmake or cmake-gui configure. # Choose the type based on the current value. set(_CMAKE_OSX_SYSROOT_TYPE STRING) -foreach(v CMAKE_OSX_SYSROOT _CMAKE_OSX_SYSROOT_DEFAULT) - if("x${${v}}" MATCHES "/") +foreach(_v CMAKE_OSX_SYSROOT _CMAKE_OSX_SYSROOT_DEFAULT) + if("x${${_v}}" MATCHES "/") set(_CMAKE_OSX_SYSROOT_TYPE PATH) break() endif() diff --git a/Modules/Platform/HP-UX.cmake b/Modules/Platform/HP-UX.cmake index 9572a7e..425a13f 100644 --- a/Modules/Platform/HP-UX.cmake +++ b/Modules/Platform/HP-UX.cmake @@ -22,7 +22,7 @@ set(CMAKE_PLATFORM_USES_PATH_WHEN_NO_SONAME 1) # set flags for gcc support include(Platform/UnixPaths) -# Look in both 32-bit and 64-bit implict link directories, but tell +# Look in both 32-bit and 64-bit implicit link directories, but tell # CMake not to pass the paths to the linker. The linker will find the # library for the proper architecture. In the future we should detect # which path will be used by the linker. Since the pointer type size diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake index 995c635..7a75004 100644 --- a/Modules/Platform/Windows-Clang.cmake +++ b/Modules/Platform/Windows-Clang.cmake @@ -142,7 +142,7 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" endif() if(DEFINED CMAKE_RC_PREPROCESSOR) set(CMAKE_DEPFILE_FLAGS_RC "-clang:-MD -clang:-MF -clang:<DEPFILE>") - set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_COMMAND> -E cmake_llvm_rc <SOURCE> <OBJECT>.pp <${CMAKE_RC_PREPROCESSOR}> <DEFINES> -DRC_INVOKED <INCLUDES> <FLAGS> -E <SOURCE> -- <CMAKE_RC_COMPILER> <DEFINES> -I <SOURCE_DIR> <INCLUDES> /fo <OBJECT> <OBJECT>.pp") + set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_COMMAND> -E cmake_llvm_rc <SOURCE> <OBJECT>.pp <${CMAKE_RC_PREPROCESSOR}> <DEFINES> -DRC_INVOKED <INCLUDES> <FLAGS> -E -- <SOURCE> ++ <CMAKE_RC_COMPILER> <DEFINES> -I <SOURCE_DIR> <INCLUDES> /fo <OBJECT> <OBJECT>.pp") if(CMAKE_GENERATOR STREQUAL "Ninja") set(CMAKE_NINJA_CMCLDEPS_RC 0) set(CMAKE_NINJA_DEP_TYPE_RC gcc) diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index 2476a33..173ef40 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -333,6 +333,14 @@ macro(__windows_compiler_msvc lang) set(CMAKE_LINK_PCH ON) if (CMAKE_${lang}_COMPILER_ID STREQUAL "Clang") set(CMAKE_PCH_PROLOGUE "#pragma clang system_header") + + # macOS paths usually start with /Users/*. Unfortunately, clang-cl interprets + # paths starting with /U as macro undefines, so we need to put a -- before the + # input file path to force it to be treated as a path. + string(REPLACE "-c <SOURCE>" "-c -- <SOURCE>" CMAKE_${lang}_COMPILE_OBJECT "${CMAKE_${lang}_COMPILE_OBJECT}") + string(REPLACE "-c <SOURCE>" "-c -- <SOURCE>" CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "${CMAKE_${lang}_COMPILE_OBJECT}") + string(REPLACE "-c <SOURCE>" "-c -- <SOURCE>" CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "${CMAKE_${lang}_COMPILE_OBJECT}") + elseif(MSVC_VERSION GREATER_EQUAL 1913) # At least MSVC toolet 14.13 from VS 2017 15.6 set(CMAKE_PCH_PROLOGUE "#pragma system_header") @@ -356,6 +364,11 @@ macro(__windows_compiler_msvc lang) set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES) set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES) + if(CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.4.0) + set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "-target ") + else() + set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "--target=") + endif() # '-flto=thin' available since Clang 3.9 and Xcode 8 # * http://clang.llvm.org/docs/ThinLTO.html#clang-llvm # * https://trac.macports.org/wiki/XcodeVersionInfo diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index a60e05e..b75eb5e 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -83,7 +83,7 @@ Defines the following command for use with ``SWIG``: ``SOURCES`` List of sources for the library. Files with extension ``.i`` will be identified as sources for the ``SWIG`` tool. Other files will be handled in - the standard way. This behavior can be overriden by specifying the variable + the standard way. This behavior can be overridden by specifying the variable ``SWIG_SOURCE_FILE_EXTENSIONS``. .. note:: diff --git a/Modules/UseSWIG/ManageSupportFiles.cmake b/Modules/UseSWIG/ManageSupportFiles.cmake index 4a03900..6618fd5 100644 --- a/Modules/UseSWIG/ManageSupportFiles.cmake +++ b/Modules/UseSWIG/ManageSupportFiles.cmake @@ -4,7 +4,7 @@ if (ACTION STREQUAL "CLEAN") # Collect current list of generated files - file (GLOB files LIST_DIRECTORIES FALSE RELATIVE "${SUPPORT_FILES_WORKING_DIRECTORY}" "${SUPPORT_FILES_WORKING_DIRECTORY}/*") + file (GLOB_RECURSE files LIST_DIRECTORIES TRUE RELATIVE "${SUPPORT_FILES_WORKING_DIRECTORY}" "${SUPPORT_FILES_WORKING_DIRECTORY}/*") if (files) # clean-up the output directory @@ -22,7 +22,7 @@ endif() if (ACTION STREQUAL "COPY") # Collect current list of generated files - file (GLOB files LIST_DIRECTORIES FALSE "${SUPPORT_FILES_WORKING_DIRECTORY}/*") + file (GLOB files LIST_DIRECTORIES TRUE "${SUPPORT_FILES_WORKING_DIRECTORY}/*") if (files) # copy files to the output directory diff --git a/Modules/WriteCompilerDetectionHeader.cmake b/Modules/WriteCompilerDetectionHeader.cmake index 23d81b5..5100035 100644 --- a/Modules/WriteCompilerDetectionHeader.cmake +++ b/Modules/WriteCompilerDetectionHeader.cmake @@ -5,6 +5,8 @@ WriteCompilerDetectionHeader ---------------------------- +.. versionadded:: 3.1 + This module provides the function ``write_compiler_detection_header()``. This function can be used to generate a file suitable for preprocessor |