diff options
Diffstat (limited to 'Modules')
137 files changed, 2012 insertions, 835 deletions
diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in index f19bc97..2643326 100644 --- a/Modules/CMakeCXXCompilerId.cpp.in +++ b/Modules/CMakeCXXCompilerId.cpp.in @@ -82,6 +82,7 @@ int main(int argc, char* argv[]) int require = 0; require += info_compiler[argc]; require += info_platform[argc]; + require += info_arch[argc]; #ifdef COMPILER_VERSION_MAJOR require += info_version[argc]; #endif diff --git a/Modules/CMakeCompilerIdDetection.cmake b/Modules/CMakeCompilerIdDetection.cmake index f15974a..75d33e8 100644 --- a/Modules/CMakeCompilerIdDetection.cmake +++ b/Modules/CMakeCompilerIdDetection.cmake @@ -70,6 +70,7 @@ function(compiler_id_detection outvar lang) FujitsuClang Fujitsu GHS + Tasking ) if ("x${lang}" STREQUAL "xC") list(APPEND ordered_compilers diff --git a/Modules/CMakeDependentOption.cmake b/Modules/CMakeDependentOption.cmake index ac0e262..9a3c940 100644 --- a/Modules/CMakeDependentOption.cmake +++ b/Modules/CMakeDependentOption.cmake @@ -84,7 +84,7 @@ macro(CMAKE_DEPENDENT_OPTION option doc default depends force) else() set(${option} "${${option}_ISSET}") endif() - if("x${_CDO_CMP0127}x" STREQUAL "xx" AND "x${depends}x" MATCHES "[^A-Za-z0-9_; ]") + if("x${_CDO_CMP0127}x" STREQUAL "xx" AND "x${depends}x" MATCHES "[^A-Za-z0-9_.; ]") cmake_policy(GET_WARNING CMP0127 _CDO_CMP0127_WARNING) message(AUTHOR_WARNING "${_CDO_CMP0127_WARNING}") endif() diff --git a/Modules/CMakeDetermineCSharpCompiler.cmake b/Modules/CMakeDetermineCSharpCompiler.cmake index da860a8..fe98469 100644 --- a/Modules/CMakeDetermineCSharpCompiler.cmake +++ b/Modules/CMakeDetermineCSharpCompiler.cmake @@ -3,7 +3,7 @@ if(NOT ${CMAKE_GENERATOR} MATCHES "Visual Studio ([^9]|[9][0-9])") message(FATAL_ERROR - "C# is currently only supported for Microsoft Visual Studio 2010 and later.") + "C# is currently only supported for Microsoft Visual Studio 11 2012 and later.") endif() include(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake) diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake index 0ac06ac..f43b17b 100644 --- a/Modules/CMakeDetermineCUDACompiler.cmake +++ b/Modules/CMakeDetermineCUDACompiler.cmake @@ -275,7 +275,7 @@ if(NOT CMAKE_CUDA_COMPILER_ID_RUN) if(DEFINED CMAKE_CUDA_ARCHITECTURES) if(CMAKE_CUDA_ARCHITECTURES STREQUAL "") message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES must be non-empty if set.") - elseif(CMAKE_CUDA_ARCHITECTURES AND NOT CMAKE_CUDA_ARCHITECTURES MATCHES "^([0-9]+(-real|-virtual)?(;[0-9]+(-real|-virtual)?|;)*|all|all-major|native)$") + elseif(CMAKE_CUDA_ARCHITECTURES AND NOT CMAKE_CUDA_ARCHITECTURES MATCHES "^([0-9]+a?(-real|-virtual)?(;[0-9]+a?(-real|-virtual)?|;)*|all|all-major|native)$") message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES:\n" " ${CMAKE_CUDA_ARCHITECTURES}\n" @@ -503,7 +503,8 @@ elseif(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA") CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES CMAKE_CUDA_HOST_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES log - "${CMAKE_CUDA_IMPLICIT_OBJECT_REGEX}") + "${CMAKE_CUDA_IMPLICIT_OBJECT_REGEX}" + LANGUAGE CUDA) # Detect CMAKE_CUDA_RUNTIME_LIBRARY_DEFAULT from the compiler by looking at which # cudart library exists in the implicit link libraries passed to the host linker. diff --git a/Modules/CMakeDetermineCompileFeatures.cmake b/Modules/CMakeDetermineCompileFeatures.cmake index a08e597..09de7b1 100644 --- a/Modules/CMakeDetermineCompileFeatures.cmake +++ b/Modules/CMakeDetermineCompileFeatures.cmake @@ -63,6 +63,7 @@ function(cmake_determine_compile_features lang) set(CMAKE_CXX17_COMPILE_FEATURES) set(CMAKE_CXX20_COMPILE_FEATURES) set(CMAKE_CXX23_COMPILE_FEATURES) + set(CMAKE_CXX26_COMPILE_FEATURES) include("${CMAKE_ROOT}/Modules/Internal/FeatureTesting.cmake") @@ -73,6 +74,9 @@ function(cmake_determine_compile_features lang) return() endif() + if (CMAKE_CXX23_COMPILE_FEATURES AND CMAKE_CXX26_COMPILE_FEATURES) + list(REMOVE_ITEM CMAKE_CXX26_COMPILE_FEATURES ${CMAKE_CXX23_COMPILE_FEATURES}) + endif() if (CMAKE_CXX20_COMPILE_FEATURES AND CMAKE_CXX23_COMPILE_FEATURES) list(REMOVE_ITEM CMAKE_CXX23_COMPILE_FEATURES ${CMAKE_CXX20_COMPILE_FEATURES}) endif() @@ -97,6 +101,7 @@ function(cmake_determine_compile_features lang) ${CMAKE_CXX17_COMPILE_FEATURES} ${CMAKE_CXX20_COMPILE_FEATURES} ${CMAKE_CXX23_COMPILE_FEATURES} + ${CMAKE_CXX26_COMPILE_FEATURES} ) endif() @@ -107,6 +112,7 @@ function(cmake_determine_compile_features lang) set(CMAKE_CXX17_COMPILE_FEATURES ${CMAKE_CXX17_COMPILE_FEATURES} PARENT_SCOPE) set(CMAKE_CXX20_COMPILE_FEATURES ${CMAKE_CXX20_COMPILE_FEATURES} PARENT_SCOPE) set(CMAKE_CXX23_COMPILE_FEATURES ${CMAKE_CXX23_COMPILE_FEATURES} PARENT_SCOPE) + set(CMAKE_CXX26_COMPILE_FEATURES ${CMAKE_CXX26_COMPILE_FEATURES} PARENT_SCOPE) message(CHECK_PASS "done") @@ -119,6 +125,7 @@ function(cmake_determine_compile_features lang) set(CMAKE_CUDA17_COMPILE_FEATURES) set(CMAKE_CUDA20_COMPILE_FEATURES) set(CMAKE_CUDA23_COMPILE_FEATURES) + set(CMAKE_CUDA26_COMPILE_FEATURES) include("${CMAKE_ROOT}/Modules/Internal/FeatureTesting.cmake") @@ -129,6 +136,9 @@ function(cmake_determine_compile_features lang) return() endif() + if (CMAKE_CUDA23_COMPILE_FEATURES AND CMAKE_CUDA26_COMPILE_FEATURES) + list(REMOVE_ITEM CMAKE_CUDA26_COMPILE_FEATURES ${CMAKE_CUDA23_COMPILE_FEATURES}) + endif() if (CMAKE_CUDA20_COMPILE_FEATURES AND CMAKE_CUDA23_COMPILE_FEATURES) list(REMOVE_ITEM CMAKE_CUDA23_COMPILE_FEATURES ${CMAKE_CUDA20_COMPILE_FEATURES}) endif() @@ -153,6 +163,7 @@ function(cmake_determine_compile_features lang) ${CMAKE_CUDA17_COMPILE_FEATURES} ${CMAKE_CUDA20_COMPILE_FEATURES} ${CMAKE_CUDA23_COMPILE_FEATURES} + ${CMAKE_CUDA26_COMPILE_FEATURES} ) endif() @@ -163,6 +174,7 @@ function(cmake_determine_compile_features lang) set(CMAKE_CUDA17_COMPILE_FEATURES ${CMAKE_CUDA17_COMPILE_FEATURES} PARENT_SCOPE) set(CMAKE_CUDA20_COMPILE_FEATURES ${CMAKE_CUDA20_COMPILE_FEATURES} PARENT_SCOPE) set(CMAKE_CUDA23_COMPILE_FEATURES ${CMAKE_CUDA23_COMPILE_FEATURES} PARENT_SCOPE) + set(CMAKE_CUDA26_COMPILE_FEATURES ${CMAKE_CUDA26_COMPILE_FEATURES} PARENT_SCOPE) message(CHECK_PASS "done") @@ -175,6 +187,8 @@ function(cmake_determine_compile_features lang) set(CMAKE_HIP17_COMPILE_FEATURES) set(CMAKE_HIP20_COMPILE_FEATURES) set(CMAKE_HIP23_COMPILE_FEATURES) + set(CMAKE_HIP26_COMPILE_FEATURES) + include("${CMAKE_ROOT}/Modules/Internal/FeatureTesting.cmake") @@ -185,6 +199,9 @@ function(cmake_determine_compile_features lang) return() endif() + if (CMAKE_HIP23_COMPILE_FEATURES AND CMAKE_HIP26_COMPILE_FEATURES) + list(REMOVE_ITEM CMAKE_HIP26_COMPILE_FEATURES ${CMAKE_HIP23_COMPILE_FEATURES}) + endif() if (CMAKE_HIP20_COMPILE_FEATURES AND CMAKE_HIP23_COMPILE_FEATURES) list(REMOVE_ITEM CMAKE_HIP23_COMPILE_FEATURES ${CMAKE_HIP20_COMPILE_FEATURES}) endif() @@ -209,6 +226,7 @@ function(cmake_determine_compile_features lang) ${CMAKE_HIP17_COMPILE_FEATURES} ${CMAKE_HIP20_COMPILE_FEATURES} ${CMAKE_HIP23_COMPILE_FEATURES} + ${CMAKE_HIP26_COMPILE_FEATURES} ) endif() @@ -219,6 +237,7 @@ function(cmake_determine_compile_features lang) set(CMAKE_HIP17_COMPILE_FEATURES ${CMAKE_HIP17_COMPILE_FEATURES} PARENT_SCOPE) set(CMAKE_HIP20_COMPILE_FEATURES ${CMAKE_HIP20_COMPILE_FEATURES} PARENT_SCOPE) set(CMAKE_HIP23_COMPILE_FEATURES ${CMAKE_HIP23_COMPILE_FEATURES} PARENT_SCOPE) + set(CMAKE_HIP26_COMPILE_FEATURES ${CMAKE_HIP26_COMPILE_FEATURES} PARENT_SCOPE) message(CHECK_PASS "done") diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index 82a6d21..053effa 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -55,7 +55,7 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) set(ENV{LANG} C) try_compile(CMAKE_${lang}_ABI_COMPILED - ${CMAKE_BINARY_DIR} ${src} + SOURCES ${src} CMAKE_FLAGS ${CMAKE_FLAGS} # Ignore unused flags when we are just determining the ABI. "--no-warn-unused-cli" @@ -149,7 +149,8 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) if(CMAKE_${lang}_VERBOSE_FLAG) CMAKE_PARSE_IMPLICIT_LINK_INFO("${OUTPUT}" implicit_libs implicit_dirs implicit_fwks log "${CMAKE_${lang}_IMPLICIT_OBJECT_REGEX}" - COMPUTE_IMPLICIT_OBJECTS implicit_objs) + COMPUTE_IMPLICIT_OBJECTS implicit_objs + LANGUAGE ${lang}) file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Parsed ${lang} implicit link information from above output:\n${log}\n\n") endif() @@ -161,8 +162,9 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) message(CHECK_START "Determine Intel Fortran Compiler Implicit Link Path") # Build a sample project which reports symbols. try_compile(IFORT_LIB_PATH_COMPILED - ${CMAKE_BINARY_DIR}/CMakeFiles/IntelVSImplicitPath - ${CMAKE_ROOT}/Modules/IntelVSImplicitPath + PROJECT IntelFortranImplicit + SOURCE_DIR ${CMAKE_ROOT}/Modules/IntelVSImplicitPath + BINARY_DIR ${CMAKE_BINARY_DIR}/CMakeFiles/IntelVSImplicitPath IntelFortranImplicit CMAKE_FLAGS "-DCMAKE_Fortran_FLAGS:STRING=${CMAKE_Fortran_FLAGS}" diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 2b19736..6b58549 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -720,7 +720,7 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} OR CMAKE_${lang}_COMPILER_ID_OUTPUT MATCHES "warning #5117: Bad # preprocessor line" ) # Compilation failed. - set(MSG + string(APPEND _CMAKE_DETERMINE_COMPILER_ID_BUILD_MSG "Compiling the ${lang} compiler identification source file \"${src}\" failed. ${COMPILER_DESCRIPTION} The output was: @@ -736,7 +736,11 @@ ${CMAKE_${lang}_COMPILER_ID_OUTPUT} # Some languages may know the correct/desired set of flags and want to fail right away if they don't work. # This is currently only used by CUDA. if(__compiler_id_require_success) - message(FATAL_ERROR "${MSG}") + message(FATAL_ERROR "${_CMAKE_DETERMINE_COMPILER_ID_BUILD_MSG}") + else() + # Build up the outputs for compiler detection attempts so that users + # can see all set of flags tried, instead of just last + set(_CMAKE_DETERMINE_COMPILER_ID_BUILD_MSG "${_CMAKE_DETERMINE_COMPILER_ID_BUILD_MSG}" PARENT_SCOPE) endif() # No output files should be inspected. diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake index 650c87a..087c0f6 100644 --- a/Modules/CMakeDetermineFortranCompiler.cmake +++ b/Modules/CMakeDetermineFortranCompiler.cmake @@ -44,17 +44,14 @@ else() # finally list compilers to try if(NOT CMAKE_Fortran_COMPILER_INIT) # Known compilers: - # f77/f90/f95: generic compiler names # ftn: Cray fortran compiler wrapper - # g77: GNU Fortran 77 compiler # gfortran: putative GNU Fortran 95+ compiler (in progress) - # fort77: native F77 compiler under HP-UX (and some older Crays) - # frt: Fujitsu F77 compiler + # frt: Fujitsu Fortran compiler # pathf90/pathf95/pathf2003: PathScale Fortran compiler - # pgf77/pgf90/pgf95/pgfortran: Portland Group F77/F90/F95 compilers + # pgfortran: Portland Group Fortran compilers # nvfortran: NVHPC Fotran compiler # flang: Flang Fortran compiler - # xlf/xlf90/xlf95: IBM (AIX) F77/F90/F95 compilers + # xlf: IBM (AIX) Fortran compiler # lf95: Lahey-Fujitsu F95 compiler # fl32: Microsoft Fortran 77 "PowerStation" compiler # af77: Apogee F77 compiler for Intergraph hardware running CLIX @@ -62,31 +59,20 @@ else() # fort: Compaq (now HP) Fortran 90/95 compiler for Tru64 and Linux/Alpha # ifx: Intel Fortran LLVM-based compiler # ifort: Intel Classic Fortran compiler - # ifc: Intel Fortran 95 compiler for Linux/x86 - # efc: Intel Fortran 95 compiler for IA64 # nagfor: NAG Fortran compiler # - # The order is 95 or newer compilers first, then 90, - # then 77 or older compilers, gnu is always last in the group, + # GNU is last to be searched, # so if you paid for a compiler it is picked by default. - if(CMAKE_HOST_WIN32) - set(CMAKE_Fortran_COMPILER_LIST - ifort ifx pgf95 pgfortran nvfortran lf95 fort - flang gfortran gfortran-4 g95 f90 pgf90 - pgf77 g77 f77 nag - ) - else() - set(CMAKE_Fortran_COMPILER_LIST - ftn - ifort ifc ifx efc pgf95 pgfortran nvfortran lf95 xlf95 fort - flang lfortran gfortran gfortran-4 g95 f90 pgf90 - frt pgf77 xlf g77 f77 nag - ) - endif() + set(CMAKE_Fortran_COMPILER_LIST + ftn + ifx ifort nvfortran pgfortran lf95 xlf fort + flang lfortran frt nagfor + gfortran + ) # Vendor-specific compiler names. set(_Fortran_COMPILER_NAMES_LCC lfortran gfortran) - set(_Fortran_COMPILER_NAMES_GNU gfortran gfortran-4 g95 g77) + set(_Fortran_COMPILER_NAMES_GNU gfortran) set(_Fortran_COMPILER_NAMES_Intel ifort ifc efc ifx) set(_Fortran_COMPILER_NAMES_Absoft af95 af90 af77) set(_Fortran_COMPILER_NAMES_PGI pgf95 pgfortran pgf90 pgf77) diff --git a/Modules/CMakeDetermineHIPCompiler.cmake b/Modules/CMakeDetermineHIPCompiler.cmake index 7b7d7a3..6294d04 100644 --- a/Modules/CMakeDetermineHIPCompiler.cmake +++ b/Modules/CMakeDetermineHIPCompiler.cmake @@ -86,6 +86,7 @@ if(NOT CMAKE_HIP_COMPILER_ROCM_ROOT AND CMAKE_HIP_COMPILER_ID STREQUAL "Clang") if(_CMAKE_HIP_COMPILER_RESULT EQUAL 0 AND _CMAKE_HIP_COMPILER_STDERR MATCHES "Found HIP installation: *([^,]*)[,\n]") set(CMAKE_HIP_COMPILER_ROCM_ROOT "${CMAKE_MATCH_1}") + file(TO_CMAKE_PATH "${CMAKE_HIP_COMPILER_ROCM_ROOT}" CMAKE_HIP_COMPILER_ROCM_ROOT) endif() endif() if(NOT CMAKE_HIP_COMPILER_ROCM_ROOT) diff --git a/Modules/CMakeDetermineVSServicePack.cmake b/Modules/CMakeDetermineVSServicePack.cmake index 53868d2..0d360b5 100644 --- a/Modules/CMakeDetermineVSServicePack.cmake +++ b/Modules/CMakeDetermineVSServicePack.cmake @@ -105,8 +105,7 @@ function(_DetermineVSServicePack_CheckVersionWithTryCompile _SUCCESS_VAR _VERSI try_compile( _CompileResult - "${CMAKE_BINARY_DIR}" - "${CMAKE_BINARY_DIR}/return0.cc" + SOURCES "${CMAKE_BINARY_DIR}/return0.cc" OUTPUT_VARIABLE _output COPY_FILE "${CMAKE_BINARY_DIR}/return0.cc") @@ -128,8 +127,7 @@ function(_DetermineVSServicePack_CheckVersionWithTryRun _SUCCESS_VAR _VERSION_V try_run( _RunResult _CompileResult - "${CMAKE_BINARY_DIR}" - "${CMAKE_BINARY_DIR}/return0.cc" + SOURCES "${CMAKE_BINARY_DIR}/return0.cc" RUN_OUTPUT_VARIABLE _runoutput ) diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index a6bd0d1..2ac8879 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -170,7 +170,7 @@ else() if("${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL Clang) if("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC") list(PREPEND _CMAKE_LINKER_NAMES "lld-link") - else() + elseif(NOT APPLE) list(PREPEND _CMAKE_LINKER_NAMES "ld.lld") endif() if(APPLE) diff --git a/Modules/CMakeFindFrameworks.cmake b/Modules/CMakeFindFrameworks.cmake index 8906f48..1aa3929 100644 --- a/Modules/CMakeFindFrameworks.cmake +++ b/Modules/CMakeFindFrameworks.cmake @@ -17,12 +17,19 @@ if(NOT CMAKE_FIND_FRAMEWORKS_INCLUDED) macro(CMAKE_FIND_FRAMEWORKS fwk) set(${fwk}_FRAMEWORKS) if(APPLE) + # 'Frameworks' directory from Brew (Apple Silicon and Intel) + if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64") + set(_brew_framework_path /opt/homebrew/Frameworks) + else() + set(_brew_framework_path /usr/local/Frameworks) + endif() + file(TO_CMAKE_PATH "$ENV{CMAKE_FRAMEWORK_PATH}" _cmff_CMAKE_FRAMEWORK_PATH) set(_cmff_search_paths ${CMAKE_FRAMEWORK_PATH} ${_cmff_CMAKE_FRAMEWORK_PATH} ~/Library/Frameworks - /usr/local/Frameworks + ${_brew_framework_path} /Library/Frameworks /System/Library/Frameworks /Network/Library/Frameworks diff --git a/Modules/CMakeHIPInformation.cmake b/Modules/CMakeHIPInformation.cmake index 4c57677..33f8697 100644 --- a/Modules/CMakeHIPInformation.cmake +++ b/Modules/CMakeHIPInformation.cmake @@ -143,7 +143,7 @@ set(CMAKE_HIP_INFORMATION_LOADED 1) # Load the file and find the relevant HIP runtime. if(NOT DEFINED _CMAKE_HIP_DEVICE_RUNTIME_TARGET) set(hip-lang_DIR "${CMAKE_HIP_COMPILER_ROCM_ROOT}/lib/cmake/hip-lang") - find_package(hip-lang CONFIG QUIET NO_DEFAULT_PATH) + find_package(hip-lang CONFIG QUIET NO_DEFAULT_PATH REQUIRED) endif() if(DEFINED _CMAKE_HIP_DEVICE_RUNTIME_TARGET) list(APPEND CMAKE_HIP_RUNTIME_LIBRARIES_STATIC ${_CMAKE_HIP_DEVICE_RUNTIME_TARGET}) diff --git a/Modules/CMakeParseImplicitLinkInfo.cmake b/Modules/CMakeParseImplicitLinkInfo.cmake index 6bdefde..1773dc4 100644 --- a/Modules/CMakeParseImplicitLinkInfo.cmake +++ b/Modules/CMakeParseImplicitLinkInfo.cmake @@ -22,7 +22,7 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj set(log "") set(keywordArgs) - set(oneValueArgs COMPUTE_IMPLICIT_OBJECTS) + set(oneValueArgs COMPUTE_IMPLICIT_OBJECTS LANGUAGE) set(multiValueArgs ) cmake_parse_arguments(EXTRA_PARSE "${keywordArgs}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) @@ -76,6 +76,11 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj endif() endif() set(is_msvc 0) + if(EXTRA_PARSE_LANGUAGE AND + ("x${CMAKE_${EXTRA_PARSE_LANGUAGE}_ID}" STREQUAL "xMSVC" OR + "x${CMAKE_${EXTRA_PARSE_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC")) + set(is_msvc 1) + endif() set(search_static 0) if("${cmd}" MATCHES "${linker_regex}") string(APPEND log " link line: [${line}]\n") diff --git a/Modules/CMakePlatformId.h.in b/Modules/CMakePlatformId.h.in index 06f5ecd..32b7166 100644 --- a/Modules/CMakePlatformId.h.in +++ b/Modules/CMakePlatformId.h.in @@ -242,6 +242,30 @@ # elif defined(__ADSPBLACKFIN__) # define ARCHITECTURE_ID "Blackfin" +#elif defined(__TASKING__) + +# if defined(__CTC__) || defined(__CPTC__) +# define ARCHITECTURE_ID "TriCore" + +# elif defined(__CMCS__) +# define ARCHITECTURE_ID "MCS" + +# elif defined(__CARM__) +# define ARCHITECTURE_ID "ARM" + +# elif defined(__CARC__) +# define ARCHITECTURE_ID "ARC" + +# elif defined(__C51__) +# define ARCHITECTURE_ID "8051" + +# elif defined(__CPCP__) +# define ARCHITECTURE_ID "PCP" + +# else +# define ARCHITECTURE_ID "" +# endif + #else # define ARCHITECTURE_ID #endif diff --git a/Modules/CMakeSwiftInformation.cmake b/Modules/CMakeSwiftInformation.cmake index ecad1d5..a0cd9da 100644 --- a/Modules/CMakeSwiftInformation.cmake +++ b/Modules/CMakeSwiftInformation.cmake @@ -65,10 +65,22 @@ set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -libc MD) set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -libc MTd) set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -libc MDd) -set(CMAKE_Swift_FLAGS_DEBUG_INIT "-g") -set(CMAKE_Swift_FLAGS_RELEASE_INIT "-O") -set(CMAKE_Swift_FLAGS_RELWITHDEBINFO_INIT "-O -g") -set(CMAKE_Swift_FLAGS_MINSIZEREL_INIT "-Osize") +if(CMAKE_GENERATOR STREQUAL "Xcode") + # Xcode has a separate Xcode project option (SWIFT_COMPILATION_MODE) used to set + # whether compiling with whole-module optimizations or incrementally. Setting + # these options here will have no effect when compiling with the built-in driver, + # and will explode violently, leaving build products in the source directory, when + # using the old swift driver. + set(CMAKE_Swift_FLAGS_DEBUG_INIT "-Onone -g") + set(CMAKE_Swift_FLAGS_RELEASE_INIT "-O") + set(CMAKE_Swift_FLAGS_RELWITHDEBINFO_INIT "-O -g") + set(CMAKE_Swift_FLAGS_MINSIZEREL_INIT "-Osize") +else() + set(CMAKE_Swift_FLAGS_DEBUG_INIT "-Onone -g -incremental") + set(CMAKE_Swift_FLAGS_RELEASE_INIT "-O -wmo") + set(CMAKE_Swift_FLAGS_RELWITHDEBINFO_INIT "-O -g -wmo") + set(CMAKE_Swift_FLAGS_MINSIZEREL_INIT "-Osize -wmo") +endif() if(CMAKE_EXECUTABLE_FORMAT STREQUAL "ELF") if(NOT DEFINED CMAKE_Swift_LINK_WHAT_YOU_USE_FLAG) @@ -91,7 +103,7 @@ if(NOT CMAKE_Swift_NUM_THREADS MATCHES "^[0-9]+$") endif() if(NOT CMAKE_Swift_CREATE_SHARED_LIBRARY) - set(CMAKE_Swift_CREATE_SHARED_LIBRARY "<CMAKE_Swift_COMPILER> -output-file-map <SWIFT_OUTPUT_FILE_MAP> -incremental -j ${CMAKE_Swift_NUM_THREADS} -emit-library -o <TARGET> -module-name <SWIFT_MODULE_NAME> -module-link-name <SWIFT_LIBRARY_NAME> -emit-module -emit-module-path <SWIFT_MODULE> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> <SONAME_FLAG> <TARGET_INSTALLNAME_DIR><TARGET_SONAME> ${CMAKE_Swift_IMPLIB_LINKER_FLAGS} <LINK_LIBRARIES>") + set(CMAKE_Swift_CREATE_SHARED_LIBRARY "<CMAKE_Swift_COMPILER> -output-file-map <SWIFT_OUTPUT_FILE_MAP> -j ${CMAKE_Swift_NUM_THREADS} -num-threads ${CMAKE_Swift_NUM_THREADS} -emit-library -o <TARGET> -module-name <SWIFT_MODULE_NAME> -module-link-name <SWIFT_LIBRARY_NAME> -emit-module -emit-module-path <SWIFT_MODULE> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> <SONAME_FLAG> <TARGET_INSTALLNAME_DIR><TARGET_SONAME> ${CMAKE_Swift_IMPLIB_LINKER_FLAGS} <LINK_LIBRARIES>") endif() if(NOT CMAKE_Swift_CREATE_SHARED_MODULE) @@ -99,11 +111,11 @@ if(NOT CMAKE_Swift_CREATE_SHARED_MODULE) endif() if(NOT CMAKE_Swift_LINK_EXECUTABLE) - set(CMAKE_Swift_LINK_EXECUTABLE "<CMAKE_Swift_COMPILER> -output-file-map <SWIFT_OUTPUT_FILE_MAP> -incremental -j ${CMAKE_Swift_NUM_THREADS} -emit-executable -o <TARGET> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> <LINK_LIBRARIES>") + set(CMAKE_Swift_LINK_EXECUTABLE "<CMAKE_Swift_COMPILER> -output-file-map <SWIFT_OUTPUT_FILE_MAP> -j ${CMAKE_Swift_NUM_THREADS} -num-threads ${CMAKE_Swift_NUM_THREADS} -emit-executable -o <TARGET> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> <LINK_LIBRARIES>") endif() if(NOT CMAKE_Swift_CREATE_STATIC_LIBRARY) - set(CMAKE_Swift_CREATE_STATIC_LIBRARY "<CMAKE_Swift_COMPILER> -output-file-map <SWIFT_OUTPUT_FILE_MAP> -incremental -j ${CMAKE_Swift_NUM_THREADS} -emit-library -static -o <TARGET> -module-name <SWIFT_MODULE_NAME> -module-link-name <SWIFT_LIBRARY_NAME> -emit-module -emit-module-path <SWIFT_MODULE> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> <LINK_LIBRARIES>") + set(CMAKE_Swift_CREATE_STATIC_LIBRARY "<CMAKE_Swift_COMPILER> -output-file-map <SWIFT_OUTPUT_FILE_MAP> -j ${CMAKE_Swift_NUM_THREADS} -num-threads ${CMAKE_Swift_NUM_THREADS} -emit-library -static -o <TARGET> -module-name <SWIFT_MODULE_NAME> -module-link-name <SWIFT_LIBRARY_NAME> -emit-module -emit-module-path <SWIFT_MODULE> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> <LINK_LIBRARIES>") set(CMAKE_Swift_ARCHIVE_CREATE "<CMAKE_AR> crs <TARGET> <OBJECTS>") set(CMAKE_Swift_ARCHIVE_FINISH "") diff --git a/Modules/CMakeSystemSpecificInformation.cmake b/Modules/CMakeSystemSpecificInformation.cmake index e045932..b5dc8d3 100644 --- a/Modules/CMakeSystemSpecificInformation.cmake +++ b/Modules/CMakeSystemSpecificInformation.cmake @@ -16,6 +16,8 @@ set(UNIX ) set(CYGWIN ) set(MSYS ) set(WIN32 ) +set(BSD ) +set(LINUX ) function(_cmake_record_install_prefix ) set(_CMAKE_SYSTEM_PREFIX_PATH_INSTALL_PREFIX_VALUE "${CMAKE_INSTALL_PREFIX}" PARENT_SCOPE) diff --git a/Modules/CMakeTestCCompiler.cmake b/Modules/CMakeTestCCompiler.cmake index ae5aa27..a706767 100644 --- a/Modules/CMakeTestCCompiler.cmake +++ b/Modules/CMakeTestCCompiler.cmake @@ -38,7 +38,7 @@ endif() if(NOT CMAKE_C_COMPILER_WORKS) PrintTestCompilerStatus("C") __TestCompiler_setTryCompileTargetType() - file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler.c + string(CONCAT __TestCompiler_testCCompilerSource "#ifdef __cplusplus\n" "# error \"The CMAKE_C_COMPILER is set to a C++ compiler\"\n" "#endif\n" @@ -53,9 +53,10 @@ if(NOT CMAKE_C_COMPILER_WORKS) # Clear result from normal variable. unset(CMAKE_C_COMPILER_WORKS) # Puts test result in cache variable. - try_compile(CMAKE_C_COMPILER_WORKS ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler.c + try_compile(CMAKE_C_COMPILER_WORKS + SOURCE_FROM_VAR testCCompiler.c __TestCompiler_testCCompilerSource OUTPUT_VARIABLE __CMAKE_C_COMPILER_OUTPUT) + unset(__TestCompiler_testCCompilerSource) # Move result from cache to normal variable. set(CMAKE_C_COMPILER_WORKS ${CMAKE_C_COMPILER_WORKS}) unset(CMAKE_C_COMPILER_WORKS CACHE) diff --git a/Modules/CMakeTestCSharpCompiler.cmake b/Modules/CMakeTestCSharpCompiler.cmake index adea250..1c9e249 100644 --- a/Modules/CMakeTestCSharpCompiler.cmake +++ b/Modules/CMakeTestCSharpCompiler.cmake @@ -12,8 +12,6 @@ include(CMakeTestCompilerCommon) unset(CMAKE_CSharp_COMPILER_WORKS CACHE) -set(test_compile_file "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCSharpCompiler.cs") - # This file is used by EnableLanguage in cmGlobalGenerator to # determine that the selected C# compiler can actually compile # and link the most basic of programs. If not, a fatal error @@ -23,19 +21,21 @@ if(NOT CMAKE_CSharp_COMPILER_WORKS) # Don't call PrintTestCompilerStatus() because the "C#" we want to pass # as the LANG doesn't match with the variable name "CMAKE_CSharp_COMPILER" message(CHECK_START "Check for working C# compiler: ${CMAKE_CSharp_COMPILER}") - file(WRITE "${test_compile_file}" - "namespace Test {" - " public class CSharp {" - " static void Main(string[] args) {}" - " }" - "}" + string(CONCAT __TestCompiler_testCSharpCompilerSource + "namespace Test {\n" + " public class CSharp {\n" + " static void Main(string[] args) {}\n" + " }\n" + "}\n" ) # Clear result from normal variable. unset(CMAKE_CSharp_COMPILER_WORKS) # Puts test result in cache variable. - try_compile(CMAKE_CSharp_COMPILER_WORKS ${CMAKE_BINARY_DIR} "${test_compile_file}" + try_compile(CMAKE_CSharp_COMPILER_WORKS + SOURCE_FROM_VAR testCSharpCompiler.cs __TestCompiler_testCSharpCompilerSource OUTPUT_VARIABLE __CMAKE_CSharp_COMPILER_OUTPUT ) + unset(__TestCompiler_testCSharpCompilerSource) # Move result from cache to normal variable. set(CMAKE_CSharp_COMPILER_WORKS ${CMAKE_CSharp_COMPILER_WORKS}) unset(CMAKE_CSharp_COMPILER_WORKS CACHE) diff --git a/Modules/CMakeTestCUDACompiler.cmake b/Modules/CMakeTestCUDACompiler.cmake index 853d655..f2fa6ea 100644 --- a/Modules/CMakeTestCUDACompiler.cmake +++ b/Modules/CMakeTestCUDACompiler.cmake @@ -76,7 +76,7 @@ endif() # any makefiles or projects. if(NOT CMAKE_CUDA_COMPILER_WORKS) PrintTestCompilerStatus("CUDA") - file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/main.cu + string(CONCAT __TestCompiler_testCudaCompilerSource "#ifndef __CUDACC__\n" "# error \"The CMAKE_CUDA_COMPILER is set to an invalid CUDA compiler\"\n" "#endif\n" @@ -86,9 +86,10 @@ if(NOT CMAKE_CUDA_COMPILER_WORKS) unset(CMAKE_CUDA_COMPILER_WORKS) # Puts test result in cache variable. - try_compile(CMAKE_CUDA_COMPILER_WORKS ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/main.cu + try_compile(CMAKE_CUDA_COMPILER_WORKS + SOURCE_FROM_VAR main.cu __TestCompiler_testCudaCompilerSource OUTPUT_VARIABLE __CMAKE_CUDA_COMPILER_OUTPUT) + unset(__TestCompiler_testCudaCompilerSource) # Move result from cache to normal variable. set(CMAKE_CUDA_COMPILER_WORKS ${CMAKE_CUDA_COMPILER_WORKS}) diff --git a/Modules/CMakeTestCXXCompiler.cmake b/Modules/CMakeTestCXXCompiler.cmake index bbe3533..fa4016a 100644 --- a/Modules/CMakeTestCXXCompiler.cmake +++ b/Modules/CMakeTestCXXCompiler.cmake @@ -38,7 +38,7 @@ endif() if(NOT CMAKE_CXX_COMPILER_WORKS) PrintTestCompilerStatus("CXX") __TestCompiler_setTryCompileTargetType() - file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCXXCompiler.cxx + string(CONCAT __TestCompiler_testCXXCompilerSource "#ifndef __cplusplus\n" "# error \"The CMAKE_CXX_COMPILER is set to a C compiler\"\n" "#endif\n" @@ -46,9 +46,10 @@ if(NOT CMAKE_CXX_COMPILER_WORKS) # Clear result from normal variable. unset(CMAKE_CXX_COMPILER_WORKS) # Puts test result in cache variable. - try_compile(CMAKE_CXX_COMPILER_WORKS ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCXXCompiler.cxx + try_compile(CMAKE_CXX_COMPILER_WORKS + SOURCE_FROM_VAR testCXXCompiler.cxx __TestCompiler_testCXXCompilerSource OUTPUT_VARIABLE __CMAKE_CXX_COMPILER_OUTPUT) + unset(__TestCompiler_testCXXCompilerSource) # Move result from cache to normal variable. set(CMAKE_CXX_COMPILER_WORKS ${CMAKE_CXX_COMPILER_WORKS}) unset(CMAKE_CXX_COMPILER_WORKS CACHE) @@ -56,7 +57,7 @@ if(NOT CMAKE_CXX_COMPILER_WORKS) if(NOT CMAKE_CXX_COMPILER_WORKS) PrintTestCompilerResult(CHECK_FAIL "broken") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining if the CXX compiler works failed with " + "Determining if the C++ compiler works failed with " "the following output:\n${__CMAKE_CXX_COMPILER_OUTPUT}\n\n") string(REPLACE "\n" "\n " _output "${__CMAKE_CXX_COMPILER_OUTPUT}") message(FATAL_ERROR "The C++ compiler\n \"${CMAKE_CXX_COMPILER}\"\n" @@ -66,7 +67,7 @@ if(NOT CMAKE_CXX_COMPILER_WORKS) endif() PrintTestCompilerResult(CHECK_PASS "works") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining if the CXX compiler works passed with " + "Determining if the C++ compiler works passed with " "the following output:\n${__CMAKE_CXX_COMPILER_OUTPUT}\n\n") endif() diff --git a/Modules/CMakeTestFortranCompiler.cmake b/Modules/CMakeTestFortranCompiler.cmake index 579f83f..e6d1f6d 100644 --- a/Modules/CMakeTestFortranCompiler.cmake +++ b/Modules/CMakeTestFortranCompiler.cmake @@ -38,7 +38,7 @@ endif() # any makefiles or projects. if(NOT CMAKE_Fortran_COMPILER_WORKS) PrintTestCompilerStatus("Fortran") - file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f " + set(__TestCompiler_testFortranCompilerSource " PROGRAM TESTFortran PRINT *, 'Hello' END @@ -46,9 +46,10 @@ if(NOT CMAKE_Fortran_COMPILER_WORKS) # Clear result from normal variable. unset(CMAKE_Fortran_COMPILER_WORKS) # Puts test result in cache variable. - try_compile(CMAKE_Fortran_COMPILER_WORKS ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f + try_compile(CMAKE_Fortran_COMPILER_WORKS + SOURCE_FROM_VAR testFortranCompiler.f __TestCompiler_testFortranCompilerSource OUTPUT_VARIABLE OUTPUT) + unset(__TestCompiler_testFortranCompilerSource) # Move result from cache to normal variable. set(CMAKE_Fortran_COMPILER_WORKS ${CMAKE_Fortran_COMPILER_WORKS}) unset(CMAKE_Fortran_COMPILER_WORKS CACHE) @@ -72,14 +73,15 @@ endif() # Test for Fortran 90 support by using an f90-specific construct. if(NOT DEFINED CMAKE_Fortran_COMPILER_SUPPORTS_F90) message(CHECK_START "Checking whether ${CMAKE_Fortran_COMPILER} supports Fortran 90") - file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompilerF90.f90 " + set(__TestCompiler_testFortranCompilerSource " PROGRAM TESTFortran90 integer stop ; stop = 1 ; do while ( stop .eq. 0 ) ; end do END PROGRAM TESTFortran90 ") - try_compile(CMAKE_Fortran_COMPILER_SUPPORTS_F90 ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompilerF90.f90 + try_compile(CMAKE_Fortran_COMPILER_SUPPORTS_F90 + SOURCE_FROM_VAR testFortranCompilerF90.f90 __TestCompiler_testFortranCompilerF90Source OUTPUT_VARIABLE OUTPUT) + unset(__TestCompiler_testFortranCompilerF90Source) if(CMAKE_Fortran_COMPILER_SUPPORTS_F90) message(CHECK_PASS "yes") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log diff --git a/Modules/CMakeTestHIPCompiler.cmake b/Modules/CMakeTestHIPCompiler.cmake index ecbfa7f..1da0ae4 100644 --- a/Modules/CMakeTestHIPCompiler.cmake +++ b/Modules/CMakeTestHIPCompiler.cmake @@ -41,7 +41,7 @@ endif() if(NOT CMAKE_HIP_COMPILER_WORKS) PrintTestCompilerStatus("HIP") __TestCompiler_setTryCompileTargetType() - file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testHIPCompiler.hip + string(CONCAT __TestCompiler_testHIPCompilerSource "#ifndef __HIP__\n" "# error \"The CMAKE_HIP_COMPILER is set to a C/CXX compiler\"\n" "#endif\n" @@ -49,9 +49,10 @@ if(NOT CMAKE_HIP_COMPILER_WORKS) # Clear result from normal variable. unset(CMAKE_HIP_COMPILER_WORKS) # Puts test result in cache variable. - try_compile(CMAKE_HIP_COMPILER_WORKS ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testHIPCompiler.hip + try_compile(CMAKE_HIP_COMPILER_WORKS + SOURCE_FROM_VAR testHIPCompiler.hip __TestCompiler_testHIPCompilerSource OUTPUT_VARIABLE __CMAKE_HIP_COMPILER_OUTPUT) + unset(__TestCompiler_testHIPCompilerSource) # Move result from cache to normal variable. set(CMAKE_HIP_COMPILER_WORKS ${CMAKE_HIP_COMPILER_WORKS}) unset(CMAKE_HIP_COMPILER_WORKS CACHE) diff --git a/Modules/CMakeTestOBJCCompiler.cmake b/Modules/CMakeTestOBJCCompiler.cmake index 20d1f8b..bbc90a7 100644 --- a/Modules/CMakeTestOBJCCompiler.cmake +++ b/Modules/CMakeTestOBJCCompiler.cmake @@ -38,7 +38,7 @@ endif() if(NOT CMAKE_OBJC_COMPILER_WORKS) PrintTestCompilerStatus("OBJC") __TestCompiler_setTryCompileTargetType() - file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testOBJCCompiler.m + string(CONCAT __TestCompiler_testObjCCompilerSource "#ifdef __cplusplus\n" "# error \"The CMAKE_OBJC_COMPILER is set to a C++ compiler\"\n" "#endif\n" @@ -50,9 +50,10 @@ if(NOT CMAKE_OBJC_COMPILER_WORKS) # Clear result from normal variable. unset(CMAKE_OBJC_COMPILER_WORKS) # Puts test result in cache variable. - try_compile(CMAKE_OBJC_COMPILER_WORKS ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testOBJCCompiler.m + try_compile(CMAKE_OBJC_COMPILER_WORKS + SOURCE_FROM_VAR testObjCCompiler.m __TestCompiler_testObjCCompilerSource OUTPUT_VARIABLE __CMAKE_OBJC_COMPILER_OUTPUT) + unset(__TestCompiler_testObjCCompilerSource) # Move result from cache to normal variable. set(CMAKE_OBJC_COMPILER_WORKS ${CMAKE_OBJC_COMPILER_WORKS}) unset(CMAKE_OBJC_COMPILER_WORKS CACHE) diff --git a/Modules/CMakeTestOBJCXXCompiler.cmake b/Modules/CMakeTestOBJCXXCompiler.cmake index 4f7185f..aceb939 100644 --- a/Modules/CMakeTestOBJCXXCompiler.cmake +++ b/Modules/CMakeTestOBJCXXCompiler.cmake @@ -38,7 +38,7 @@ endif() if(NOT CMAKE_OBJCXX_COMPILER_WORKS) PrintTestCompilerStatus("OBJCXX") __TestCompiler_setTryCompileTargetType() - file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testOBJCXXCompiler.mm + string(CONCAT __TestCompiler_testObjCXXCompilerSource "#ifndef __cplusplus\n" "# error \"The CMAKE_OBJCXX_COMPILER is set to a C compiler\"\n" "#endif\n" @@ -49,9 +49,10 @@ if(NOT CMAKE_OBJCXX_COMPILER_WORKS) # Clear result from normal variable. unset(CMAKE_OBJCXX_COMPILER_WORKS) # Puts test result in cache variable. - try_compile(CMAKE_OBJCXX_COMPILER_WORKS ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testOBJCXXCompiler.mm + try_compile(CMAKE_OBJCXX_COMPILER_WORKS + SOURCE_FROM_VAR testObjCXXCompiler.mm __TestCompiler_testObjCXXCompilerSource OUTPUT_VARIABLE __CMAKE_OBJCXX_COMPILER_OUTPUT) + unset(__TestCompiler_testObjCXXCompilerSource) # Move result from cache to normal variable. set(CMAKE_OBJCXX_COMPILER_WORKS ${CMAKE_OBJCXX_COMPILER_WORKS}) unset(CMAKE_OBJCXX_COMPILER_WORKS CACHE) diff --git a/Modules/CMakeTestSwiftCompiler.cmake b/Modules/CMakeTestSwiftCompiler.cmake index 2f2546f..88a864c 100644 --- a/Modules/CMakeTestSwiftCompiler.cmake +++ b/Modules/CMakeTestSwiftCompiler.cmake @@ -21,13 +21,12 @@ unset(CMAKE_Swift_COMPILER_WORKS CACHE) # any makefiles or projects. if(NOT CMAKE_Swift_COMPILER_WORKS) PrintTestCompilerStatus("Swift") - file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/main.swift - "print(\"CMake\")\n") # Clear result from normal variable. unset(CMAKE_Swift_COMPILER_WORKS) # Puts test result in cache variable. - try_compile(CMAKE_Swift_COMPILER_WORKS ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/main.swift + set(__CMAKE_Swift_TEST_SOURCE "print(\"CMake\")\n") + try_compile(CMAKE_Swift_COMPILER_WORKS + SOURCE_FROM_VAR main.swift __CMAKE_Swift_TEST_SOURCE OUTPUT_VARIABLE __CMAKE_Swift_COMPILER_OUTPUT) # Move result from cache to normal variable. set(CMAKE_Swift_COMPILER_WORKS ${CMAKE_Swift_COMPILER_WORKS}) @@ -64,4 +63,5 @@ else() include(${CMAKE_PLATFORM_INFO_DIR}/CMakeSwiftCompiler.cmake) endif() +unset(__CMAKE_Swift_TEST_SOURCE) unset(__CMAKE_Swift_COMPILER_OUTPUT) diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index 4934934..828d9ca 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -53,9 +53,9 @@ Here's how it works: * :manual:`cpack <cpack(1)>` runs * it includes ``CPackConfig.cmake`` -* it iterates over the generators given by the ``-G`` command line option, - or if no such option was specified, over the list of generators given by - the :variable:`CPACK_GENERATOR` variable set in the ``CPackConfig.cmake`` +* it iterates over the generators given by the :option:`-G <cpack -G>` command + line option, or if no such option was specified, over the list of generators + given by the :variable:`CPACK_GENERATOR` variable set in the ``CPackConfig.cmake`` input file. * foreach generator, it then @@ -246,9 +246,9 @@ installers. The most commonly-used variables are: List of CPack generators to use. If not specified, CPack will create a set of options following the naming pattern :variable:`CPACK_BINARY_<GENNAME>` (e.g. ``CPACK_BINARY_NSIS``) allowing - the user to enable/disable individual generators. If the ``-G`` option is - given on the :manual:`cpack <cpack(1)>` command line, it will override this - variable and any ``CPACK_BINARY_<GENNAME>`` options. + the user to enable/disable individual generators. If the :option:`-G <cpack -G>` + option is given on the :manual:`cpack <cpack(1)>` command line, it will override + this variable and any ``CPACK_BINARY_<GENNAME>`` options. .. variable:: CPACK_OUTPUT_CONFIG_FILE @@ -469,7 +469,35 @@ The following variables are for advanced uses of CPack: generates (when :variable:`CPACK_GENERATOR` is not set) a set of CMake options (see CMake :command:`option` command) which may then be used to select the CPack generator(s) to be used when building the ``package`` - target or when running :manual:`cpack <cpack(1)>` without the ``-G`` option. + target or when running :manual:`cpack <cpack(1)>` without the + :option:`-G <cpack -G>` option. + +.. variable:: CPACK_READELF_EXECUTABLE + + .. versionadded:: 3.25 + + Specify the ``readelf`` executable path used by CPack. + The default value will be ``CMAKE_READELF`` when set. Otherwise, + the default value will be empty and CPack will use :command:`find_program` + to determine the ``readelf`` path when needed. + +.. variable:: CPACK_OBJCOPY_EXECUTABLE + + .. versionadded:: 3.25 + + Specify the ``objcopy`` executable path used by CPack. + The default value will be ``CMAKE_OBJCOPY`` when set. Otherwise, + the default value will be empty and CPack will use :command:`find_program` + to determine the ``objcopy`` path when needed. + +.. variable:: CPACK_OBJDUMP_EXECUTABLE + + .. versionadded:: 3.25 + + Specify the ``objdump`` executable path used by CPack. + The default value will be ``CMAKE_OBJDUMP`` when set. Otherwise, + the default value will be empty and CPack will use :command:`find_program` + to determine the ``objdump`` path when needed. #]=======================================================================] @@ -590,6 +618,16 @@ _cpack_set_default(CPACK_RESOURCE_FILE_WELCOME _cpack_set_default(CPACK_MODULE_PATH "${CMAKE_MODULE_PATH}") +if(CMAKE_READELF) + _cpack_set_default(CPACK_READELF_EXECUTABLE "${CMAKE_READELF}") +endif() +if(CMAKE_OBJCOPY) + _cpack_set_default(CPACK_OBJCOPY_EXECUTABLE "${CMAKE_OBJCOPY}") +endif() +if(CMAKE_OBJDUMP) + _cpack_set_default(CPACK_OBJDUMP_EXECUTABLE "${CMAKE_OBJDUMP}") +endif() + # Set default directory creation permissions mode if(CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS) _cpack_set_default(CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS diff --git a/Modules/CPackIFW.cmake b/Modules/CPackIFW.cmake index a4bfe1d..efe6999 100644 --- a/Modules/CPackIFW.cmake +++ b/Modules/CPackIFW.cmake @@ -439,37 +439,55 @@ set(_CPACK_IFW_PREFIXES "QtIFW-") set(_CPACK_IFW_VERSIONS + "4.4.2" + "4.4.1" + "4.4.0" "4.4" + "4.3.0" "4.3" + "4.2.0" "4.2" + "4.1.1" + "4.1.0" "4.1" + "4.0.1" + "4.0.0" "4.0" - "3.2" + "3.2.3" + "3.2.2" + "3.2.1" "3.2.0" - "3.1" + "3.2" + "3.1.1" "3.1.0" - "3.0" + "3.1" + "3.0.6" + "3.0.4" + "3.0.3" + "3.0.2" + "3.0.1" "3.0.0" - "2.3" + "3.0" "2.3.0" - "2.2" + "2.3" "2.2.0" - "2.1" + "2.2" "2.1.0" - "2.0" + "2.1" "2.0.5" "2.0.3" "2.0.2" "2.0.1" "2.0.0" - "1.6" + "2.0" "1.6.0" - "1.5" + "1.6" "1.5.0" - "1.4" + "1.5" "1.4.0" - "1.3" - "1.3.0") + "1.4" + "1.3.0" + "1.3") set(_CPACK_IFW_SUFFIXES "bin") foreach(_CPACK_IFW_PREFIX ${_CPACK_IFW_PREFIXES}) diff --git a/Modules/CTestTargets.cmake b/Modules/CTestTargets.cmake index 838fbbf..b91b48e 100644 --- a/Modules/CTestTargets.cmake +++ b/Modules/CTestTargets.cmake @@ -86,7 +86,7 @@ if(NOT _CTEST_TARGETS_ADDED) # or "RUN_TESTS" target: if(CTEST_TEST_TARGET_ALIAS) add_custom_target(${CTEST_TEST_TARGET_ALIAS} - ${CMAKE_CTEST_COMMAND} ${__conf_types} + ${CMAKE_CTEST_COMMAND} ${CMAKE_CTEST_ARGUMENTS} ${__conf_types} USES_TERMINAL ) endif() diff --git a/Modules/CTestUseLaunchers.cmake b/Modules/CTestUseLaunchers.cmake index 23a206b..5c544f8 100644 --- a/Modules/CTestUseLaunchers.cmake +++ b/Modules/CTestUseLaunchers.cmake @@ -11,7 +11,7 @@ CTestUseLaunchers is automatically included when you include(CTest). However, it is split out into its own module file so projects can use the CTEST_USE_LAUNCHERS functionality independently. -To use launchers, set CTEST_USE_LAUNCHERS to ON in a ctest -S +To use launchers, set CTEST_USE_LAUNCHERS to ON in a :option:`ctest -S` dashboard script, and then also set it in the cache of the configured project. Both cmake and ctest need to know the value of it for the launchers to work properly. CMake needs to know in order to generate @@ -27,9 +27,12 @@ variable initialization only occurs if CTEST_USE_LAUNCHERS is not already defined. .. versionadded:: 3.8 - If CTEST_USE_LAUNCHERS is on in a ctest -S script + If CTEST_USE_LAUNCHERS is on in a :option:`ctest -S` script the ctest_configure command will add -DCTEST_USE_LAUNCHERS:BOOL=TRUE to the cmake command used to configure the project. + +.. TODO Use RST markup + #]=======================================================================] if(NOT DEFINED CTEST_USE_LAUNCHERS AND DEFINED ENV{CTEST_USE_LAUNCHERS_DEFAULT}) diff --git a/Modules/CheckCXXSymbolExists.cmake b/Modules/CheckCXXSymbolExists.cmake index 7b13c3a..1fa0898 100644 --- a/Modules/CheckCXXSymbolExists.cmake +++ b/Modules/CheckCXXSymbolExists.cmake @@ -74,5 +74,5 @@ include_guard(GLOBAL) include(CheckSymbolExists) macro(CHECK_CXX_SYMBOL_EXISTS SYMBOL FILES VARIABLE) - __CHECK_SYMBOL_EXISTS_IMPL("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.cxx" "${SYMBOL}" "${FILES}" "${VARIABLE}" ) + __CHECK_SYMBOL_EXISTS_IMPL(CheckSymbolExists.cxx "${SYMBOL}" "${FILES}" "${VARIABLE}" ) endmacro() diff --git a/Modules/CheckFortranFunctionExists.cmake b/Modules/CheckFortranFunctionExists.cmake index 8f1ca9d..7e3a7ee 100644 --- a/Modules/CheckFortranFunctionExists.cmake +++ b/Modules/CheckFortranFunctionExists.cmake @@ -58,8 +58,7 @@ macro(CHECK_FORTRAN_FUNCTION_EXISTS FUNCTION VARIABLE) else() set(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES) endif() - file(WRITE - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f + set(__CheckFunction_testFortranCompilerSource " program TESTFortran external ${FUNCTION} @@ -68,12 +67,12 @@ macro(CHECK_FORTRAN_FUNCTION_EXISTS FUNCTION VARIABLE) " ) try_compile(${VARIABLE} - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f + SOURCE_FROM_VAR testFortranCompiler.f __CheckFunction_testFortranCompilerSource ${CHECK_FUNCTION_EXISTS_ADD_LINK_OPTIONS} ${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES} OUTPUT_VARIABLE OUTPUT ) + unset(__CheckFunction_testFortranCompilerSource) if(${VARIABLE}) set(${VARIABLE} 1 CACHE INTERNAL "Have Fortran function ${FUNCTION}") message(CHECK_PASS "found") diff --git a/Modules/CheckFunctionExists.cmake b/Modules/CheckFunctionExists.cmake index 9efa132..60f0184 100644 --- a/Modules/CheckFunctionExists.cmake +++ b/Modules/CheckFunctionExists.cmake @@ -81,17 +81,15 @@ macro(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE) endif() if(CMAKE_C_COMPILER_LOADED) - set(_cfe_source ${CMAKE_ROOT}/Modules/CheckFunctionExists.c) + set(_cfe_source CheckFunctionExists.c) elseif(CMAKE_CXX_COMPILER_LOADED) - set(_cfe_source ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckFunctionExists/CheckFunctionExists.cxx) - configure_file(${CMAKE_ROOT}/Modules/CheckFunctionExists.c "${_cfe_source}" COPYONLY) + set(_cfe_source CheckFunctionExists.cxx) else() message(FATAL_ERROR "CHECK_FUNCTION_EXISTS needs either C or CXX language enabled") endif() try_compile(${VARIABLE} - ${CMAKE_BINARY_DIR} - ${_cfe_source} + SOURCE_FROM_FILE "${_cfe_source}" "${CMAKE_ROOT}/Modules/CheckFunctionExists.c" COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${CHECK_FUNCTION_EXISTS_ADD_LINK_OPTIONS} ${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES} diff --git a/Modules/CheckIPOSupported.cmake b/Modules/CheckIPOSupported.cmake index cca1be9..9108e34 100644 --- a/Modules/CheckIPOSupported.cmake +++ b/Modules/CheckIPOSupported.cmake @@ -76,6 +76,23 @@ endmacro() # Run IPO/LTO test macro(_ipo_run_language_check language) + set(_C_ext "c") + set(_CXX_ext "cpp") + set(_Fortran_ext "f") + string(COMPARE EQUAL "${language}" "CUDA" is_cuda) + + set(ext ${_${language}_ext}) + if(NOT "${ext}" STREQUAL "") + set(copy_sources foo.${ext} main.${ext}) + elseif(is_cuda) + if(_CMAKE_CUDA_IPO_SUPPORTED_BY_CMAKE) + set("${X_RESULT}" YES PARENT_SCOPE) + endif() + return() + else() + message(FATAL_ERROR "Language not supported") + endif() + set(testdir "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/_CMakeLTOTest-${language}") file(REMOVE_RECURSE "${testdir}") @@ -100,20 +117,6 @@ macro(_ipo_run_language_check language) @ONLY ) - string(COMPARE EQUAL "${language}" "C" is_c) - string(COMPARE EQUAL "${language}" "CXX" is_cxx) - string(COMPARE EQUAL "${language}" "Fortran" is_fortran) - - if(is_c) - set(copy_sources foo.c main.c) - elseif(is_cxx) - set(copy_sources foo.cpp main.cpp) - elseif(is_fortran) - set(copy_sources foo.f main.f) - else() - message(FATAL_ERROR "Language not supported") - endif() - foreach(x ${copy_sources}) configure_file( "${try_compile_src}/${x}" @@ -134,9 +137,9 @@ macro(_ipo_run_language_check language) try_compile( _IPO_LANGUAGE_CHECK_RESULT - "${bindir}" - "${srcdir}" - "${TRY_COMPILE_PROJECT_NAME}" + PROJECT "${TRY_COMPILE_PROJECT_NAME}" + SOURCE_DIR "${srcdir}" + BINARY_DIR "${bindir}" CMAKE_FLAGS "-DCMAKE_VERBOSE_MAKEFILE=ON" "-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON" @@ -214,6 +217,11 @@ function(check_ipo_supported) list(APPEND languages "C") endif() + list(FIND enabled_languages "CUDA" result) + if(NOT result EQUAL -1) + list(APPEND languages "CUDA") + endif() + list(FIND enabled_languages "Fortran" result) if(NOT result EQUAL -1) list(APPEND languages "Fortran") @@ -222,7 +230,7 @@ function(check_ipo_supported) string(COMPARE EQUAL "${languages}" "" no_languages) if(no_languages) _ipo_not_supported( - "no C/CXX/Fortran languages found in ENABLED_LANGUAGES global property" + "no C/CXX/CUDA/Fortran languages found in ENABLED_LANGUAGES global property" ) return() endif() @@ -230,7 +238,7 @@ function(check_ipo_supported) set(languages "${X_LANGUAGES}") set(unsupported_languages "${languages}") - list(REMOVE_ITEM unsupported_languages "C" "CXX" "Fortran") + list(REMOVE_ITEM unsupported_languages "C" "CXX" "CUDA" "Fortran") string(COMPARE NOTEQUAL "${unsupported_languages}" "" has_unsupported) if(has_unsupported) _ipo_not_supported( diff --git a/Modules/CheckIncludeFile.cmake b/Modules/CheckIncludeFile.cmake index 71ddde7..4cba91b 100644 --- a/Modules/CheckIncludeFile.cmake +++ b/Modules/CheckIncludeFile.cmake @@ -54,8 +54,8 @@ macro(CHECK_INCLUDE_FILE INCLUDE VARIABLE) endif() set(MACRO_CHECK_INCLUDE_FILE_FLAGS ${CMAKE_REQUIRED_FLAGS}) set(CHECK_INCLUDE_FILE_VAR ${INCLUDE}) - configure_file(${CMAKE_ROOT}/Modules/CheckIncludeFile.c.in - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.c) + file(READ ${CMAKE_ROOT}/Modules/CheckIncludeFile.c.in _CIF_SOURCE_CONTENT) + string(CONFIGURE "${_CIF_SOURCE_CONTENT}" _CIF_SOURCE_CONTENT) if(NOT CMAKE_REQUIRED_QUIET) message(CHECK_START "Looking for ${INCLUDE}") endif() @@ -93,8 +93,7 @@ macro(CHECK_INCLUDE_FILE INCLUDE VARIABLE) endif() try_compile(${VARIABLE} - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.c + SOURCE_FROM_VAR CheckIncludeFile.c _CIF_SOURCE_CONTENT COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${_CIF_LINK_OPTIONS} ${_CIF_LINK_LIBRARIES} diff --git a/Modules/CheckIncludeFileCXX.cmake b/Modules/CheckIncludeFileCXX.cmake index 953224e..f6af036 100644 --- a/Modules/CheckIncludeFileCXX.cmake +++ b/Modules/CheckIncludeFileCXX.cmake @@ -53,8 +53,8 @@ macro(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE) endif() set(MACRO_CHECK_INCLUDE_FILE_FLAGS ${CMAKE_REQUIRED_FLAGS}) set(CHECK_INCLUDE_FILE_VAR ${INCLUDE}) - configure_file(${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx) + file(READ ${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in _CIF_SOURCE_CONTENT) + string(CONFIGURE "${_CIF_SOURCE_CONTENT}" _CIF_SOURCE_CONTENT) if(NOT CMAKE_REQUIRED_QUIET) message(CHECK_START "Looking for C++ include ${INCLUDE}") endif() @@ -92,8 +92,7 @@ macro(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE) endif() try_compile(${VARIABLE} - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx + SOURCE_FROM_VAR CheckIncludeFile.cxx _CIF_SOURCE_CONTENT COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${_CIF_LINK_OPTIONS} ${_CIF_LINK_LIBRARIES} diff --git a/Modules/CheckIncludeFiles.cmake b/Modules/CheckIncludeFiles.cmake index 1800ca8..8e82859 100644 --- a/Modules/CheckIncludeFiles.cmake +++ b/Modules/CheckIncludeFiles.cmake @@ -52,7 +52,7 @@ include_guard(GLOBAL) macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE) if(NOT DEFINED "${VARIABLE}") - set(CMAKE_CONFIGURABLE_FILE_CONTENT "/* */\n") + set(_src_content "/* */\n") if("x${ARGN}" STREQUAL "x") if(CMAKE_C_COMPILER_LOADED) @@ -71,9 +71,9 @@ macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE) endif() if(_lang STREQUAL "C") - set(src ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckIncludeFiles/${VARIABLE}.c) + set(src ${VARIABLE}.c) elseif(_lang STREQUAL "CXX") - set(src ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckIncludeFiles/${VARIABLE}.cpp) + set(src ${VARIABLE}.cpp) else() message(FATAL_ERROR "Unknown language:\n ${_lang}\nSupported languages: C, CXX.\n") endif() @@ -86,13 +86,11 @@ macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE) set(CHECK_INCLUDE_FILES_CONTENT "/* */\n") set(MACRO_CHECK_INCLUDE_FILES_FLAGS ${CMAKE_REQUIRED_FLAGS}) foreach(FILE ${INCLUDE}) - string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT + string(APPEND _src_content "#include <${FILE}>\n") endforeach() - string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT + string(APPEND _src_content "\n\nint main(void){return 0;}\n") - configure_file("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in" - "${src}" @ONLY) set(_INCLUDE ${INCLUDE}) # remove empty elements if("${_INCLUDE}" MATCHES "^([^;]+);.+;([^;]+)$") @@ -136,8 +134,7 @@ macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE) message(CHECK_START "Looking for ${_description}") endif() try_compile(${VARIABLE} - ${CMAKE_BINARY_DIR} - ${src} + SOURCE_FROM_VAR "${src}" _src_content COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${_CIF_LINK_OPTIONS} ${_CIF_LINK_LIBRARIES} @@ -164,7 +161,7 @@ macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE) file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if files ${INCLUDE} " "exist failed with the following output:\n" - "${OUTPUT}\nSource:\n${CMAKE_CONFIGURABLE_FILE_CONTENT}\n") + "${OUTPUT}\nSource:\n${_src_content}\n") endif() endif() endmacro() diff --git a/Modules/CheckLibraryExists.cmake b/Modules/CheckLibraryExists.cmake index 804e0cb..56424ac 100644 --- a/Modules/CheckLibraryExists.cmake +++ b/Modules/CheckLibraryExists.cmake @@ -61,17 +61,15 @@ macro(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE) endif() if(CMAKE_C_COMPILER_LOADED) - set(_cle_source ${CMAKE_ROOT}/Modules/CheckFunctionExists.c) + set(_cle_source CheckFunctionExists.c) elseif(CMAKE_CXX_COMPILER_LOADED) - set(_cle_source ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckLibraryExists/CheckFunctionExists.cxx) - configure_file(${CMAKE_ROOT}/Modules/CheckFunctionExists.c "${_cle_source}" COPYONLY) + set(_cle_source CheckFunctionExists.cxx) else() message(FATAL_ERROR "CHECK_FUNCTION_EXISTS needs either C or CXX language enabled") endif() try_compile(${VARIABLE} - ${CMAKE_BINARY_DIR} - ${_cle_source} + SOURCE_FROM_FILE "${_cle_source}" "${CMAKE_ROOT}/Modules/CheckFunctionExists.c" COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${CHECK_LIBRARY_EXISTS_LINK_OPTIONS} LINK_LIBRARIES ${CHECK_LIBRARY_EXISTS_LIBRARIES} diff --git a/Modules/CheckPrototypeDefinition.cmake b/Modules/CheckPrototypeDefinition.cmake index d29c5e8..12f4e86 100644 --- a/Modules/CheckPrototypeDefinition.cmake +++ b/Modules/CheckPrototypeDefinition.cmake @@ -94,14 +94,11 @@ function(check_prototype_definition _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIAB set(CHECK_PROTOTYPE_DEFINITION_PROTO ${_PROTOTYPE}) set(CHECK_PROTOTYPE_DEFINITION_RETURN ${_RETURN}) - configure_file("${__check_proto_def_dir}/CheckPrototypeDefinition.c.in" - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c" @ONLY) - - file(READ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c _SOURCE) + file(READ ${__check_proto_def_dir}/CheckPrototypeDefinition.c.in _SOURCE) + string(CONFIGURE "${_SOURCE}" _SOURCE @ONLY) try_compile(${_VARIABLE} - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c + SOURCE_FROM_VAR CheckPrototypeDefinition.c _SOURCE COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${CHECK_PROTOTYPE_DEFINITION_LINK_OPTIONS} ${CHECK_PROTOTYPE_DEFINITION_LIBS} diff --git a/Modules/CheckSymbolExists.cmake b/Modules/CheckSymbolExists.cmake index a7139af..0d44d56 100644 --- a/Modules/CheckSymbolExists.cmake +++ b/Modules/CheckSymbolExists.cmake @@ -68,11 +68,11 @@ cmake_policy(SET CMP0054 NEW) # if() quoted variables not dereferenced macro(CHECK_SYMBOL_EXISTS SYMBOL FILES VARIABLE) if(CMAKE_C_COMPILER_LOADED) __CHECK_SYMBOL_EXISTS_FILTER_FLAGS(C) - __CHECK_SYMBOL_EXISTS_IMPL("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.c" "${SYMBOL}" "${FILES}" "${VARIABLE}" ) + __CHECK_SYMBOL_EXISTS_IMPL(CheckSymbolExists.c "${SYMBOL}" "${FILES}" "${VARIABLE}" ) __CHECK_SYMBOL_EXISTS_RESTORE_FLAGS(C) elseif(CMAKE_CXX_COMPILER_LOADED) __CHECK_SYMBOL_EXISTS_FILTER_FLAGS(CXX) - __CHECK_SYMBOL_EXISTS_IMPL("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.cxx" "${SYMBOL}" "${FILES}" "${VARIABLE}" ) + __CHECK_SYMBOL_EXISTS_IMPL(CheckSymbolExists.cxx "${SYMBOL}" "${FILES}" "${VARIABLE}" ) __CHECK_SYMBOL_EXISTS_RESTORE_FLAGS(CXX) else() message(FATAL_ERROR "CHECK_SYMBOL_EXISTS needs either C or CXX language enabled") @@ -92,7 +92,7 @@ endmacro() macro(__CHECK_SYMBOL_EXISTS_IMPL SOURCEFILE SYMBOL FILES VARIABLE) if(NOT DEFINED "${VARIABLE}" OR "x${${VARIABLE}}" STREQUAL "x${VARIABLE}") - set(CMAKE_CONFIGURABLE_FILE_CONTENT "/* */\n") + set(_CSE_SOURCE "/* */\n") set(MACRO_CHECK_SYMBOL_EXISTS_FLAGS ${CMAKE_REQUIRED_FLAGS}) if(CMAKE_REQUIRED_LINK_OPTIONS) set(CHECK_SYMBOL_EXISTS_LINK_OPTIONS @@ -113,17 +113,17 @@ macro(__CHECK_SYMBOL_EXISTS_IMPL SOURCEFILE SYMBOL FILES VARIABLE) set(CMAKE_SYMBOL_EXISTS_INCLUDES) endif() foreach(FILE ${FILES}) - string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT + string(APPEND _CSE_SOURCE "#include <${FILE}>\n") endforeach() - string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT " + string(APPEND _CSE_SOURCE " int main(int argc, char** argv) { (void)argv;") set(_CSE_CHECK_NON_MACRO "return ((int*)(&${SYMBOL}))[argc];") if("${SYMBOL}" MATCHES "^[a-zA-Z_][a-zA-Z0-9_]*$") # The SYMBOL has a legal macro name. Test whether it exists as a macro. - string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT " + string(APPEND _CSE_SOURCE " #ifndef ${SYMBOL} ${_CSE_CHECK_NON_MACRO} #else @@ -132,22 +132,18 @@ int main(int argc, char** argv) #endif") else() # The SYMBOL cannot be a macro (e.g., a template function). - string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT " + string(APPEND _CSE_SOURCE " ${_CSE_CHECK_NON_MACRO}") endif() - string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT " + string(APPEND _CSE_SOURCE " }") unset(_CSE_CHECK_NON_MACRO) - configure_file("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in" - "${SOURCEFILE}" @ONLY) - if(NOT CMAKE_REQUIRED_QUIET) message(CHECK_START "Looking for ${SYMBOL}") endif() try_compile(${VARIABLE} - ${CMAKE_BINARY_DIR} - "${SOURCEFILE}" + SOURCE_FROM_VAR "${SOURCEFILE}" _CSE_SOURCE COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${CHECK_SYMBOL_EXISTS_LINK_OPTIONS} ${CHECK_SYMBOL_EXISTS_LIBS} @@ -164,7 +160,7 @@ int main(int argc, char** argv) "Determining if the ${SYMBOL} " "exist passed with the following output:\n" "${OUTPUT}\nFile ${SOURCEFILE}:\n" - "${CMAKE_CONFIGURABLE_FILE_CONTENT}\n") + "${_CSE_SOURCE}\n") else() if(NOT CMAKE_REQUIRED_QUIET) message(CHECK_FAIL "not found") @@ -174,9 +170,9 @@ int main(int argc, char** argv) "Determining if the ${SYMBOL} " "exist failed with the following output:\n" "${OUTPUT}\nFile ${SOURCEFILE}:\n" - "${CMAKE_CONFIGURABLE_FILE_CONTENT}\n") + "${_CSE_SOURCE}\n") endif() - unset(CMAKE_CONFIGURABLE_FILE_CONTENT) + unset(_CSE_SOURCE) endif() endmacro() diff --git a/Modules/CheckTypeSize.cmake b/Modules/CheckTypeSize.cmake index 602170c..b14ab06 100644 --- a/Modules/CheckTypeSize.cmake +++ b/Modules/CheckTypeSize.cmake @@ -104,9 +104,9 @@ function(__check_type_size_impl type var map builtin language) # Perform language check if(language STREQUAL "C") - set(src ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${var}.c) + set(src ${var}.c) elseif(language STREQUAL "CXX") - set(src ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${var}.cpp) + set(src ${var}.cpp) else() message(FATAL_ERROR "Unknown language:\n ${language}\nSupported languages: C, CXX.\n") endif() @@ -142,8 +142,9 @@ function(__check_type_size_impl type var map builtin language) # Perform the check. 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} + file(READ ${__check_type_size_dir}/CheckTypeSize.c.in src_content) + string(CONFIGURE "${src_content}" src_content @ONLY) + try_compile(HAVE_${var} SOURCE_FROM_VAR "${src}" src_content COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS} LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} @@ -209,9 +210,8 @@ function(__check_type_size_impl type var map builtin language) if(NOT CMAKE_REQUIRED_QUIET) message(CHECK_FAIL "failed") endif() - file(READ ${src} content) file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining size of ${type} failed with the following output:\n${output}\n${src}:\n${content}\n\n") + "Determining size of ${type} failed with the following output:\n${output}\n${src}:\n${src_content}\n\n") set(${var} "" CACHE INTERNAL "CHECK_TYPE_SIZE: ${type} unknown") file(REMOVE ${map}) endif() diff --git a/Modules/CheckVariableExists.cmake b/Modules/CheckVariableExists.cmake index 7420124..5dc3441 100644 --- a/Modules/CheckVariableExists.cmake +++ b/Modules/CheckVariableExists.cmake @@ -62,8 +62,7 @@ macro(CHECK_VARIABLE_EXISTS VAR VARIABLE) set(CHECK_VARIABLE_EXISTS_ADD_LIBRARIES) endif() try_compile(${VARIABLE} - ${CMAKE_BINARY_DIR} - ${CMAKE_ROOT}/Modules/CheckVariableExists.c + SOURCES ${CMAKE_ROOT}/Modules/CheckVariableExists.c COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${CHECK_VARIABLE_EXISTS_ADD_LINK_OPTIONS} ${CHECK_VARIABLE_EXISTS_ADD_LIBRARIES} diff --git a/Modules/Compiler/Clang-CUDA.cmake b/Modules/Compiler/Clang-CUDA.cmake index 219897e..d9929f1 100644 --- a/Modules/Compiler/Clang-CUDA.cmake +++ b/Modules/Compiler/Clang-CUDA.cmake @@ -35,6 +35,10 @@ set(CMAKE_CUDA_RUNTIME_LIBRARY_LINK_OPTIONS_STATIC "cudadevrt;cudart_static") set(CMAKE_CUDA_RUNTIME_LIBRARY_LINK_OPTIONS_SHARED "cudadevrt;cudart") set(CMAKE_CUDA_RUNTIME_LIBRARY_LINK_OPTIONS_NONE "") +# Clang doesn't support CUDA device LTO +set(_CMAKE_CUDA_IPO_SUPPORTED_BY_CMAKE NO) +set(_CMAKE_CUDA_IPO_MAY_BE_SUPPORTED_BY_COMPILER NO) + if(UNIX) list(APPEND CMAKE_CUDA_RUNTIME_LIBRARY_LINK_OPTIONS_STATIC "rt" "pthread" "dl") endif() diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake index df115d3..4f9af37 100644 --- a/Modules/Compiler/Clang.cmake +++ b/Modules/Compiler/Clang.cmake @@ -80,7 +80,7 @@ else() set(CMAKE_${lang}_COMPILE_OPTIONS_IPO "-flto") endif() - if(ANDROID AND NOT CMAKE_ANDROID_NDK_VERSION VERSION_GREATER_EQUAL "22") + if(ANDROID AND CMAKE_ANDROID_NDK_VERSION VERSION_LESS "22") # https://github.com/android-ndk/ndk/issues/242 set(CMAKE_${lang}_LINK_OPTIONS_IPO "-fuse-ld=gold") endif() @@ -255,6 +255,7 @@ macro(__compiler_clang_cxx_standards lang) cxx_std_17 cxx_std_20 cxx_std_23 + cxx_std_26 ) _record_compiler_features(${lang} "" CMAKE_${lang}_COMPILE_FEATURES) endmacro() diff --git a/Modules/Compiler/IntelLLVM-FindBinUtils.cmake b/Modules/Compiler/IntelLLVM-FindBinUtils.cmake new file mode 100644 index 0000000..c5b1ee6 --- /dev/null +++ b/Modules/Compiler/IntelLLVM-FindBinUtils.cmake @@ -0,0 +1,45 @@ +if(NOT DEFINED _CMAKE_PROCESSING_LANGUAGE OR _CMAKE_PROCESSING_LANGUAGE STREQUAL "") + message(FATAL_ERROR "Internal error: _CMAKE_PROCESSING_LANGUAGE is not set") +endif() + +# Ubuntu: +# * /usr/bin/llvm-ar-9 +# * /usr/bin/llvm-ranlib-9 +string(REGEX MATCH "^([0-9]+)" __version_x + "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_VERSION}") + +# Debian: +# * /usr/bin/llvm-ar-4.0 +# * /usr/bin/llvm-ranlib-4.0 +string(REGEX MATCH "^([0-9]+\\.[0-9]+)" __version_x_y + "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_VERSION}") + +# Try to find tools in the IntelLLVM Clang tools directory +get_filename_component(__intel_llvm_hint_1 "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER}" DIRECTORY) +get_filename_component(__intel_llvm_hint_1 "${__intel_llvm_hint_1}/../bin-llvm" REALPATH) + +get_filename_component(__intel_llvm_hint_2 "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER}" DIRECTORY) + +set(__intel_llvm_hints ${__intel_llvm_hint_1} ${__intel_llvm_hint_2}) + +# http://manpages.ubuntu.com/manpages/precise/en/man1/llvm-ar.1.html +find_program(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_AR NAMES + "${_CMAKE_TOOLCHAIN_PREFIX}llvm-ar-${__version_x_y}" + "${_CMAKE_TOOLCHAIN_PREFIX}llvm-ar-${__version_x}" + "${_CMAKE_TOOLCHAIN_PREFIX}llvm-ar" + HINTS ${__intel_llvm_hints} + NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH + DOC "LLVM archiver" +) +mark_as_advanced(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_AR) + +# http://manpages.ubuntu.com/manpages/precise/en/man1/llvm-ranlib.1.html +find_program(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_RANLIB NAMES + "${_CMAKE_TOOLCHAIN_PREFIX}llvm-ranlib-${__version_x_y}" + "${_CMAKE_TOOLCHAIN_PREFIX}llvm-ranlib-${__version_x}" + "${_CMAKE_TOOLCHAIN_PREFIX}llvm-ranlib" + HINTS ${__intel_llvm_hints} + NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH + DOC "Generate index for LLVM archive" +) +mark_as_advanced(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_RANLIB) diff --git a/Modules/Compiler/IntelLLVM.cmake b/Modules/Compiler/IntelLLVM.cmake index c5800dc..30de1a9 100644 --- a/Modules/Compiler/IntelLLVM.cmake +++ b/Modules/Compiler/IntelLLVM.cmake @@ -15,6 +15,15 @@ set(__pch_header_CXX "c++-header") set(__pch_header_OBJC "objective-c-header") set(__pch_header_OBJCXX "objective-c++-header") +# Variables that are common across front-end variants +macro(__compiler_intel_llvm_common lang) + set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES) + set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES) + set(CMAKE_${lang}_ARCHIVE_CREATE_IPO "\"${CMAKE_${lang}_COMPILER_AR}\" cr <TARGET> <LINK_FLAGS> <OBJECTS>") + set(CMAKE_${lang}_ARCHIVE_APPEND_IPO "\"${CMAKE_${lang}_COMPILER_AR}\" r <TARGET> <LINK_FLAGS> <OBJECTS>") + set(CMAKE_${lang}_ARCHIVE_FINISH_IPO "\"${CMAKE_${lang}_COMPILER_RANLIB}\" <TARGET>") +endmacro() + if(CMAKE_HOST_WIN32) # MSVC-like macro(__compiler_intel_llvm lang) @@ -24,6 +33,9 @@ if(CMAKE_HOST_WIN32) set(CMAKE_${lang}_COMPILE_OPTIONS_INVALID_PCH -Winvalid-pch) set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-WX") endif() + __compiler_intel_llvm_common(${lang}) + set(CMAKE_${lang}_COMPILE_OPTIONS_IPO "-Qipo") + set(CMAKE_${lang}_LINK_OPTIONS_IPO "-Qipo") endmacro() else() # GNU-like @@ -61,12 +73,9 @@ else() set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Xlinker" " ") set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP) - set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES) - set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES) - set(CMAKE_${lang}_COMPILE_OPTIONS_IPO "-flto=thin") - set(CMAKE_${lang}_ARCHIVE_CREATE_IPO "\"${CMAKE_${lang}_COMPILER_AR}\" cr <TARGET> <LINK_FLAGS> <OBJECTS>") - set(CMAKE_${lang}_ARCHIVE_APPEND_IPO "\"${CMAKE_${lang}_COMPILER_AR}\" r <TARGET> <LINK_FLAGS> <OBJECTS>") - set(CMAKE_${lang}_ARCHIVE_FINISH_IPO "\"${CMAKE_${lang}_COMPILER_RANLIB}\" <TARGET>") + __compiler_intel_llvm_common(${lang}) + set(CMAKE_${lang}_COMPILE_OPTIONS_IPO "-ipo") + set(CMAKE_${lang}_LINK_OPTIONS_IPO "-ipo") set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") diff --git a/Modules/Compiler/MSVC-CXX.cmake b/Modules/Compiler/MSVC-CXX.cmake index 75165fd..60d13f1 100644 --- a/Modules/Compiler/MSVC-CXX.cmake +++ b/Modules/Compiler/MSVC-CXX.cmake @@ -72,6 +72,7 @@ elseif (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0) cxx_std_17 cxx_std_20 cxx_std_23 + cxx_std_26 ) _record_compiler_features(CXX "" CMAKE_CXX_COMPILE_FEATURES) endmacro() diff --git a/Modules/Compiler/NVIDIA-CUDA.cmake b/Modules/Compiler/NVIDIA-CUDA.cmake index e07d152..c8dcd2a 100644 --- a/Modules/Compiler/NVIDIA-CUDA.cmake +++ b/Modules/Compiler/NVIDIA-CUDA.cmake @@ -48,6 +48,13 @@ if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) set(CMAKE_CUDA_DEPENDS_USE_COMPILER TRUE) endif() +if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 11.2) + set(_CMAKE_CUDA_IPO_SUPPORTED_BY_CMAKE YES) + set(_CMAKE_CUDA_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES) + + set(CMAKE_CUDA_DEVICE_LINK_OPTIONS_IPO " -dlto") +endif() + if(NOT "x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC") set(CMAKE_CUDA_COMPILE_OPTIONS_PIE -Xcompiler=-fPIE) set(CMAKE_CUDA_COMPILE_OPTIONS_PIC -Xcompiler=-fPIC) @@ -61,6 +68,7 @@ if(NOT "x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC") string(APPEND CMAKE_CUDA_FLAGS_MINSIZEREL_INIT " -O1 -DNDEBUG") string(APPEND CMAKE_CUDA_FLAGS_RELWITHDEBINFO_INIT " -O2 -g -DNDEBUG") endif() + set(CMAKE_SHARED_LIBRARY_CREATE_CUDA_FLAGS -shared) set(CMAKE_INCLUDE_SYSTEM_FLAG_CUDA -isystem=) @@ -132,15 +140,19 @@ else() endif() -# FIXME: investigate use of --options-file. -# Tell Makefile generator that nvcc does not support @<rspfile> syntax. -set(CMAKE_CUDA_USE_RESPONSE_FILE_FOR_INCLUDES 0) -set(CMAKE_CUDA_USE_RESPONSE_FILE_FOR_LIBRARIES 0) -set(CMAKE_CUDA_USE_RESPONSE_FILE_FOR_OBJECTS 0) - if (CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "9.0") set(CMAKE_CUDA_RESPONSE_FILE_DEVICE_LINK_FLAG "--options-file ") set(CMAKE_CUDA_RESPONSE_FILE_FLAG "--options-file ") endif() +if (CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "11.0") + set(CMAKE_CUDA_USE_RESPONSE_FILE_FOR_INCLUDES 1) + set(CMAKE_CUDA_USE_RESPONSE_FILE_FOR_LIBRARIES 1) + set(CMAKE_CUDA_USE_RESPONSE_FILE_FOR_OBJECTS 1) +else() + set(CMAKE_CUDA_USE_RESPONSE_FILE_FOR_INCLUDES 0) + set(CMAKE_CUDA_USE_RESPONSE_FILE_FOR_LIBRARIES 0) + set(CMAKE_CUDA_USE_RESPONSE_FILE_FOR_OBJECTS 0) +endif() + __compiler_check_default_language_standard(CUDA 6.0 03) diff --git a/Modules/Compiler/Tasking-ASM.cmake b/Modules/Compiler/Tasking-ASM.cmake new file mode 100644 index 0000000..19bce19 --- /dev/null +++ b/Modules/Compiler/Tasking-ASM.cmake @@ -0,0 +1,7 @@ +include(Compiler/Tasking) + +set(CMAKE_ASM_OUTPUT_EXTENSION ".o") +set(CMAKE_ASM_OUTPUT_EXTENSION_REPLACE 1) + +set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> <INCLUDES> <FLAGS> -o <OBJECT> <SOURCE>") +set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS S;s;asm;msa) diff --git a/Modules/Compiler/Tasking-C.cmake b/Modules/Compiler/Tasking-C.cmake new file mode 100644 index 0000000..0ea3cd2 --- /dev/null +++ b/Modules/Compiler/Tasking-C.cmake @@ -0,0 +1,47 @@ +include(Compiler/Tasking) +__compiler_tasking(C) + +set(CMAKE_C90_STANDARD_COMPILE_OPTION "--iso=90" "--strict") +set(CMAKE_C90_EXTENSION_COMPILE_OPTION "--iso=90" " ") + +set(CMAKE_C99_STANDARD_COMPILE_OPTION "--iso=99" "--strict") +set(CMAKE_C99_EXTENSION_COMPILE_OPTION "--iso=99" " ") + +set(CMAKE_C11_STANDARD_COMPILE_OPTION "--iso=11" "--strict") +set(CMAKE_C11_EXTENSION_COMPILE_OPTION "--iso=11" " ") + +if(CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "TriCore") + if(CMAKE_TASKING_TOOLSET STREQUAL "SmartCode") + __compiler_check_default_language_standard(C 10.1 11) + else() + __compiler_check_default_language_standard(C 6.3 11) + endif() +elseif(CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "ARM") + if(CMAKE_TASKING_TOOLSET STREQUAL "SmartCode") + __compiler_check_default_language_standard(C 10.1 11) + elseif(CMAKE_TASKING_TOOLSET STREQUAL "TriCore") + __compiler_check_default_language_standard(C 6.3 11) + else() + __compiler_check_default_language_standard(C 6.0 11) + endif() +elseif(CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "MCS") + if(CMAKE_TASKING_TOOLSET STREQUAL "SmartCode") + __compiler_check_default_language_standard(C 10.1 11) + elseif(CMAKE_TASKING_TOOLSET STREQUAL "TriCore") + __compiler_check_default_language_standard(C 6.3 11) + else() + __compiler_check_default_language_standard(C 3.3 11) + endif() +elseif(CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "ARC") + __compiler_check_default_language_standard(C 10.1 11) +elseif(CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "8051") + if(CMAKE_TASKING_TOOLSET STREQUAL "SmartCode") + __compiler_check_default_language_standard(C 10.1 11) + elseif(CMAKE_TASKING_TOOLSET STREQUAL "TriCore") + __compiler_check_default_language_standard(C 6.3 11) + else() + __compiler_check_default_language_standard(C 7.2 89) + endif() +elseif(CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "PCP") + __compiler_check_default_language_standard(C 6.3 11) +endif() diff --git a/Modules/Compiler/Tasking-CXX.cmake b/Modules/Compiler/Tasking-CXX.cmake new file mode 100644 index 0000000..635104c --- /dev/null +++ b/Modules/Compiler/Tasking-CXX.cmake @@ -0,0 +1,31 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. +include(Compiler/Tasking) +__compiler_tasking(CXX) + +set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "--c++=03" "--strict") +set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "--iso=03" " ") + +set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "--c++=11" "--strict") +set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "--c++=11" " ") + +set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "--c++=14" "--strict") +set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "--c++=14" " ") + +if(CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL "TriCore") + if(CMAKE_TASKING_TOOLSET STREQUAL "SmartCode") + __compiler_check_default_language_standard(CXX 10.1 14) + else() + __compiler_check_default_language_standard(CXX 6.3 14) + endif() +elseif(CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL "ARM") + if(CMAKE_TASKING_TOOLSET STREQUAL "SmartCode") + __compiler_check_default_language_standard(CXX 10.1 14) + elseif(CMAKE_TASKING_TOOLSET STREQUAL "TriCore") + __compiler_check_default_language_standard(CXX 6.3 14) + else() + __compiler_check_default_language_standard(CXX 6.0 14) + endif() +else() + message(FATAL_ERROR "CXX is not supported with the ${CMAKE_CXX_COMPILER_ARCHITECTURE_ID} architecture.") +endif() diff --git a/Modules/Compiler/Tasking-DetermineCompiler.cmake b/Modules/Compiler/Tasking-DetermineCompiler.cmake new file mode 100644 index 0000000..a40be19 --- /dev/null +++ b/Modules/Compiler/Tasking-DetermineCompiler.cmake @@ -0,0 +1,10 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. +set(_compiler_id_pp_test "defined(__TASKING__)") + +set(_compiler_id_version_compute " + # define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__VERSION__/1000) + # define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__VERSION__ % 100)") + +string(APPEND _compiler_id_version_compute " +# define @PREFIX@COMPILER_VERSION_INTERNAL @MACRO_DEC@(__VERSION__)") diff --git a/Modules/Compiler/Tasking-FindBinUtils.cmake b/Modules/Compiler/Tasking-FindBinUtils.cmake new file mode 100644 index 0000000..eab31d7 --- /dev/null +++ b/Modules/Compiler/Tasking-FindBinUtils.cmake @@ -0,0 +1,18 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +# Find the archiver for the compiler architecture, which is always in the same +# directory as the compiler. +if(NOT DEFINED _CMAKE_PROCESSING_LANGUAGE OR _CMAKE_PROCESSING_LANGUAGE STREQUAL "") + message(FATAL_ERROR "Internal error: _CMAKE_PROCESSING_LANGUAGE is not set") +endif() + +get_filename_component(__tasking_hints "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER}" DIRECTORY) + +find_program(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_AR + NAMES artc ararm armcs ar51 ararc arpcp + HINTS ${__tasking_hints} + NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH + DOC "Tasking Archiver" +) +mark_as_advanced(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_AR) diff --git a/Modules/Compiler/Tasking.cmake b/Modules/Compiler/Tasking.cmake new file mode 100644 index 0000000..d0c2f79 --- /dev/null +++ b/Modules/Compiler/Tasking.cmake @@ -0,0 +1,86 @@ +# 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(_Tasking_CMAKE_LOADED) + return() +endif() +set(_Tasking_CMAKE_LOADED TRUE) +include(Compiler/CMakeCommonCompilerMacros) + +set(CMAKE_EXECUTABLE_SUFFIX ".elf") +set(CMAKE_STATIC_LIBRARY_SUFFIX ".a") +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) + +set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE) +set(BUILD_SHARED_LIBS FALSE CACHE BOOL "") +set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") +set(CMAKE_LINK_SEARCH_START_STATIC TRUE) + +function(__tasking_set_processor_list lang out_var) + execute_process(COMMAND "${CMAKE_${lang}_COMPILER}" --cpu-list + OUTPUT_VARIABLE processor_list + ERROR_VARIABLE processor_list) + string(REGEX MATCHALL " +([A-Za-z0-9_]+)[^\n]+\n" processor_list "${processor_list}") + list(POP_FRONT processor_list) + string(REGEX REPLACE " +([A-Za-z0-9_]+)[^\n]+\n" "\\1" processor_list "${processor_list}") + set(${out_var} "${processor_list}" PARENT_SCOPE) +endfunction() + +function(__tasking_check_processor processor list out_var) + string(TOLOWER "${processor}" processor) + if(processor IN_LIST list) + set(${out_var} TRUE PARENT_SCOPE) + else() + set(${out_var} FALSE PARENT_SCOPE) + endif() +endfunction() + +if(NOT CMAKE_TASKING_TOOLSET) + set(CMAKE_TASKING_TOOLSET "Standalone") +endif() + +macro(__compiler_tasking lang) + + if(CMAKE_SYSTEM_PROCESSOR) + if(NOT _TASKING_${lang}_PROCESSOR_LIST) + __tasking_set_processor_list(${lang} _TASKING_${lang}_PROCESSOR_LIST) + endif() + __tasking_check_processor(${CMAKE_SYSTEM_PROCESSOR} "${_TASKING_${lang}_PROCESSOR_LIST}" _TASKING_${lang}_VALID_PROCESSOR) + if(${_TASKING_${lang}_VALID_PROCESSOR}) + string(APPEND CMAKE_${lang}_FLAGS_INIT " -C${CMAKE_SYSTEM_PROCESSOR}") + else() + message(FATAL_ERROR "Invalid processor ${CMAKE_SYSTEM_PROCESSOR} specified.\n" + "Supported processors: ${_TASKING_${lang}_PROCESSOR_LIST}") + endif() + endif() + + set(CMAKE_${lang}_VERBOSE_FLAG "-v") + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC") + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Wl" " ") + set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "-f ") + set(CMAKE_DEPFILE_FLAGS_${lang} "--dep-file=<DEP_FILE>") + set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "--warning-as-errors") + + string(APPEND CMAKE_${lang}_FLAGS_INIT " ") + string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -O0 -g") + string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -O2 -t4 -DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O2 -t2 -DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -t2 -g -DNDEBUG") + + set(CMAKE_${lang}_ARCHIVE_CREATE "\"${CMAKE_${lang}_COMPILER_AR}\" -r <TARGET> <OBJECTS>") + set(CMAKE_${lang}_ARCHIVE_APPEND "\"${CMAKE_${lang}_COMPILER_AR}\" -r <TARGET> <OBJECTS>") + set(CMAKE_${lang}_ARCHIVE_FINISH "") + + set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -cs <SOURCE> -o <ASSEMBLY_SOURCE>") + set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -Ep <SOURCE> > <PREPROCESSED_SOURCE>") + + set(CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "${CMAKE_${lang}_COMPILER}") + if(CMAKE_${lang}_COMPILER_ARG1) + separate_arguments(_COMPILER_ARGS NATIVE_COMMAND "${CMAKE_${lang}_COMPILER_ARG1}") + list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND ${_COMPILER_ARGS}) + unset(_COMPILER_ARGS) + endif() + list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "-Ep" "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp") + +endmacro() diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 9952658..22a25bd 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -1840,7 +1840,11 @@ function(_ep_get_build_command else() set(cmd "${CMAKE_COMMAND}") endif() - set(args --build ".") + if(step STREQUAL "INSTALL") + set(args --install ".") + else() + set(args --build ".") + endif() get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(_isMultiConfig) if (CMAKE_CFG_INTDIR AND @@ -1862,9 +1866,6 @@ function(_ep_get_build_command endif() list(APPEND args --config ${config}) endif() - if(step STREQUAL "INSTALL") - list(APPEND args --target install) - endif() # But for "TEST" drive the project with corresponding "ctest". if("x${step}x" STREQUAL "xTESTx") string(REGEX REPLACE "^(.*/)cmake([^/]*)$" "\\1ctest\\2" cmd "${cmd}") @@ -3832,6 +3833,19 @@ function(_ep_add_install_command name) set(uses_terminal "") endif() + # With BUILD_ALWAYS+BUILD_BYPRODUCTS, Ninja restats the + # build step outputs and may not consider this step to + # be out-of-date. Explicitly mark it out-of-date too. + get_property(build_always + TARGET ${name} + PROPERTY _EP_BUILD_ALWAYS + ) + if(build_always) + set(always 1) + else() + set(always 0) + endif() + set(__cmdQuoted) foreach(__item IN LISTS cmd) string(APPEND __cmdQuoted " [==[${__item}]==]") @@ -3842,6 +3856,7 @@ function(_ep_add_install_command name) COMMAND ${__cmdQuoted} WORKING_DIRECTORY \${binary_dir} DEPENDEES build + ALWAYS \${always} ${log} ${uses_terminal} )" diff --git a/Modules/ExternalProject/gitupdate.cmake.in b/Modules/ExternalProject/gitupdate.cmake.in index 7896f62..50f0167 100644 --- a/Modules/ExternalProject/gitupdate.cmake.in +++ b/Modules/ExternalProject/gitupdate.cmake.in @@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.5) function(get_hash_for_ref ref out_var err_var) execute_process( - COMMAND "@git_EXECUTABLE@" rev-parse "${ref}^0" + COMMAND "@git_EXECUTABLE@" --git-dir=.git rev-parse "${ref}^0" WORKING_DIRECTORY "@work_dir@" RESULT_VARIABLE error_code OUTPUT_VARIABLE ref_hash @@ -27,7 +27,7 @@ endif() execute_process( - COMMAND "@git_EXECUTABLE@" show-ref "@git_tag@" + COMMAND "@git_EXECUTABLE@" --git-dir=.git show-ref "@git_tag@" WORKING_DIRECTORY "@work_dir@" OUTPUT_VARIABLE show_ref_output ) @@ -95,7 +95,7 @@ endif() if(fetch_required) message(VERBOSE "Fetching latest from the remote @git_remote_name@") execute_process( - COMMAND "@git_EXECUTABLE@" fetch --tags --force "@git_remote_name@" + COMMAND "@git_EXECUTABLE@" --git-dir=.git fetch --tags --force "@git_remote_name@" WORKING_DIRECTORY "@work_dir@" COMMAND_ERROR_IS_FATAL ANY ) @@ -112,7 +112,7 @@ if(git_update_strategy MATCHES "^REBASE(_CHECKOUT)?$") # We can't if we aren't already on a branch and we shouldn't if that local # branch isn't tracking the one we want to checkout. execute_process( - COMMAND "@git_EXECUTABLE@" symbolic-ref -q HEAD + COMMAND "@git_EXECUTABLE@" --git-dir=.git symbolic-ref -q HEAD WORKING_DIRECTORY "@work_dir@" OUTPUT_VARIABLE current_branch OUTPUT_STRIP_TRAILING_WHITESPACE @@ -128,7 +128,7 @@ if(git_update_strategy MATCHES "^REBASE(_CHECKOUT)?$") else() execute_process( - COMMAND "@git_EXECUTABLE@" for-each-ref "--format=%(upstream:short)" "${current_branch}" + COMMAND "@git_EXECUTABLE@" --git-dir=.git for-each-ref "--format=%(upstream:short)" "${current_branch}" WORKING_DIRECTORY "@work_dir@" OUTPUT_VARIABLE upstream_branch OUTPUT_STRIP_TRAILING_WHITESPACE @@ -151,7 +151,7 @@ endif() # Check if stash is needed execute_process( - COMMAND "@git_EXECUTABLE@" status --porcelain + COMMAND "@git_EXECUTABLE@" --git-dir=.git status --porcelain WORKING_DIRECTORY "@work_dir@" RESULT_VARIABLE error_code OUTPUT_VARIABLE repo_status @@ -165,7 +165,7 @@ string(LENGTH "${repo_status}" need_stash) # rebase or checkout without losing those changes permanently if(need_stash) execute_process( - COMMAND "@git_EXECUTABLE@" stash save @git_stash_save_options@ + COMMAND "@git_EXECUTABLE@" --git-dir=.git stash save @git_stash_save_options@ WORKING_DIRECTORY "@work_dir@" COMMAND_ERROR_IS_FATAL ANY ) @@ -173,13 +173,13 @@ endif() if(git_update_strategy STREQUAL "CHECKOUT") execute_process( - COMMAND "@git_EXECUTABLE@" checkout "${checkout_name}" + COMMAND "@git_EXECUTABLE@" --git-dir=.git checkout "${checkout_name}" WORKING_DIRECTORY "@work_dir@" COMMAND_ERROR_IS_FATAL ANY ) else() execute_process( - COMMAND "@git_EXECUTABLE@" rebase "${checkout_name}" + COMMAND "@git_EXECUTABLE@" --git-dir=.git rebase "${checkout_name}" WORKING_DIRECTORY "@work_dir@" RESULT_VARIABLE error_code OUTPUT_VARIABLE rebase_output @@ -188,7 +188,7 @@ else() if(error_code) # Rebase failed, undo the rebase attempt before continuing execute_process( - COMMAND "@git_EXECUTABLE@" rebase --abort + COMMAND "@git_EXECUTABLE@" --git-dir=.git rebase --abort WORKING_DIRECTORY "@work_dir@" ) @@ -196,7 +196,7 @@ else() # Not allowed to do a checkout as a fallback, so cannot proceed if(need_stash) execute_process( - COMMAND "@git_EXECUTABLE@" stash pop --index --quiet + COMMAND "@git_EXECUTABLE@" --git-dir=.git stash pop --index --quiet WORKING_DIRECTORY "@work_dir@" ) endif() @@ -218,7 +218,7 @@ else() message(WARNING "Rebase failed, output has been saved to ${error_log_file}" "\nFalling back to checkout, previous commit tagged as ${tag_name}") execute_process( - COMMAND "@git_EXECUTABLE@" tag -a + COMMAND "@git_EXECUTABLE@" --git-dir=.git tag -a -m "ExternalProject attempting to move from here to ${checkout_name}" ${tag_name} WORKING_DIRECTORY "@work_dir@" @@ -226,7 +226,7 @@ else() ) execute_process( - COMMAND "@git_EXECUTABLE@" checkout "${checkout_name}" + COMMAND "@git_EXECUTABLE@" --git-dir=.git checkout "${checkout_name}" WORKING_DIRECTORY "@work_dir@" COMMAND_ERROR_IS_FATAL ANY ) @@ -236,29 +236,29 @@ endif() if(need_stash) # Put back the stashed changes execute_process( - COMMAND "@git_EXECUTABLE@" stash pop --index --quiet + COMMAND "@git_EXECUTABLE@" --git-dir=.git stash pop --index --quiet WORKING_DIRECTORY "@work_dir@" RESULT_VARIABLE error_code ) if(error_code) # Stash pop --index failed: Try again dropping the index execute_process( - COMMAND "@git_EXECUTABLE@" reset --hard --quiet + COMMAND "@git_EXECUTABLE@" --git-dir=.git reset --hard --quiet WORKING_DIRECTORY "@work_dir@" ) execute_process( - COMMAND "@git_EXECUTABLE@" stash pop --quiet + COMMAND "@git_EXECUTABLE@" --git-dir=.git stash pop --quiet WORKING_DIRECTORY "@work_dir@" RESULT_VARIABLE error_code ) if(error_code) # Stash pop failed: Restore previous state. execute_process( - COMMAND "@git_EXECUTABLE@" reset --hard --quiet ${head_sha} + COMMAND "@git_EXECUTABLE@" --git-dir=.git reset --hard --quiet ${head_sha} WORKING_DIRECTORY "@work_dir@" ) execute_process( - COMMAND "@git_EXECUTABLE@" stash pop --index --quiet + COMMAND "@git_EXECUTABLE@" --git-dir=.git stash pop --index --quiet WORKING_DIRECTORY "@work_dir@" ) message(FATAL_ERROR "\nFailed to unstash changes in: '@work_dir@'." @@ -270,7 +270,7 @@ endif() set(init_submodules "@init_submodules@") if(init_submodules) execute_process( - COMMAND "@git_EXECUTABLE@" submodule update @git_submodules_recurse@ --init @git_submodules@ + COMMAND "@git_EXECUTABLE@" --git-dir=.git submodule update @git_submodules_recurse@ --init @git_submodules@ WORKING_DIRECTORY "@work_dir@" COMMAND_ERROR_IS_FATAL ANY ) diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake index 995e69a..ac3918c 100644 --- a/Modules/FetchContent.cmake +++ b/Modules/FetchContent.cmake @@ -111,6 +111,7 @@ Commands FetchContent_Declare( <name> <contentOptions>... + [SYSTEM] [OVERRIDE_FIND_PACKAGE | FIND_PACKAGE_ARGS args...] ) @@ -229,6 +230,16 @@ Commands to intercept any direct call to :command:`find_package`, except if that call contains the ``BYPASS_PROVIDER`` option. + .. versionadded:: 3.25 + + ``SYSTEM`` + If the ``SYSTEM`` argument is provided, targets created by + the dependency will have their :prop_tgt:`SYSTEM` property + set to true when populated by :command:`FetchContent_MakeAvailable`. + The entries in their :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` + will be treated as ``SYSTEM`` include directories when + compiling consumers. + .. command:: FetchContent_MakeAvailable .. versionadded:: 3.14 @@ -884,9 +895,10 @@ Overriding Where To Find CMakeLists.txt If the sub-project's ``CMakeLists.txt`` file is not at the top level of its source tree, the ``SOURCE_SUBDIR`` option can be used to tell ``FetchContent`` -where to find it. The following example shows how to use that option and +where to find it. The following example shows how to use that option, and it also sets a variable which is meaningful to the subproject before pulling -it into the main build: +it into the main build (set as an ``INTERNAL`` cache variable to avoid +problems with policy :policy:`CMP0077`): .. code-block:: cmake @@ -897,7 +909,7 @@ it into the main build: GIT_TAG ae50d9b9902526efd6c7a1907d09739f959c6297 # v3.15.0 SOURCE_SUBDIR cmake ) - set(protobuf_BUILD_TESTS OFF) + set(protobuf_BUILD_TESTS OFF CACHE INTERNAL "") FetchContent_MakeAvailable(protobuf) Complex Dependency Hierarchies @@ -1972,13 +1984,17 @@ macro(FetchContent_MakeAvailable) if("${__cmake_contentDetails}" STREQUAL "") message(FATAL_ERROR "No details have been set for content: ${__cmake_contentName}") endif() - cmake_parse_arguments(__cmake_arg "" "SOURCE_SUBDIR" "" ${__cmake_contentDetails}) + cmake_parse_arguments(__cmake_arg "SYSTEM" "SOURCE_SUBDIR" "" ${__cmake_contentDetails}) if(NOT "${__cmake_arg_SOURCE_SUBDIR}" STREQUAL "") string(APPEND __cmake_srcdir "/${__cmake_arg_SOURCE_SUBDIR}") endif() if(EXISTS ${__cmake_srcdir}/CMakeLists.txt) - add_subdirectory(${__cmake_srcdir} ${${__cmake_contentNameLower}_BINARY_DIR}) + if (__cmake_arg_SYSTEM) + add_subdirectory(${__cmake_srcdir} ${${__cmake_contentNameLower}_BINARY_DIR} SYSTEM) + else() + add_subdirectory(${__cmake_srcdir} ${${__cmake_contentNameLower}_BINARY_DIR}) + endif() endif() unset(__cmake_srcdir) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index 7a381af..d02c589 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -35,6 +35,12 @@ The following variables may be set to influence this module's behavior: if set ``pkg-config`` will be used to search for a BLAS library first and if one is found that is preferred +``BLA_PKGCONFIG_BLAS`` + .. versionadded:: 3.25 + + If set, the ``pkg-config`` method will look for this module name instead of + just ``blas``. + ``BLA_SIZEOF_INTEGER`` .. versionadded:: 3.22 @@ -273,8 +279,11 @@ endif() include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) if(BLA_PREFER_PKGCONFIG) + if(NOT BLA_PKGCONFIG_BLAS) + set(BLA_PKGCONFIG_BLAS "blas") + endif() find_package(PkgConfig QUIET) - pkg_check_modules(PKGC_BLAS QUIET blas) + pkg_check_modules(PKGC_BLAS QUIET ${BLA_PKGCONFIG_BLAS}) if(PKGC_BLAS_FOUND) set(BLAS_FOUND ${PKGC_BLAS_FOUND}) set(BLAS_LIBRARIES "${PKGC_BLAS_LINK_LIBRARIES}") diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index af5f798..470111f 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -799,7 +799,9 @@ if(NOT "${CUDA_TOOLKIT_ROOT_DIR}" STREQUAL "${CUDA_TOOLKIT_ROOT_DIR_INTERNAL}") unset(CUDA_VERSION CACHE) endif() -if(NOT "${CUDA_TOOLKIT_TARGET_DIR}" STREQUAL "${CUDA_TOOLKIT_TARGET_DIR_INTERNAL}") +# If CUDA_TOOLKIT_TARGET_DIR exists, check if it has changed. +if(DEFINED CUDA_TOOLKIT_TARGET_DIR + AND NOT "${CUDA_TOOLKIT_TARGET_DIR}" STREQUAL "${CUDA_TOOLKIT_TARGET_DIR_INTERNAL}") cuda_unset_include_and_libraries() endif() diff --git a/Modules/FindCUDA/select_compute_arch.cmake b/Modules/FindCUDA/select_compute_arch.cmake index a35b3f8..5fad337 100644 --- a/Modules/FindCUDA/select_compute_arch.cmake +++ b/Modules/FindCUDA/select_compute_arch.cmake @@ -135,10 +135,10 @@ function(CUDA_DETECT_INSTALLED_GPUS OUT_VARIABLE) "}\n") if(CMAKE_CUDA_COMPILER_LOADED) # CUDA as a language - try_run(run_result compile_result ${PROJECT_BINARY_DIR} ${file} + try_run(run_result compile_result SOURCES ${file} RUN_OUTPUT_VARIABLE compute_capabilities) else() - try_run(run_result compile_result ${PROJECT_BINARY_DIR} ${file} + try_run(run_result compile_result SOURCES ${file} CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${CUDA_INCLUDE_DIRS}" LINK_LIBRARIES ${CUDA_LIBRARIES} RUN_OUTPUT_VARIABLE compute_capabilities) diff --git a/Modules/FindCUDAToolkit.cmake b/Modules/FindCUDAToolkit.cmake index 5f83ccc..7699e28 100644 --- a/Modules/FindCUDAToolkit.cmake +++ b/Modules/FindCUDAToolkit.cmake @@ -109,6 +109,7 @@ of the following libraries that are part of the CUDAToolkit: - :ref:`CUDA Runtime Library<cuda_toolkit_rt_lib>` - :ref:`CUDA Driver Library<cuda_toolkit_driver_lib>` - :ref:`cuBLAS<cuda_toolkit_cuBLAS>` +- :ref:`cuFile<cuda_toolkit_cuFile>` - :ref:`cuFFT<cuda_toolkit_cuFFT>` - :ref:`cuRAND<cuda_toolkit_cuRAND>` - :ref:`cuSOLVER<cuda_toolkit_cuSOLVER>` @@ -119,8 +120,10 @@ of the following libraries that are part of the CUDAToolkit: - :ref:`nvGRAPH<cuda_toolkit_nvGRAPH>` - :ref:`nvJPEG<cuda_toolkit_nvJPEG>` - :ref:`nvidia-ML<cuda_toolkit_nvML>` +- :ref:`nvPTX Compiler<cuda_toolkit_nvptx>` - :ref:`nvRTC<cuda_toolkit_nvRTC>` - :ref:`nvToolsExt<cuda_toolkit_nvToolsExt>` +- :ref:`nvtx3<cuda_toolkit_nvtx3>` - :ref:`OpenCL<cuda_toolkit_opencl>` - :ref:`cuLIBOS<cuda_toolkit_cuLIBOS>` @@ -163,6 +166,22 @@ Targets Created: - ``CUDA::cublasLt`` starting in CUDA 10.1 - ``CUDA::cublasLt_static`` starting in CUDA 10.1 +.. _`cuda_toolkit_cuFile`: + +cuFile +"""""" + +.. versionadded:: 3.25 + +The NVIDIA GPUDirect Storage `cuFile <https://docs.nvidia.com/cuda/cufile-api/index.html>`_ library. + +Targets Created: + +- ``CUDA::cuFile`` starting in CUDA 11.4 +- ``CUDA::cuFile_static`` starting in CUDA 11.4 +- ``CUDA::cuFile_rdma`` starting in CUDA 11.4 +- ``CUDA::cuFile_rdma_static`` starting in CUDA 11.4 + .. _`cuda_toolkit_cuFFT`: cuFFT @@ -333,6 +352,22 @@ Targets Created: - ``CUDA::nvjpeg`` - ``CUDA::nvjpeg_static`` +.. _`cuda_toolkit_nvPTX`: + +nvPTX Compiler +"""""""""""""" + +.. versionadded:: 3.25 + +The `nvPTX <https://docs.nvidia.com/cuda/ptx-compiler-api/index.html>`_ (PTX Compilation) library. +The PTX Compiler APIs are a set of APIs which can be used to compile a PTX program into GPU assembly code. +Introduced in CUDA 11.1 +This is a static library only. + +Targets Created: + +- ``CUDA::nvptxcompiler`` starting in CUDA 11.1 + .. _`cuda_toolkit_nvRTC`: nvRTC @@ -362,6 +397,8 @@ Targets Created: nvToolsExt """""""""" +.. deprecated:: 3.25 With CUDA 10.0+, use :ref:`nvtx3 <cuda_toolkit_nvtx3>`. + The `NVIDIA Tools Extension <https://docs.nvidia.com/gameworks/content/gameworkslibrary/nvtx/nvidia_tools_extension_library_nvtx.htm>`_. This is a shared library only. @@ -369,6 +406,20 @@ Targets Created: - ``CUDA::nvToolsExt`` +.. _`cuda_toolkit_nvtx3`: + +nvtx3 +""""" + +.. versionadded:: 3.25 + +The header-only `NVIDIA Tools Extension Library <https://nvidia.github.io/NVTX/doxygen/index.html>`_. +Introduced in CUDA 10.0. + +Targets created: + +- ``CUDA::nvtx3`` + .. _`cuda_toolkit_opencl`: OpenCL @@ -942,6 +993,14 @@ if(CUDAToolkit_FOUND) _CUDAToolkit_find_and_add_import_lib(cublas_static DEPS culibos) endif() + if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 11.4) + _CUDAToolkit_find_and_add_import_lib(cuFile DEPS culibos) + _CUDAToolkit_find_and_add_import_lib(cuFile_static DEPS culibos) + + _CUDAToolkit_find_and_add_import_lib(cuFile_rdma DEPS cuFile culibos) + _CUDAToolkit_find_and_add_import_lib(cuFile_rdma_static DEPS cuFile_static culibos) + endif() + # cuFFTW depends on cuFFT _CUDAToolkit_find_and_add_import_lib(cufftw DEPS cufft) _CUDAToolkit_find_and_add_import_lib(cufftw_static DEPS cufft_static) @@ -998,6 +1057,9 @@ if(CUDAToolkit_FOUND) endif() _CUDAToolkit_find_and_add_import_lib(nvrtc DEPS cuda_driver) + if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 11.1.0) + _CUDAToolkit_find_and_add_import_lib(nvptxcompiler_static DEPS cuda_driver) + endif() _CUDAToolkit_find_and_add_import_lib(nvml ALT nvidia-ml nvml) @@ -1014,6 +1076,21 @@ if(CUDAToolkit_FOUND) endif() _CUDAToolkit_find_and_add_import_lib(nvToolsExt ALT nvToolsExt64) + if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 10.0) + # nvToolsExt is deprecated since nvtx3 introduction. + # Warn only if the project requires a sufficiently new CMake to make migration possible. + if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_GREATER_EQUAL 3.25) + set_property(TARGET CUDA::nvToolsExt PROPERTY DEPRECATION "nvToolsExt has been superseded by nvtx3 since CUDA 10.0 and CMake 3.25. Use CUDA::nvtx3 and include <nvtx3/nvToolsExt.h> instead.") + endif() + + # Header-only variant. Uses dlopen(). + if(NOT TARGET CUDA::nvtx3) + add_library(CUDA::nvtx3 INTERFACE IMPORTED) + target_include_directories(CUDA::nvtx3 SYSTEM INTERFACE "${CUDAToolkit_INCLUDE_DIRS}") + target_link_libraries(CUDA::nvtx3 INTERFACE ${CMAKE_DL_LIBS}) + endif() + endif() + _CUDAToolkit_find_and_add_import_lib(OpenCL) endif() diff --git a/Modules/FindCURL.cmake b/Modules/FindCURL.cmake index e37d225..acb87dc 100644 --- a/Modules/FindCURL.cmake +++ b/Modules/FindCURL.cmake @@ -72,6 +72,8 @@ if(NOT CURL_NO_CURL_CMAKE) # can print what we found and return. if(CURL_FOUND) find_package_handle_standard_args(CURL HANDLE_COMPONENTS CONFIG_MODE) + # The upstream curl package sets CURL_VERSION, not CURL_VERSION_STRING. + set(CURL_VERSION_STRING "${CURL_VERSION}") return() endif() endif() @@ -80,7 +82,6 @@ find_package(PkgConfig QUIET) if(PKG_CONFIG_FOUND) pkg_check_modules(PC_CURL QUIET libcurl) if(PC_CURL_FOUND) - set(CURL_VERSION_STRING ${PC_CURL_VERSION}) pkg_get_variable(CURL_SUPPORTED_PROTOCOLS libcurl supported_protocols) pkg_get_variable(CURL_SUPPORTED_FEATURES libcurl supported_features) endif() @@ -120,7 +121,7 @@ if(NOT CURL_LIBRARY) select_library_configurations(CURL) endif() -if(CURL_INCLUDE_DIR AND NOT CURL_VERSION_STRING) +if(CURL_INCLUDE_DIR) foreach(_curl_version_header curlver.h curl.h) if(EXISTS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}") file(STRINGS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}" curl_version_str REGEX "^#define[\t ]+LIBCURL_VERSION[\t ]+\".*\"") diff --git a/Modules/FindCoin3D.cmake b/Modules/FindCoin3D.cmake index 301e70b..5910ad1 100644 --- a/Modules/FindCoin3D.cmake +++ b/Modules/FindCoin3D.cmake @@ -31,11 +31,11 @@ if (WIN32) "[HKEY_LOCAL_MACHINE\\SOFTWARE\\SIM\\Coin3D\\2;Installation Path]/include" ) - find_library(COIN3D_LIBRARY_DEBUG coin2d + find_library(COIN3D_LIBRARY_DEBUG NAMES coin2d coin4d "[HKEY_LOCAL_MACHINE\\SOFTWARE\\SIM\\Coin3D\\2;Installation Path]/lib" ) - find_library(COIN3D_LIBRARY_RELEASE coin2 + find_library(COIN3D_LIBRARY_RELEASE NAMES coin2 coin4 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\SIM\\Coin3D\\2;Installation Path]/lib" ) diff --git a/Modules/FindDoxygen.cmake b/Modules/FindDoxygen.cmake index 4a16e31..23b7107 100644 --- a/Modules/FindDoxygen.cmake +++ b/Modules/FindDoxygen.cmake @@ -432,9 +432,44 @@ endif() # or use something like homebrew. # ============== End OSX stuff ================ +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) + # # Find Doxygen... # +function(_Doxygen_get_version doxy_version result_var doxy_path) + execute_process( + COMMAND "${doxy_path}" --version + OUTPUT_VARIABLE full_doxygen_version + OUTPUT_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE version_result + ) + + # Ignore any commit hashes, etc. + string(REGEX MATCH [[^[0-9]+\.[0-9]+\.[0-9]+]] sem_doxygen_version "${full_doxygen_version}") + + set(${result_var} ${version_result} PARENT_SCOPE) + set(${doxy_version} ${sem_doxygen_version} PARENT_SCOPE) +endfunction() + +function(_Doxygen_version_validator version_match doxy_path) + if(NOT DEFINED Doxygen_FIND_VERSION) + set(${is_valid_version} TRUE PARENT_SCOPE) + else() + _Doxygen_get_version(candidate_version version_result "${doxy_path}") + + if(version_result) + message(DEBUG "Unable to determine candidate doxygen version at ${doxy_path}: ${version_result}") + endif() + + find_package_check_version("${candidate_version}" valid_doxy_version + HANDLE_VERSION_RANGE + ) + + set(${version_match} "${valid_doxy_version}" PARENT_SCOPE) + endif() +endfunction() + macro(_Doxygen_find_doxygen) find_program( DOXYGEN_EXECUTABLE @@ -446,16 +481,13 @@ macro(_Doxygen_find_doxygen) /Applications/Utilities/Doxygen.app/Contents/Resources /Applications/Utilities/Doxygen.app/Contents/MacOS DOC "Doxygen documentation generation tool (http://www.doxygen.org)" + VALIDATOR _Doxygen_version_validator ) mark_as_advanced(DOXYGEN_EXECUTABLE) if(DOXYGEN_EXECUTABLE) - execute_process( - COMMAND "${DOXYGEN_EXECUTABLE}" --version - OUTPUT_VARIABLE DOXYGEN_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE - RESULT_VARIABLE _Doxygen_version_result - ) + _Doxygen_get_version(DOXYGEN_VERSION _Doxygen_version_result "${DOXYGEN_EXECUTABLE}") + if(_Doxygen_version_result) message(WARNING "Unable to determine doxygen version: ${_Doxygen_version_result}") endif() @@ -642,11 +674,11 @@ endforeach() unset(_comp) # Verify find results -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) find_package_handle_standard_args( Doxygen REQUIRED_VARS DOXYGEN_EXECUTABLE VERSION_VAR DOXYGEN_VERSION + HANDLE_VERSION_RANGE HANDLE_COMPONENTS ) diff --git a/Modules/FindGDAL.cmake b/Modules/FindGDAL.cmake index 5237e15..e6eac30 100644 --- a/Modules/FindGDAL.cmake +++ b/Modules/FindGDAL.cmake @@ -160,7 +160,7 @@ unset(_gdal_version) unset(_gdal_versions) find_library(GDAL_LIBRARY - NAMES ${_gdal_lib} ${_gdal_libnames} gdal gdal_i gdal1.5.0 gdal1.4.0 gdal1.3.2 GDAL + NAMES ${_gdal_lib} ${_gdal_libnames} gdal gdald gdal_i gdal1.5.0 gdal1.4.0 gdal1.3.2 GDAL HINTS ENV GDAL_DIR ENV GDAL_ROOT diff --git a/Modules/FindGLEW.cmake b/Modules/FindGLEW.cmake index b9ebe08..bfde40b 100644 --- a/Modules/FindGLEW.cmake +++ b/Modules/FindGLEW.cmake @@ -63,11 +63,36 @@ This module defines the following variables: #]=======================================================================] include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) find_package(GLEW CONFIG QUIET) if(GLEW_FOUND) find_package_handle_standard_args(GLEW DEFAULT_MSG GLEW_CONFIG) + get_target_property(GLEW_INCLUDE_DIRS GLEW::GLEW INTERFACE_INCLUDE_DIRECTORIES) + set(GLEW_INCLUDE_DIR ${GLEW_INCLUDE_DIRS}) + get_target_property(_GLEW_DEFS GLEW::GLEW INTERFACE_COMPILE_DEFINITIONS) + if("${_GLEW_DEFS}" MATCHES "GLEW_STATIC") + get_target_property(GLEW_LIBRARY_DEBUG GLEW::GLEW IMPORTED_LOCATION_DEBUG) + get_target_property(GLEW_LIBRARY_RELEASE GLEW::GLEW IMPORTED_LOCATION_RELEASE) + else() + get_target_property(GLEW_LIBRARY_DEBUG GLEW::GLEW IMPORTED_IMPLIB_DEBUG) + get_target_property(GLEW_LIBRARY_RELEASE GLEW::GLEW IMPORTED_IMPLIB_RELEASE) + endif() + get_target_property(_GLEW_LINK_INTERFACE GLEW::GLEW IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE) # same for debug and release + list(APPEND GLEW_LIBRARIES ${_GLEW_LINK_INTERFACE}) + list(APPEND GLEW_LIBRARY ${_GLEW_LINK_INTERFACE}) + select_library_configurations(GLEW) + if("${_GLEW_DEFS}" MATCHES "GLEW_STATIC") + set(GLEW_STATIC_LIBRARIES ${GLEW_LIBRARIES}) + else() + set(GLEW_SHARED_LIBRARIES ${GLEW_LIBRARIES}) + endif() + unset(_GLEW_DEFS) + unset(_GLEW_LINK_INTERFACE) + unset(GLEW_LIBRARY) + unset(GLEW_LIBRARY_DEBUG) + unset(GLEW_LIBRARY_RELEASE) return() endif() @@ -171,8 +196,6 @@ find_library(GLEW_STATIC_LIBRARY_DEBUG set(CMAKE_FIND_LIBRARY_SUFFIXES ${__GLEW_CURRENT_FIND_LIBRARY_SUFFIXES}) unset(__GLEW_CURRENT_FIND_LIBRARY_SUFFIXES) -include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) - select_library_configurations(GLEW_SHARED) select_library_configurations(GLEW_STATIC) diff --git a/Modules/FindGLUT.cmake b/Modules/FindGLUT.cmake index 320ddad..e0636b2 100644 --- a/Modules/FindGLUT.cmake +++ b/Modules/FindGLUT.cmake @@ -67,83 +67,39 @@ The following variables may also be provided, for backwards compatibility: include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -function(_add_glut_target_simple) - if(TARGET GLUT::GLUT) - return() - endif() - add_library(GLUT::GLUT INTERFACE IMPORTED) - if(GLUT_INCLUDE_DIRS) - target_include_directories(GLUT::GLUT SYSTEM - INTERFACE "${GLUT_INCLUDE_DIRS}") - endif() - if(GLUT_LIBRARIES) - target_link_libraries(GLUT::GLUT INTERFACE ${GLUT_LIBRARIES}) - endif() - if(GLUT_LIBRARY_DIRS) - target_link_directories(GLUT::GLUT INTERFACE ${GLUT_LIBRARY_DIRS}) - endif() - if(GLUT_LDFLAGS) - target_link_options(GLUT::GLUT INTERFACE ${GLUT_LDFLAGS}) - endif() - if(GLUT_CFLAGS) - separate_arguments(GLUT_CFLAGS_SPLIT UNIX_COMMAND "${GLUT_CFLAGS}") - target_compile_options(GLUT::GLUT INTERFACE ${GLUT_CFLAGS_SPLIT}) - endif() - - set_property(TARGET GLUT::GLUT APPEND PROPERTY - IMPORTED_LOCATION "${GLUT_glut_LIBRARY}") -endfunction() - find_package(PkgConfig QUIET) -if(PKG_CONFIG_FOUND) - # Tell pkg-config not to strip any -I flags to make sure GLUT_INCLUDE_DIRS - # will be defined. - if(DEFINED ENV{PKG_CONFIG_ALLOW_SYSTEM_CFLAGS}) - set(_pkgconfig_allow_system_cflags_old "$ENV{PKG_CONFIG_ALLOW_SYSTEM_CFLAGS}") - else() - unset(_pkgconfig_allow_system_cflags_old) - endif() - set(ENV{PKG_CONFIG_ALLOW_SYSTEM_CFLAGS} 1) - pkg_check_modules(GLUT QUIET glut) - if(DEFINED _pkgconfig_allow_system_cflags_old) - set(ENV{PKG_CONFIG_ALLOW_SYSTEM_CFLAGS} "${_pkgconfig_allow_system_cflags_old}") - unset(_pkgconfig_allow_system_cflags_old) - else() - unset(ENV{PKG_CONFIG_ALLOW_SYSTEM_CFLAGS}) - endif() - if(NOT GLUT_FOUND) - pkg_check_modules(GLUT QUIET freeglut) - endif() - if(GLUT_FOUND) - # GLUT_INCLUDE_DIRS is now the official result variable, but - # older versions of CMake only provided GLUT_INCLUDE_DIR. - set(GLUT_INCLUDE_DIR "${GLUT_INCLUDE_DIRS}") - _add_glut_target_simple() - FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLUT REQUIRED_VARS GLUT_FOUND) - return() - endif() +pkg_check_modules(PC_GLUT QUIET glut) +if(NOT PC_GLUT_FOUND) + pkg_check_modules(PC_GLUT QUIET freeglut) endif() if(WIN32) find_path( GLUT_INCLUDE_DIR NAMES GL/glut.h - PATHS ${GLUT_ROOT_PATH}/include ) + PATHS ${GLUT_ROOT_PATH}/include + HINTS ${PC_GLUT_INCLUDE_DIRS}) mark_as_advanced(GLUT_INCLUDE_DIR) find_library( GLUT_glut_LIBRARY_RELEASE NAMES freeglut glut glut32 PATHS ${OPENGL_LIBRARY_DIR} ${GLUT_ROOT_PATH}/Release + HINTS + ${PC_GLUT_LIBRARY_DIRS} ) +# N.B. As the pkg-config cannot distinguish between release and debug libraries, +# assume that their hint was the both Debug and Release library. find_library( GLUT_glut_LIBRARY_DEBUG NAMES freeglutd PATHS ${OPENGL_LIBRARY_DIR} ${GLUT_ROOT_PATH}/Debug + HINTS + ${PC_GLUT_LIBRARY_DIRS} ) mark_as_advanced(GLUT_glut_LIBRARY_RELEASE GLUT_glut_LIBRARY_DEBUG) select_library_configurations(GLUT_glut) elseif(APPLE) - find_path(GLUT_INCLUDE_DIR glut.h ${OPENGL_LIBRARY_DIR}) + find_path(GLUT_INCLUDE_DIR glut.h PATHS ${OPENGL_LIBRARY_DIR} HINTS ${PC_GLUT_INCLUDE_DIRS}) mark_as_advanced(GLUT_INCLUDE_DIR) - find_library(GLUT_glut_LIBRARY GLUT DOC "GLUT library for OSX") + find_library(GLUT_glut_LIBRARY GLUT HINTS ${PC_GLUT_LIBRARY_DIRS} DOC "GLUT library for OSX") find_library(GLUT_cocoa_LIBRARY Cocoa DOC "Cocoa framework for OSX") mark_as_advanced(GLUT_glut_LIBRARY GLUT_cocoa_LIBRARY) @@ -192,18 +148,24 @@ else() endif () find_path( GLUT_INCLUDE_DIR GL/glut.h + PATHS /usr/include/GL /usr/openwin/share/include /usr/openwin/include /opt/graphics/OpenGL/include /opt/graphics/OpenGL/contrib/libglut ${_GLUT_INC_DIR} + HINTS + ${PC_GLUT_INCLUDE_DIRS} ) mark_as_advanced(GLUT_INCLUDE_DIR) find_library( GLUT_glut_LIBRARY glut + PATHS /usr/openwin/lib ${_GLUT_glut_LIB_DIR} + HINTS + ${PC_GLUT_LIBRARY_DIRS} ) mark_as_advanced(GLUT_glut_LIBRARY) diff --git a/Modules/FindGTK2.cmake b/Modules/FindGTK2.cmake index 00bfc29..4634876 100644 --- a/Modules/FindGTK2.cmake +++ b/Modules/FindGTK2.cmake @@ -313,6 +313,7 @@ function(_GTK2_FIND_INCLUDE_DIR _var _hdr) /usr/openwin/lib /sw/lib /opt/local/lib + /opt/homebrew/lib /usr/pkg/lib /usr/pkg/include/glib $ENV{GTKMM_BASEPATH}/include diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 40ed9a9..d662a7d 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -238,7 +238,7 @@ function(_HDF5_test_regular_compiler_C success version is_parallel) " fid = H5Fcreate(\"foo.h5\",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT);\n" " return 0;\n" "}") - try_compile(${success} ${scratch_directory} ${test_file} + try_compile(${success} SOURCES ${test_file} COPY_FILE ${scratch_directory}/compiler_has_h5_c ) endif() @@ -286,7 +286,7 @@ function(_HDF5_test_regular_compiler_CXX success version is_parallel) " H5File file(\"foo.h5\", H5F_ACC_TRUNC);\n" " return 0;\n" "}") - try_compile(${success} ${scratch_directory} ${test_file} + try_compile(${success} SOURCES ${test_file} COPY_FILE ${scratch_directory}/compiler_has_h5_cxx ) endif() @@ -323,7 +323,7 @@ function(_HDF5_test_regular_compiler_Fortran success is_parallel) " call h5open_f(error)\n" " call h5close_f(error)\n" "end\n") - try_compile(${success} ${scratch_directory} ${test_file}) + try_compile(${success} SOURCES ${test_file}) if(${success}) execute_process(COMMAND ${CMAKE_Fortran_COMPILER} -showconfig OUTPUT_VARIABLE config_output diff --git a/Modules/FindICU.cmake b/Modules/FindICU.cmake index 91dcba5..b4f4d71 100644 --- a/Modules/FindICU.cmake +++ b/Modules/FindICU.cmake @@ -254,13 +254,6 @@ function(_ICU_FIND) set("${component_found}" ON) set("${component_found_compat}" ON) list(APPEND ICU_LIBRARY "${${component_cache}}") - endif() - mark_as_advanced("${component_found}") - mark_as_advanced("${component_found_compat}") - set("${component_cache}" "${${component_cache}}" PARENT_SCOPE) - set("${component_found}" "${${component_found}}" PARENT_SCOPE) - set("${component_found_compat}" "${${component_found_compat}}" PARENT_SCOPE) - if(component_found OR component_found_compat) if (ICU_FIND_REQUIRED_${component}) list(APPEND ICU_LIBS_FOUND "${component} (required): ${${component_cache}}") else() @@ -274,6 +267,11 @@ function(_ICU_FIND) list(APPEND ICU_LIBS_NOTFOUND "${component} (optional)") endif() endif() + mark_as_advanced("${component_found}") + mark_as_advanced("${component_found_compat}") + set("${component_cache}" "${${component_cache}}" PARENT_SCOPE) + set("${component_found}" "${${component_found}}" PARENT_SCOPE) + set("${component_found_compat}" "${${component_found_compat}}" PARENT_SCOPE) endforeach() set(_ICU_REQUIRED_LIBS_FOUND "${ICU_REQUIRED_LIBS_FOUND}" PARENT_SCOPE) set(ICU_LIBRARY "${ICU_LIBRARY}" PARENT_SCOPE) diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index b08b359..4151116 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -35,6 +35,13 @@ The following variables may be set to influence this module's behavior: if set ``pkg-config`` will be used to search for a LAPACK library first and if one is found that is preferred +``BLA_PKGCONFIG_LAPACK`` + .. versionadded:: 3.25 + + If set, the ``pkg-config`` method will look for this module name instead of + just ``lapack``. + + ``BLA_SIZEOF_INTEGER`` .. versionadded:: 3.22 @@ -278,8 +285,11 @@ endif() # Search with pkg-config if specified if(BLA_PREFER_PKGCONFIG) + if(NOT BLA_PKGCONFIG_LAPACK) + set(BLA_PKGCONFIG_LAPACK "lapack") + endif() find_package(PkgConfig QUIET) - pkg_check_modules(PKGC_LAPACK QUIET lapack) + pkg_check_modules(PKGC_LAPACK QUIET ${BLA_PKGCONFIG_LAPACK}) if(PKGC_LAPACK_FOUND) set(LAPACK_FOUND TRUE) set(LAPACK_LIBRARIES "${PKGC_LAPACK_LINK_LIBRARIES}") diff --git a/Modules/FindLibArchive.cmake b/Modules/FindLibArchive.cmake index 08078a2..9d3ac13 100644 --- a/Modules/FindLibArchive.cmake +++ b/Modules/FindLibArchive.cmake @@ -26,6 +26,9 @@ The module defines the following ``IMPORTED`` targets: .. versionadded:: 3.6 Support for new libarchive 3.2 version string format. +.. versionadded:: 3.17 + Provides an imported target. + #]=======================================================================] find_path(LibArchive_INCLUDE_DIR diff --git a/Modules/FindMFC.cmake b/Modules/FindMFC.cmake index b8ca71b..2d5de89 100644 --- a/Modules/FindMFC.cmake +++ b/Modules/FindMFC.cmake @@ -29,23 +29,19 @@ endif() if(MFC_ATTEMPT_TRY_COMPILE) if(NOT DEFINED MFC_HAVE_MFC) set(CHECK_INCLUDE_FILE_VAR "afxwin.h") - configure_file(${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx) + file(READ ${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in _CIF_SOURCE_CONTENT) + string(CONFIGURE "${_CIF_SOURCE_CONTENT}" _CIF_SOURCE_CONTENT) message(CHECK_START "Looking for MFC") # Try both shared and static as the root project may have set the /MT flag try_compile(MFC_HAVE_MFC - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx + SOURCE_FROM_VAR CheckIncludeFile.cxx _CIF_SOURCE_CONTENT CMAKE_FLAGS -DCMAKE_MFC_FLAG:STRING=2 -DCOMPILE_DEFINITIONS:STRING=-D_AFXDLL OUTPUT_VARIABLE OUTPUT) if(NOT MFC_HAVE_MFC) - configure_file(${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx) try_compile(MFC_HAVE_MFC - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx + SOURCE_FROM_VAR CheckIncludeFile.cxx _CIF_SOURCE_CONTENT CMAKE_FLAGS -DCMAKE_MFC_FLAG:STRING=1 OUTPUT_VARIABLE OUTPUT) diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index bca0c10..e15be91 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -391,11 +391,11 @@ function (_MPI_check_compiler LANG QUERY_FLAG OUTPUT_VARIABLE RESULT_VARIABLE) # library that has invalid or missing version information there would be warning # messages emitted by ld.so in the compiler output. In either case, we'll treat # the output as invalid. - if("${WRAPPER_OUTPUT}" MATCHES "undefined reference|unrecognized|need to set|no version information available|command not found") + if(WRAPPER_OUTPUT MATCHES "undefined reference|unrecognized|need to set|no version information available|command not found") set(WRAPPER_RETURN 255) endif() # Ensure that no error output might be passed upwards. - if(NOT WRAPPER_RETURN EQUAL 0) + if(NOT WRAPPER_RETURN EQUAL "0") unset(WRAPPER_OUTPUT) else() # Strip leading whitespace @@ -441,13 +441,13 @@ function (_MPI_interrogate_compiler LANG) if(MSVC) get_filename_component(_MPI_UNDERLAYING_COMPILER "${_MPI_UNDERLAYING_COMPILER}" NAME) endif() - if("${LANG}" STREQUAL "C") + if(LANG STREQUAL "C") _MPI_env_set_ifnot(I_MPI_CC _MPI_UNDERLAYING_COMPILER) _MPI_env_set_ifnot(MPICH_CC _MPI_UNDERLAYING_COMPILER) - elseif("${LANG}" STREQUAL "CXX") + elseif(LANG STREQUAL "CXX") _MPI_env_set_ifnot(I_MPI_CXX _MPI_UNDERLAYING_COMPILER) _MPI_env_set_ifnot(MPICH_CXX _MPI_UNDERLAYING_COMPILER) - elseif("${LANG}" STREQUAL "Fortran") + elseif(LANG STREQUAL "Fortran") _MPI_env_set_ifnot(I_MPI_FC _MPI_UNDERLAYING_COMPILER) _MPI_env_set_ifnot(MPICH_FC _MPI_UNDERLAYING_COMPILER) _MPI_env_set_ifnot(I_MPI_F77 _MPI_UNDERLAYING_COMPILER) @@ -470,10 +470,10 @@ function (_MPI_interrogate_compiler LANG) # or a newer version of LAM/MPI, and implies that -showme:link will also work. # Open MPI also supports -show, but separates linker and compiler information _MPI_check_compiler(${LANG} "-showme:compile" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) - if (MPI_COMPILER_RETURN EQUAL 0) + if (MPI_COMPILER_RETURN EQUAL "0") _MPI_check_compiler(${LANG} "-showme:link" MPI_LINK_CMDLINE MPI_COMPILER_RETURN) - if (NOT MPI_COMPILER_RETURN EQUAL 0) + if (NOT MPI_COMPILER_RETURN EQUAL "0") unset(MPI_COMPILE_CMDLINE) endif() endif() @@ -482,13 +482,13 @@ function (_MPI_interrogate_compiler LANG) # For modern versions, both do the same as -show. However, for old versions, they do differ # when called for mpicxx and mpif90 and it's necessary to use them over -show in order to find the # removed MPI C++ bindings. - if (NOT MPI_COMPILER_RETURN EQUAL 0) + if (NOT MPI_COMPILER_RETURN EQUAL "0") _MPI_check_compiler(${LANG} "-compile-info" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) - if (MPI_COMPILER_RETURN EQUAL 0) + if (MPI_COMPILER_RETURN EQUAL "0") _MPI_check_compiler(${LANG} "-link-info" MPI_LINK_CMDLINE MPI_COMPILER_RETURN) - if (NOT MPI_COMPILER_RETURN EQUAL 0) + if (NOT MPI_COMPILER_RETURN EQUAL "0") unset(MPI_COMPILE_CMDLINE) endif() endif() @@ -496,18 +496,18 @@ function (_MPI_interrogate_compiler LANG) # Cray compiler wrappers come usually without a separate mpicc/c++/ftn, but offer # --cray-print-opts=... - if (NOT MPI_COMPILER_RETURN EQUAL 0) + if (NOT MPI_COMPILER_RETURN EQUAL "0") _MPI_check_compiler(${LANG} "--cray-print-opts=cflags" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) - if (MPI_COMPILER_RETURN EQUAL 0) + if (MPI_COMPILER_RETURN EQUAL "0") # Pass --no-as-needed so the mpi library is always linked. Otherwise, the # Cray compiler wrapper puts an --as-needed flag around the mpi library, # and it is not linked unless code directly refers to it. _MPI_check_compiler(${LANG} "--no-as-needed;--cray-print-opts=libs" MPI_LINK_CMDLINE MPI_COMPILER_RETURN) - if (NOT MPI_COMPILER_RETURN EQUAL 0) + if (NOT MPI_COMPILER_RETURN EQUAL "0") unset(MPI_COMPILE_CMDLINE) unset(MPI_LINK_CMDLINE) endif() @@ -516,24 +516,24 @@ function (_MPI_interrogate_compiler LANG) # MPICH, MVAPICH2 and Intel MPI just use "-show". Open MPI also offers this, but the # -showme commands are more specialized. - if (NOT MPI_COMPILER_RETURN EQUAL 0) + if (NOT MPI_COMPILER_RETURN EQUAL "0") _MPI_check_compiler(${LANG} "-show" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) endif() # Older versions of LAM/MPI have "-showme". Open MPI also supports this. # Unknown to MPICH, MVAPICH and Intel MPI. - if (NOT MPI_COMPILER_RETURN EQUAL 0) + if (NOT MPI_COMPILER_RETURN EQUAL "0") _MPI_check_compiler(${LANG} "-showme" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) endif() - if (MPI_COMPILER_RETURN EQUAL 0 AND DEFINED MPI_COMPILE_CMDLINE) + if (MPI_COMPILER_RETURN EQUAL "0" AND DEFINED MPI_COMPILE_CMDLINE) # Intel MPI can be run with -compchk or I_MPI_CHECK_COMPILER set to 1. # In this case, -show will be prepended with a line to the compiler checker. This is a script that performs # compatibility checks and returns a non-zero exit code together with an error if something fails. # It has to be called as "compchk.sh <arch> <compiler>". Here, <arch> is one out of 32 (i686), 64 (ia64) or 32e (x86_64). # The compiler is identified by filename, and can be either the MPI compiler or the underlying compiler. # NOTE: It is vital to run this script while the environment variables are set up, otherwise it can check the wrong compiler. - if("${MPI_COMPILE_CMDLINE}" MATCHES "^([^\" ]+/compchk.sh|\"[^\"]+/compchk.sh\") +([^ ]+)") + if(MPI_COMPILE_CMDLINE MATCHES "^([^\" ]+/compchk.sh|\"[^\"]+/compchk.sh\") +([^ ]+)") # Now CMAKE_MATCH_1 contains the path to the compchk.sh file and CMAKE_MATCH_2 the architecture flag. unset(COMPILER_CHECKER_OUTPUT) execute_process( @@ -542,7 +542,7 @@ function (_MPI_interrogate_compiler LANG) ERROR_VARIABLE COMPILER_CHECKER_OUTPUT ERROR_STRIP_TRAILING_WHITESPACE RESULT_VARIABLE MPI_COMPILER_RETURN) # If it returned a non-zero value, the check below will fail and cause the interrogation to be aborted. - if(NOT MPI_COMPILER_RETURN EQUAL 0) + if(NOT MPI_COMPILER_RETURN EQUAL "0") if(NOT MPI_FIND_QUIETLY) message(STATUS "Intel MPI compiler check failed: ${COMPILER_CHECKER_OUTPUT}") endif() @@ -554,13 +554,13 @@ function (_MPI_interrogate_compiler LANG) endif() # Revert changes to the environment made previously - if("${LANG}" STREQUAL "C") + if(LANG STREQUAL "C") _MPI_env_unset_ifnot(I_MPI_CC) _MPI_env_unset_ifnot(MPICH_CC) - elseif("${LANG}" STREQUAL "CXX") + elseif(LANG STREQUAL "CXX") _MPI_env_unset_ifnot(I_MPI_CXX) _MPI_env_unset_ifnot(MPICH_CXX) - elseif("${LANG}" STREQUAL "Fortran") + elseif(LANG STREQUAL "Fortran") _MPI_env_unset_ifnot(I_MPI_FC) _MPI_env_unset_ifnot(MPICH_FC) _MPI_env_unset_ifnot(I_MPI_F77) @@ -572,7 +572,7 @@ function (_MPI_interrogate_compiler LANG) _MPI_env_unset_ifnot(I_MPI_DEBUG_INFO_STRIP) _MPI_env_unset_ifnot(I_MPI_FORT_BIND) - if (NOT (MPI_COMPILER_RETURN EQUAL 0) OR NOT (DEFINED MPI_COMPILE_CMDLINE)) + if (NOT (MPI_COMPILER_RETURN EQUAL "0") OR NOT (DEFINED MPI_COMPILE_CMDLINE)) # Cannot interrogate this compiler, so exit. set(MPI_${LANG}_WRAPPER_FOUND FALSE PARENT_SCOPE) return() @@ -613,13 +613,13 @@ function (_MPI_interrogate_compiler LANG) if(UNIX) # At this point, we obtained some output from a compiler wrapper that works. # We'll now try to parse it into variables with meaning to us. - if("${LANG}" STREQUAL "Fortran") + if(LANG STREQUAL "Fortran") # If MPICH (and derivates) didn't recognize the Fortran compiler include flag during configuration, # they'll return a set of three commands, consisting out of a symlink command for mpif.h, # the actual compiler command and deletion of the created symlink. # Especially with M(VA)PICH-1, this appears to happen erroneously, and therefore we should translate # this output into an additional include directory and then drop it from the output. - if("${MPI_COMPILE_CMDLINE}" MATCHES "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h") + if(MPI_COMPILE_CMDLINE MATCHES "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h") get_filename_component(MPI_INCLUDE_DIRS_WORK "${CMAKE_MATCH_1}" DIRECTORY) string(REGEX REPLACE "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h\n" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}") string(REGEX REPLACE "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h\n" "" MPI_LINK_CMDLINE "${MPI_LINK_CMDLINE}") @@ -651,7 +651,7 @@ function (_MPI_interrogate_compiler LANG) # produce inconsistent results with the regularly flags. # Similarly, aliasing flags do not belong into our flag array. # Also strip out `-framework` flags. - if(NOT "${_MPI_COMPILE_OPTION}" MATCHES "^-f((no-|)(stack-protector|strict-aliasing)|PI[CE]|pi[ce]|ramework)") + if(NOT _MPI_COMPILE_OPTION MATCHES "^-f((no-|)(stack-protector|strict-aliasing)|PI[CE]|pi[ce]|ramework)") list(APPEND MPI_COMPILE_OPTIONS_WORK "${_MPI_COMPILE_OPTION}") endif() endforeach() @@ -673,7 +673,7 @@ function (_MPI_interrogate_compiler LANG) foreach(_MPI_COMPILE_DEFINITION IN LISTS MPI_ALL_COMPILE_DEFINITIONS) string(REGEX REPLACE "^ ?${_MPI_PREPROCESSOR_FLAG_REGEX}-D *" "" _MPI_COMPILE_DEFINITION "${_MPI_COMPILE_DEFINITION}") string(REPLACE "\"" "" _MPI_COMPILE_DEFINITION "${_MPI_COMPILE_DEFINITION}") - if(NOT "${_MPI_COMPILE_DEFINITION}" MATCHES "^_FORTIFY_SOURCE.*") + if(NOT _MPI_COMPILE_DEFINITION MATCHES "^_FORTIFY_SOURCE.*") list(APPEND MPI_COMPILE_DEFINITIONS_WORK "${_MPI_COMPILE_DEFINITION}") endif() endforeach() @@ -788,7 +788,7 @@ function (_MPI_interrogate_compiler LANG) # decide how to link it based on file type, not based on a prefix like 'lib'. set(_MPI_LIB_SUFFIX_REGEX "${CMAKE_STATIC_LIBRARY_SUFFIX}") if(DEFINED CMAKE_IMPORT_LIBRARY_SUFFIX) - if(NOT ("${CMAKE_IMPORT_LIBRARY_SUFFIX}" STREQUAL "${CMAKE_STATIC_LIBRARY_SUFFIX}")) + if(NOT (CMAKE_IMPORT_LIBRARY_SUFFIX STREQUAL CMAKE_STATIC_LIBRARY_SUFFIX)) string(APPEND _MPI_LIB_SUFFIX_REGEX "|${CMAKE_IMPORT_LIBRARY_SUFFIX}") endif() else() @@ -804,7 +804,7 @@ function (_MPI_interrogate_compiler LANG) if(_MPI_LIB_NAME_TEST STREQUAL "") string(REGEX REPLACE "^ +\"?|\"? +$" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_NAME}" DIRECTORY) - if(NOT "${_MPI_LIB_PATH}" STREQUAL "") + if(NOT _MPI_LIB_PATH STREQUAL "") list(APPEND MPI_LIB_FULLPATHS_WORK "${_MPI_LIB_NAME}") else() list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}") @@ -845,7 +845,7 @@ function (_MPI_interrogate_compiler LANG) foreach(_MPI_LINK_DIRECTORY IN LISTS MPI_LINK_DIRECTORIES_LEFTOVER) file(TO_NATIVE_PATH "${_MPI_LINK_DIRECTORY}" _MPI_LINK_DIRECTORY_ACTUAL) string(FIND "${_MPI_LINK_DIRECTORY_ACTUAL}" " " _MPI_LINK_DIRECTORY_CONTAINS_SPACE) - if(NOT _MPI_LINK_DIRECTORY_CONTAINS_SPACE EQUAL -1) + if(NOT _MPI_LINK_DIRECTORY_CONTAINS_SPACE EQUAL "-1") set(_MPI_LINK_DIRECTORY_ACTUAL "\"${_MPI_LINK_DIRECTORY_ACTUAL}\"") endif() if(MPI_LINK_FLAGS_WORK) @@ -871,7 +871,7 @@ function (_MPI_interrogate_compiler LANG) # MPI might require pthread to work. The above mechanism wouldn't detect it, but we need to # link it in that case. -lpthread is covered by the normal library treatment on the other hand. - if("${MPI_COMPILE_CMDLINE}" MATCHES "-pthread") + if(MPI_COMPILE_CMDLINE MATCHES "-pthread") list(APPEND MPI_COMPILE_OPTIONS_WORK "-pthread") if(MPI_LINK_FLAGS_WORK) string(APPEND MPI_LINK_FLAGS_WORK " -pthread") @@ -918,10 +918,10 @@ function(_MPI_guess_settings LANG) # The environment variables MSMPI_INC and MSMPILIB32/64 are the only ways of locating the MSMPI_SDK, # which is installed separately from the runtime. Thus it's possible to have mpiexec but not MPI headers # or import libraries and vice versa. - if(NOT MPI_GUESS_LIBRARY_NAME OR "${MPI_GUESS_LIBRARY_NAME}" STREQUAL "MSMPI") + if(NOT MPI_GUESS_LIBRARY_NAME OR MPI_GUESS_LIBRARY_NAME STREQUAL "MSMPI") # We first attempt to locate the msmpi.lib. Should be find it, we'll assume that the MPI present is indeed # Microsoft MPI. - if("${CMAKE_SIZEOF_VOID_P}" EQUAL 8) + if(CMAKE_SIZEOF_VOID_P EQUAL "8") file(TO_CMAKE_PATH "$ENV{MSMPI_LIB64}" MPI_MSMPI_LIB_PATH) file(TO_CMAKE_PATH "$ENV{MSMPI_INC}/x64" MPI_MSMPI_INC_PATH_EXTRA) else() @@ -975,9 +975,9 @@ function(_MPI_guess_settings LANG) # Our strategy is now to locate all libraries, but enter msmpifec into the LIB_NAMES array. # Should this not be adequate it's a straightforward way for a user to change the LIB_NAMES array and # have his library found. Still, this should not be necessary outside of exceptional cases, as reasoned. - if ("${LANG}" STREQUAL "Fortran") + if (LANG STREQUAL "Fortran") set(MPI_MSMPI_CALLINGCONVS c) - if("${CMAKE_SIZEOF_VOID_P}" EQUAL 4) + if(CMAKE_SIZEOF_VOID_P EQUAL "4") list(APPEND MPI_MSMPI_CALLINGCONVS s) endif() foreach(mpistrlenpos IN ITEMS e m) @@ -1025,7 +1025,7 @@ function(_MPI_guess_settings LANG) # At this point there's not many MPIs that we could still consider. # OpenMPI 1.6.x and below supported Windows, but these ship compiler wrappers that still work. # The only other relevant MPI implementation without a wrapper is MPICH2, which had Windows support in 1.4.1p1 and older. - if(NOT MPI_GUESS_FOUND AND (NOT MPI_GUESS_LIBRARY_NAME OR "${MPI_GUESS_LIBRARY_NAME}" STREQUAL "MPICH2")) + if(NOT MPI_GUESS_FOUND AND (NOT MPI_GUESS_LIBRARY_NAME OR MPI_GUESS_LIBRARY_NAME STREQUAL "MPICH2")) set(MPI_MPICH_PREFIX_PATHS "$ENV{ProgramW6432}/MPICH2/lib" "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH\\SMPD;binary]/../lib" @@ -1042,7 +1042,7 @@ function(_MPI_guess_settings LANG) set(MPI_MPICH_LIB_NAMES "mpi") # If MPI-2 C++ bindings are requested, we need to locate cxx.lib as well. # Otherwise, MPICH_SKIP_MPICXX will be defined and these bindings aren't needed. - if("${LANG}" STREQUAL "CXX" AND NOT MPI_CXX_SKIP_MPICXX) + if(LANG STREQUAL "CXX" AND NOT MPI_CXX_SKIP_MPICXX) find_library(MPI_cxx_LIBRARY NAMES cxx HINTS ${MPI_MPICH_PREFIX_PATHS}) @@ -1055,7 +1055,7 @@ function(_MPI_guess_settings LANG) # fmpich2s.lib would be useful for Compaq Visual Fortran, fmpich2g.lib has to be used with GNU g77 and is also # provided in the form of an .a archive for MinGW and Cygwin. From our perspective, fmpich2.lib is the only one # we need to try, and if it doesn't work with the given Fortran compiler we'd find out later on during validation - elseif("${LANG}" STREQUAL "Fortran") + elseif(LANG STREQUAL "Fortran") find_library(MPI_fmpich2_LIBRARY NAMES fmpich2 HINTS ${MPI_MPICH_PREFIX_PATHS}) @@ -1103,7 +1103,7 @@ function(_MPI_guess_settings LANG) endfunction() function(_MPI_adjust_compile_definitions LANG) - if("${LANG}" STREQUAL "CXX") + if(LANG STREQUAL "CXX") # To disable the C++ bindings, we need to pass some definitions since the mpi.h header has to deal with both C and C++ # bindings in MPI-2. if(MPI_CXX_SKIP_MPICXX AND NOT MPI_${LANG}_COMPILE_DEFINITIONS MATCHES "SKIP_MPICXX") @@ -1119,7 +1119,7 @@ endfunction() macro(_MPI_assemble_libraries LANG) set(MPI_${LANG}_LIBRARIES "") # Only for libraries do we need to check whether the compiler's linking stage is separate. - if(NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}" OR NOT MPI_${LANG}_WORKS_IMPLICIT) + if(NOT MPI_${LANG}_COMPILER STREQUAL CMAKE_${LANG}_COMPILER OR NOT MPI_${LANG}_WORKS_IMPLICIT) foreach(mpilib IN LISTS MPI_${LANG}_LIB_NAMES) list(APPEND MPI_${LANG}_LIBRARIES ${MPI_${mpilib}_LIBRARY}) endforeach() @@ -1131,7 +1131,7 @@ macro(_MPI_assemble_include_dirs LANG) ${MPI_${LANG}_COMPILER_INCLUDE_DIRS} ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} ) - if("${LANG}" MATCHES "(C|CXX)") + if(LANG MATCHES "^(C|CXX)$") if(MPI_${LANG}_HEADER_DIR) list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_HEADER_DIR}") endif() @@ -1156,7 +1156,7 @@ macro(_MPI_split_include_dirs LANG) # We try to find the headers/modules among those paths (and system paths) # For C/C++, we just need to have a look for mpi.h. - if("${LANG}" MATCHES "(C|CXX)") + if(LANG MATCHES "^(C|CXX)$") find_path(MPI_${LANG}_HEADER_DIR "mpi.h" HINTS ${MPI_${LANG}_COMPILER_INCLUDE_DIRS} @@ -1171,7 +1171,7 @@ macro(_MPI_split_include_dirs LANG) # any of the Fortran 77/90/2008 APIs for MPI. For example, MSMPI # only provides Fortran 77 and - if mpi.f90 is built - potentially # a Fortran 90 module. - elseif("${LANG}" STREQUAL "Fortran") + elseif(LANG STREQUAL "Fortran") find_path(MPI_${LANG}_F77_HEADER_DIR "mpif.h" HINTS ${MPI_${LANG}_COMPILER_INCLUDE_DIRS} @@ -1238,28 +1238,30 @@ function(_MPI_try_staged_settings LANG MPI_TEST_FILE_NAME MODE RUN_BINARY SUPPRE set(SRC_DIR "${CMAKE_ROOT}/Modules/FindMPI") set(BIN_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI/${MPI_TEST_FILE_NAME}_${LANG}.bin") unset(MPI_TEST_COMPILE_DEFINITIONS) - if("${LANG}" STREQUAL "Fortran") - if("${MODE}" STREQUAL "F90_MODULE") + if(LANG STREQUAL "Fortran") + if(MODE STREQUAL "F90_MODULE") set(MPI_Fortran_INCLUDE_LINE "use mpi\n implicit none") - elseif("${MODE}" STREQUAL "F08_MODULE") + elseif(MODE STREQUAL "F08_MODULE") set(MPI_Fortran_INCLUDE_LINE "use mpi_f08\n implicit none") else() # F77 header set(MPI_Fortran_INCLUDE_LINE "implicit none\n include 'mpif.h'") endif() - configure_file("${SRC_DIR}/${MPI_TEST_FILE_NAME}.f90.in" "${WORK_DIR}/${MPI_TEST_FILE_NAME}.f90" @ONLY) - set(MPI_TEST_SOURCE_FILE "${WORK_DIR}/${MPI_TEST_FILE_NAME}.f90") - elseif("${LANG}" STREQUAL "CXX") - configure_file("${SRC_DIR}/${MPI_TEST_FILE_NAME}.c" "${WORK_DIR}/${MPI_TEST_FILE_NAME}.cpp" COPYONLY) - set(MPI_TEST_SOURCE_FILE "${WORK_DIR}/${MPI_TEST_FILE_NAME}.cpp") - if("${MODE}" STREQUAL "TEST_MPICXX") + file(READ "${SRC_DIR}/${MPI_TEST_FILE_NAME}.f90.in" MPI_TEST_SOURCE_CONTENT) + string(CONFIGURE "${MPI_TEST_SOURCE_CONTENT}" MPI_TEST_SOURCE_CONTENT) + set(MPI_TEST_SOURCE_FILE "${MPI_TEST_FILE_NAME}.f90") + elseif(LANG STREQUAL "CXX") + file(READ "${SRC_DIR}/${MPI_TEST_FILE_NAME}.c" MPI_TEST_SOURCE_CONTENT) + set(MPI_TEST_SOURCE_FILE "${MPI_TEST_FILE_NAME}.cpp") + if(MODE STREQUAL "TEST_MPICXX") set(MPI_TEST_COMPILE_DEFINITIONS TEST_MPI_MPICXX) endif() else() # C - set(MPI_TEST_SOURCE_FILE "${SRC_DIR}/${MPI_TEST_FILE_NAME}.c") + file(READ "${SRC_DIR}/${MPI_TEST_FILE_NAME}.c" MPI_TEST_SOURCE_CONTENT) + set(MPI_TEST_SOURCE_FILE "${MPI_TEST_FILE_NAME}.c") endif() if(RUN_BINARY) try_run(MPI_RUN_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} MPI_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} - "${CMAKE_BINARY_DIR}" SOURCES "${MPI_TEST_SOURCE_FILE}" + SOURCE_FROM_VAR "${MPI_TEST_SOURCE_FILE}" MPI_TEST_SOURCE_CONTENT COMPILE_DEFINITIONS ${MPI_TEST_COMPILE_DEFINITIONS} LINK_LIBRARIES MPI::MPI_${LANG} RUN_OUTPUT_VARIABLE MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} @@ -1267,7 +1269,7 @@ function(_MPI_try_staged_settings LANG MPI_TEST_FILE_NAME MODE RUN_BINARY SUPPRE set(MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} "${MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE}}" PARENT_SCOPE) else() try_compile(MPI_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} - "${CMAKE_BINARY_DIR}" SOURCES "${MPI_TEST_SOURCE_FILE}" + SOURCE_FROM_VAR "${MPI_TEST_SOURCE_FILE}" MPI_TEST_SOURCE_CONTENT COMPILE_DEFINITIONS ${MPI_TEST_COMPILE_DEFINITIONS} LINK_LIBRARIES MPI::MPI_${LANG} COPY_FILE "${BIN_FILE}" @@ -1290,7 +1292,7 @@ macro(_MPI_check_lang_works LANG SUPPRESS_ERRORS) # - *both*, the mpi module and 'mpif.h' # Since older MPI standards (MPI-1) did not define anything but 'mpif.h', we need to check all three individually. if( NOT MPI_${LANG}_WORKS ) - if("${LANG}" STREQUAL "Fortran") + if(LANG STREQUAL "Fortran") set(MPI_Fortran_INTEGER_LINE "(kind=MPI_INTEGER_KIND)") _MPI_try_staged_settings(${LANG} test_mpi F77_HEADER FALSE ${SUPPRESS_ERRORS}) _MPI_try_staged_settings(${LANG} test_mpi F90_MODULE FALSE ${SUPPRESS_ERRORS}) @@ -1339,11 +1341,11 @@ macro(MPI_search_mpi_prefix_folder PREFIX_FOLDER) endmacro() set(MPI_HINT_DIRS ${MPI_HOME} $ENV{MPI_HOME} $ENV{I_MPI_ROOT}) -if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux") +if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux") # SUSE Linux Enterprise Server stores its MPI implementations under /usr/lib64/mpi/gcc/<name> # We enumerate the subfolders and append each as a prefix MPI_search_mpi_prefix_folder("/usr/lib64/mpi/gcc") -elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "FreeBSD") +elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "FreeBSD") # FreeBSD ships mpich under the normal system paths - but available openmpi implementations # will be found in /usr/local/mpi/<name> MPI_search_mpi_prefix_folder("/usr/local/mpi") @@ -1410,7 +1412,7 @@ if(NOT MPI_IGNORE_LEGACY_VARIABLES) if(MPI_${LANG}_COMPILE_FLAGS) separate_arguments(MPI_SEPARATE_FLAGS NATIVE_COMMAND "${MPI_${LANG}_COMPILE_FLAGS}") foreach(_MPI_FLAG IN LISTS MPI_SEPARATE_FLAGS) - if("${_MPI_FLAG}" MATCHES "^ *-D([^ ]+)") + if(_MPI_FLAG MATCHES "^ *-D([^ ]+)") list(APPEND MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS "${CMAKE_MATCH_1}") else() list(APPEND MPI_${LANG}_EXTRA_COMPILE_OPTIONS "${_MPI_FLAG}") @@ -1459,7 +1461,7 @@ foreach(LANG IN ITEMS C CXX Fortran) set(_MPI_FIND_${LANG} TRUE) elseif( LANG IN_LIST MPI_FIND_COMPONENTS) set(_MPI_FIND_${LANG} TRUE) - elseif( "${LANG}" STREQUAL "CXX" AND NOT MPI_CXX_SKIP_MPICXX AND MPICXX IN_LIST MPI_FIND_COMPONENTS ) + elseif( LANG STREQUAL "CXX" AND NOT MPI_CXX_SKIP_MPICXX AND MPICXX IN_LIST MPI_FIND_COMPONENTS ) set(_MPI_FIND_${LANG} TRUE) else() set(_MPI_FIND_${LANG} FALSE) @@ -1471,7 +1473,7 @@ foreach(LANG IN ITEMS C CXX Fortran) endif() endif() if(_MPI_FIND_${LANG}) - if( "${LANG}" STREQUAL "CXX" AND NOT MPICXX IN_LIST MPI_FIND_COMPONENTS ) + if( LANG STREQUAL "CXX" AND NOT MPICXX IN_LIST MPI_FIND_COMPONENTS ) option(MPI_CXX_SKIP_MPICXX "If true, the MPI-2 C++ bindings are disabled using definitions." FALSE) mark_as_advanced(MPI_CXX_SKIP_MPICXX) endif() @@ -1493,7 +1495,7 @@ foreach(LANG IN ITEMS C CXX Fortran) set(MPI_${LANG}_TRIED_IMPLICIT TRUE) endif() - if(NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}" OR NOT MPI_${LANG}_WORKS) + if(NOT MPI_${LANG}_COMPILER STREQUAL CMAKE_${LANG}_COMPILER OR NOT MPI_${LANG}_WORKS) set(MPI_${LANG}_WRAPPER_FOUND FALSE) set(MPI_PINNED_COMPILER FALSE) @@ -1529,7 +1531,7 @@ foreach(LANG IN ITEMS C CXX Fortran) DOC "MPI compiler for ${LANG}" ) - if("${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}") + if(MPI_${LANG}_COMPILER STREQUAL CMAKE_${LANG}_COMPILER) set(MPI_PINNED_COMPILER TRUE) # If we haven't made the implicit compiler test yet, perform it now. @@ -1590,7 +1592,7 @@ foreach(LANG IN ITEMS C CXX Fortran) endif() if(_MPI_PKG AND PKG_CONFIG_FOUND) pkg_check_modules("MPI_${LANG}_PKG" "${_MPI_PKG}") - if("${MPI_${LANG}_PKG_FOUND}") + if(MPI_${LANG}_PKG_FOUND) set(MPI_${LANG}_COMPILE_OPTIONS ${MPI_${LANG}_PKG_CFLAGS} CACHE STRING "MPI ${LANG} compilation options" FORCE) set(MPI_${LANG}_INCLUDE_PATH ${MPI_${LANG}_PKG_INCLUDE_DIRS} CACHE STRING "MPI ${LANG} include directories" FORCE) set(MPI_${LANG}_LINK_FLAGS ${MPI_${LANG}_PKG_LDFLAGS} CACHE STRING "MPI ${LANG} linker flags" FORCE) @@ -1611,10 +1613,10 @@ foreach(LANG IN ITEMS C CXX Fortran) endif() endif() - if(NOT MPI_SKIP_GUESSING AND NOT "${MPI_${LANG}_PKG_FOUND}") + if(NOT MPI_SKIP_GUESSING AND NOT MPI_${LANG}_PKG_FOUND) # For C++, we may use the settings for C. Should a given compiler wrapper for C++ not exist, but one for C does, we copy over the # settings for C. An MPI distribution that is in this situation would be IBM Platform MPI. - if("${LANG}" STREQUAL "CXX" AND MPI_C_WRAPPER_FOUND) + if(LANG STREQUAL "CXX" AND MPI_C_WRAPPER_FOUND) set(MPI_${LANG}_COMPILE_OPTIONS ${MPI_C_COMPILE_OPTIONS} CACHE STRING "MPI ${LANG} compilation options" ) set(MPI_${LANG}_COMPILE_DEFINITIONS ${MPI_C_COMPILE_DEFINITIONS} CACHE STRING "MPI ${LANG} compilation definitions" ) set(MPI_${LANG}_COMPILER_INCLUDE_DIRS ${MPI_C_INCLUDE_DIRS} CACHE STRING "MPI ${LANG} compiler wrapper include directories") @@ -1628,7 +1630,7 @@ foreach(LANG IN ITEMS C CXX Fortran) endif() endif() - if(NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}") + if(NOT MPI_${LANG}_COMPILER STREQUAL CMAKE_${LANG}_COMPILER) _MPI_split_include_dirs(${LANG}) _MPI_assemble_include_dirs(${LANG}) else() @@ -1665,7 +1667,7 @@ foreach(LANG IN ITEMS C CXX Fortran) # If we've found MPI, then we'll perform additional analysis: Determine the MPI version, MPI library version, supported # MPI APIs (i.e. MPI-2 C++ bindings). For Fortran we also need to find specific parameters if we're under MPI-3. if(MPI_${LANG}_WORKS) - if("${LANG}" STREQUAL "CXX" AND NOT DEFINED MPI_MPICXX_FOUND) + if(LANG STREQUAL "CXX" AND NOT DEFINED MPI_MPICXX_FOUND) if(NOT MPI_CXX_SKIP_MPICXX AND NOT MPI_CXX_VALIDATE_SKIP_MPICXX) _MPI_try_staged_settings(${LANG} test_mpi MPICXX FALSE FALSE) if(MPI_RESULT_${LANG}_test_mpi_MPICXX) @@ -1689,7 +1691,7 @@ foreach(LANG IN ITEMS C CXX Fortran) # Fortran parameters, since those depend on the method of consumption. # For C++, we can always use the C bindings, and should do so, since the C++ bindings do not exist in MPI-3 # whereas the C bindings do, and the C++ bindings never offered any feature advantage over their C counterparts. - if("${LANG}" STREQUAL "Fortran") + if(LANG STREQUAL "Fortran") if(MPI_${LANG}_HAVE_F08_MODULE) set(MPI_${LANG}_HIGHEST_METHOD F08_MODULE) elseif(MPI_${LANG}_HAVE_F90_MODULE) @@ -1705,7 +1707,7 @@ foreach(LANG IN ITEMS C CXX Fortran) _MPI_try_staged_settings(${LANG} mpiver ${MPI_${LANG}_HIGHEST_METHOD} FALSE FALSE) if(MPI_RESULT_${LANG}_mpiver_${MPI_${LANG}_HIGHEST_METHOD}) file(STRINGS ${MPI_BIN_FOLDER}/mpiver_${LANG}.bin _MPI_VERSION_STRING LIMIT_COUNT 1 REGEX "INFO:MPI-VER") - if("${_MPI_VERSION_STRING}" MATCHES ".*INFO:MPI-VER\\[([0-9]+)\\.([0-9]+)\\].*") + if(_MPI_VERSION_STRING MATCHES ".*INFO:MPI-VER\\[([0-9]+)\\.([0-9]+)\\].*") set(MPI_${LANG}_VERSION_MAJOR "${CMAKE_MATCH_1}") set(MPI_${LANG}_VERSION_MINOR "${CMAKE_MATCH_2}") set(MPI_${LANG}_VERSION "${MPI_${LANG}_VERSION_MAJOR}.${MPI_${LANG}_VERSION_MINOR}") @@ -1724,12 +1726,12 @@ foreach(LANG IN ITEMS C CXX Fortran) _MPI_try_staged_settings(${LANG} fortranparam_mpi ${mpimethod} TRUE FALSE) if(MPI_RESULT_${LANG}_fortranparam_mpi_${mpimethod} AND NOT "${MPI_RUN_RESULT_${LANG}_fortranparam_mpi_${mpimethod}}" STREQUAL "FAILED_TO_RUN") - if("${MPI_RUN_OUTPUT_${LANG}_fortranparam_mpi_${mpimethod}}" MATCHES + if(MPI_RUN_OUTPUT_${LANG}_fortranparam_mpi_${mpimethod} MATCHES ".*INFO:SUBARRAYS\\[ *([TF]) *\\]-ASYNCPROT\\[ *([TF]) *\\].*") - if("${CMAKE_MATCH_1}" STREQUAL "T") + if(CMAKE_MATCH_1 STREQUAL "T") set(MPI_${LANG}_${mpimethod}_SUBARRAYS TRUE) endif() - if("${CMAKE_MATCH_2}" STREQUAL "T") + if(CMAKE_MATCH_2 STREQUAL "T") set(MPI_${LANG}_${mpimethod}_ASYNCPROT TRUE) endif() endif() @@ -1744,7 +1746,7 @@ foreach(LANG IN ITEMS C CXX Fortran) # By the MPI-2 standard, MPI_VERSION and MPI_SUBVERSION are valid for both C and C++ bindings. if(NOT DEFINED MPI_${LANG}_VERSION) file(STRINGS ${MPI_BIN_FOLDER}/test_mpi_${LANG}.bin _MPI_VERSION_STRING LIMIT_COUNT 1 REGEX "INFO:MPI-VER") - if("${_MPI_VERSION_STRING}" MATCHES ".*INFO:MPI-VER\\[([0-9]+)\\.([0-9]+)\\].*") + if(_MPI_VERSION_STRING MATCHES ".*INFO:MPI-VER\\[([0-9]+)\\.([0-9]+)\\].*") set(MPI_${LANG}_VERSION_MAJOR "${CMAKE_MATCH_1}") set(MPI_${LANG}_VERSION_MINOR "${CMAKE_MATCH_2}") set(MPI_${LANG}_VERSION "${MPI_${LANG}_VERSION_MAJOR}.${MPI_${LANG}_VERSION_MINOR}") @@ -1764,7 +1766,7 @@ foreach(LANG IN ITEMS C CXX Fortran) if(MPI_DETERMINE_LIBRARY_VERSION AND NOT MPI_${LANG}_LIBRARY_VERSION_STRING) _MPI_try_staged_settings(${LANG} libver_mpi ${MPI_${LANG}_HIGHEST_METHOD} TRUE FALSE) if(MPI_RESULT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD} AND - "${MPI_RUN_RESULT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD}}" EQUAL "0") + MPI_RUN_RESULT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD} EQUAL "0") string(STRIP "${MPI_RUN_OUTPUT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD}}" MPI_${LANG}_LIBRARY_VERSION_STRING) else() @@ -1778,12 +1780,12 @@ foreach(LANG IN ITEMS C CXX Fortran) set(MPI_${LANG}_FIND_VERSION_EXACT ${MPI_FIND_VERSION_EXACT}) unset(MPI_${LANG}_REQUIRED_VARS) - if (NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}") + if (NOT MPI_${LANG}_COMPILER STREQUAL CMAKE_${LANG}_COMPILER) foreach(mpilibname IN LISTS MPI_${LANG}_LIB_NAMES) list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${mpilibname}_LIBRARY") endforeach() list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_LIB_NAMES") - if("${LANG}" STREQUAL "Fortran") + if(LANG STREQUAL "Fortran") # For Fortran we only need one of the module or header directories to have *some* support for MPI. if(NOT MPI_${LANG}_MODULE_DIR) list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_F77_HEADER_DIR") @@ -1883,7 +1885,7 @@ else() endif() list(LENGTH MPI_LIBRARIES MPI_NUMLIBS) -if (MPI_NUMLIBS GREATER 1) +if (MPI_NUMLIBS GREATER "1") set(MPI_EXTRA_LIBRARY_WORK "${MPI_LIBRARIES}") list(REMOVE_AT MPI_EXTRA_LIBRARY_WORK 0) set(MPI_EXTRA_LIBRARY "${MPI_EXTRA_LIBRARY_WORK}") diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake index 470ebe0..07a9adf 100644 --- a/Modules/FindMatlab.cmake +++ b/Modules/FindMatlab.cmake @@ -85,10 +85,18 @@ Module Input Variables Users or projects may set the following variables to configure the module behavior: +:variable:`Matlab_ROOT <<PackageName>_ROOT>` + .. versionadded:: 3.25 + + Default value for :variable:`Matlab_ROOT_DIR`, the root of the Matlab + installation. + :variable:`Matlab_ROOT_DIR` - the root of the Matlab installation. + The root of the Matlab installation. + :variable:`MATLAB_FIND_DEBUG` outputs debug information + :variable:`MATLAB_ADDITIONAL_VERSIONS` additional versions of Matlab for the automatic retrieval of the installed versions. @@ -844,6 +852,15 @@ function(matlab_get_version_from_matlab_run matlab_binary_program matlab_list_ve endif() endif() + if(NOT EXISTS "${_matlab_temporary_folder}/matlabVersionLog.cmaketmp") + # last resort check as some HPC with "module load matlab" not enacted fail to catch in earlier checks + # and error CMake configure even if find_package(Matlab) is not REQUIRED + if(MATLAB_FIND_DEBUG) + message(WARNING "[MATLAB] Unable to determine the version of Matlab. The version log file does not exist.") + endif() + return() + endif() + # if successful, read back the log file(READ "${_matlab_temporary_folder}/matlabVersionLog.cmaketmp" _matlab_version_from_cmd) file(REMOVE "${_matlab_temporary_folder}/matlabVersionLog.cmaketmp") @@ -1573,6 +1590,13 @@ endfunction() # this variable will get all Matlab installations found in the current system. set(_matlab_possible_roots) +if(NOT DEFINED Matlab_ROOT AND DEFINED ENV{Matlab_ROOT}) + set(Matlab_ROOT $ENV{Matlab_ROOT}) +endif() +if(DEFINED Matlab_ROOT) + set(Matlab_ROOT_DIR ${Matlab_ROOT}) +endif() + if(Matlab_ROOT_DIR) # if the user specifies a possible root, we keep this one diff --git a/Modules/FindOpenACC.cmake b/Modules/FindOpenACC.cmake index cf58f3b..00e42b8 100644 --- a/Modules/FindOpenACC.cmake +++ b/Modules/FindOpenACC.cmake @@ -27,6 +27,13 @@ The module provides :prop_tgt:`IMPORTED` targets: Variables ^^^^^^^^^ +The module defines the following variables: + +``OpenACC_FOUND`` + .. versionadded:: 3.25 + + Variable indicating that OpenACC flags for at least one languages have been found. + This module will set the following variables per language in your project, where ``<lang>`` is one of C, CXX, or Fortran: @@ -121,21 +128,18 @@ set(OpenACC_Fortran_CHECK_VERSION_SOURCE ) -function(_OPENACC_WRITE_SOURCE_FILE LANG SRC_FILE_CONTENT_VAR SRC_FILE_NAME SRC_FILE_FULLPATH) - set(WORK_DIR ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindOpenACC) +macro(_OPENACC_PREPARE_SOURCE LANG CONTENT_ID NAME_PREFIX FULLNAME_VAR CONTENT_VAR) if("${LANG}" STREQUAL "C") - set(SRC_FILE "${WORK_DIR}/${SRC_FILE_NAME}.c") - file(WRITE "${SRC_FILE}" "${OpenACC_C_CXX_${SRC_FILE_CONTENT_VAR}}") + set(${FULLNAME_VAR} "${NAME_PREFIX}.c") + set(${CONTENT_VAR} "${OpenACC_C_CXX_${CONTENT_ID}}") elseif("${LANG}" STREQUAL "CXX") - set(SRC_FILE "${WORK_DIR}/${SRC_FILE_NAME}.cpp") - file(WRITE "${SRC_FILE}" "${OpenACC_C_CXX_${SRC_FILE_CONTENT_VAR}}") + set(${FULLNAME_VAR} "${NAME_PREFIX}.cpp") + set(${CONTENT_VAR} "${OpenACC_C_CXX_${CONTENT_ID}}") elseif("${LANG}" STREQUAL "Fortran") - set(SRC_FILE "${WORK_DIR}/${SRC_FILE_NAME}.F90") - file(WRITE "${SRC_FILE}_in" "${OpenACC_Fortran_${SRC_FILE_CONTENT_VAR}}") - configure_file("${SRC_FILE}_in" "${SRC_FILE}" @ONLY) + set(${FULLNAME_VAR} "${NAME_PREFIX}.F90") + set(${CONTENT_VAR} "${OpenACC_Fortran_${CONTENT_ID}}") endif() - set(${SRC_FILE_FULLPATH} "${SRC_FILE}" PARENT_SCOPE) -endfunction() +endmacro() function(_OPENACC_GET_FLAGS_CANDIDATE LANG FLAG_VAR) @@ -177,10 +181,12 @@ endfunction() function(_OPENACC_GET_FLAGS LANG FLAG_VAR) set(FLAG_CANDIDATES "") _OPENACC_GET_FLAGS_CANDIDATE("${LANG}" FLAG_CANDIDATES) - _OPENACC_WRITE_SOURCE_FILE("${LANG}" "TEST_SOURCE" OpenACCTryFlag _OPENACC_TEST_SRC) + _OPENACC_PREPARE_SOURCE("${LANG}" TEST_SOURCE OpenACCTryFlag + _OPENACC_TEST_SRC_NAME _OPENACC_TEST_SRC_CONTENT) foreach(FLAG IN LISTS FLAG_CANDIDATES) - try_compile(OpenACC_FLAG_TEST_RESULT ${CMAKE_BINARY_DIR} ${_OPENACC_TEST_SRC} + try_compile(OpenACC_FLAG_TEST_RESULT + SOURCE_FROM_VAR "${_OPENACC_TEST_SRC_NAME}" _OPENACC_TEST_SRC_CONTENT CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${FLAG}" OUTPUT_VARIABLE OpenACC_TRY_COMPILE_OUTPUT ) @@ -205,13 +211,15 @@ endfunction() function(_OPENACC_GET_SPEC_DATE LANG SPEC_DATE) - _OPENACC_WRITE_SOURCE_FILE("${LANG}" "CHECK_VERSION_SOURCE" OpenACCCheckVersion _OPENACC_TEST_SRC) + _OPENACC_PREPARE_SOURCE(${LANG} CHECK_VERSION_SOURCE OpenACCCheckVersion + _OPENACC_TEST_SRC_NAME _OPENACC_TEST_SRC_CONTENT) set(BIN_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindOpenACC/accver_${LANG}.bin") - try_compile(OpenACC_SPECTEST_${LANG} "${CMAKE_BINARY_DIR}" "${_OPENACC_TEST_SRC}" - CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OpenACC_${LANG}_FLAGS}" - COPY_FILE ${BIN_FILE} - OUTPUT_VARIABLE OUTPUT) + try_compile(OpenACC_SPECTEST_${LANG} + SOURCE_FROM_VAR "${_OPENACC_TEST_SRC_NAME}" _OPENACC_TEST_SRC_CONTENT + CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OpenACC_${LANG}_FLAGS}" + COPY_FILE "${BIN_FILE}" + OUTPUT_VARIABLE OUTPUT) if(${OpenACC_SPECTEST_${LANG}}) file(STRINGS ${BIN_FILE} specstr LIMIT_COUNT 1 REGEX "INFO:OpenACC-date") @@ -270,6 +278,9 @@ foreach (LANG IN ITEMS C CXX Fortran) REQUIRED_VARS OpenACC_${LANG}_FLAGS VERSION_VAR OpenACC_${LANG}_VERSION ) + if(OpenACC_${LANG}_FOUND) + set(OpenACC_FOUND TRUE) + endif() endif() endforeach() diff --git a/Modules/FindOpenAL.cmake b/Modules/FindOpenAL.cmake index b5b92c5..53aafdc 100644 --- a/Modules/FindOpenAL.cmake +++ b/Modules/FindOpenAL.cmake @@ -29,6 +29,16 @@ OpenAL is searched in the following order: 5. Manually compiled framework: ``/Library/Frameworks``. 6. Add-on package: ``/opt``. +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 3.25 + +This module defines the :prop_tgt:`IMPORTED` target: + +``OpenAL::OpenAL`` + The OpenAL library, if found. + Result Variables ^^^^^^^^^^^^^^^^ @@ -94,3 +104,19 @@ find_package_handle_standard_args( ) mark_as_advanced(OPENAL_LIBRARY OPENAL_INCLUDE_DIR) + +if(OPENAL_INCLUDE_DIR AND OPENAL_LIBRARY) + if(NOT TARGET OpenAL::OpenAL) + if(EXISTS "${OPENAL_LIBRARY}") + add_library(OpenAL::OpenAL UNKNOWN IMPORTED) + set_target_properties(OpenAL::OpenAL PROPERTIES + IMPORTED_LOCATION "${OPENAL_LIBRARY}") + else() + add_library(OpenAL::OpenAL INTERFACE IMPORTED) + set_target_properties(OpenAL::OpenAL PROPERTIES + IMPORTED_LIBNAME "${OPENAL_LIBRARY}") + endif() + set_target_properties(OpenAL::OpenAL PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${OPENAL_INCLUDE_DIR}") + endif() +endif() diff --git a/Modules/FindOpenGL.cmake b/Modules/FindOpenGL.cmake index d6d1c00..a9a1b2a 100644 --- a/Modules/FindOpenGL.cmake +++ b/Modules/FindOpenGL.cmake @@ -377,7 +377,7 @@ else() (NOT OPENGL_USE_EGL AND NOT OPENGL_glx_LIBRARY AND OPENGL_gl_LIBRARY)) - list(APPEND _OpenGL_REQUIRED_VARS OPENGL_gl_LIBRARY) + list(PREPEND _OpenGL_REQUIRED_VARS OPENGL_gl_LIBRARY) endif() # We always need the 'gl.h' include dir. diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake index ecfb7f9..9e24925 100644 --- a/Modules/FindOpenMP.cmake +++ b/Modules/FindOpenMP.cmake @@ -178,27 +178,25 @@ set(OpenMP_Fortran_TEST_SOURCE " ) -function(_OPENMP_WRITE_SOURCE_FILE LANG SRC_FILE_CONTENT_VAR SRC_FILE_NAME SRC_FILE_FULLPATH) - set(WORK_DIR ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindOpenMP) +macro(_OPENMP_PREPARE_SOURCE LANG CONTENT_ID NAME_PREFIX FULLNAME_VAR CONTENT_VAR) if("${LANG}" STREQUAL "C") - set(SRC_FILE "${WORK_DIR}/${SRC_FILE_NAME}.c") - file(WRITE "${SRC_FILE}" "${OpenMP_C_CXX_${SRC_FILE_CONTENT_VAR}}") + set(${FULLNAME_VAR} "${NAME_PREFIX}.c") + set(${CONTENT_VAR} "${OpenMP_C_CXX_${CONTENT_ID}}") elseif("${LANG}" STREQUAL "CXX") - set(SRC_FILE "${WORK_DIR}/${SRC_FILE_NAME}.cpp") - file(WRITE "${SRC_FILE}" "${OpenMP_C_CXX_${SRC_FILE_CONTENT_VAR}}") + set(${FULLNAME_VAR} "${NAME_PREFIX}.cpp") + set(${CONTENT_VAR} "${OpenMP_C_CXX_${CONTENT_ID}}") elseif("${LANG}" STREQUAL "Fortran") - set(SRC_FILE "${WORK_DIR}/${SRC_FILE_NAME}.f90") - file(WRITE "${SRC_FILE}_in" "${OpenMP_Fortran_${SRC_FILE_CONTENT_VAR}}") - configure_file("${SRC_FILE}_in" "${SRC_FILE}" @ONLY) + set(${FULLNAME_VAR} "${NAME_PREFIX}.F90") + string(CONFIGURE "${OpenMP_Fortran_${CONTENT_ID}}" ${CONTENT_VAR} @ONLY) endif() - set(${SRC_FILE_FULLPATH} "${SRC_FILE}" PARENT_SCOPE) -endfunction() +endmacro() include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseImplicitLinkInfo.cmake) function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR) _OPENMP_FLAG_CANDIDATES("${LANG}") - _OPENMP_WRITE_SOURCE_FILE("${LANG}" "TEST_SOURCE" OpenMPTryFlag _OPENMP_TEST_SRC) + _OPENMP_PREPARE_SOURCE("${LANG}" TEST_SOURCE OpenMPTryFlag + _OPENMP_TEST_SRC_NAME _OPENMP_TEST_SRC_CONTENT) unset(OpenMP_VERBOSE_COMPILE_OPTIONS) separate_arguments(OpenMP_VERBOSE_OPTIONS NATIVE_COMMAND "${CMAKE_${LANG}_VERBOSE_FLAG}") @@ -214,7 +212,8 @@ function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR) string(APPEND OPENMP_FLAGS_TEST " ${OpenMP_VERBOSE_COMPILE_OPTIONS}") endif() string(REGEX REPLACE "[-/=+]" "" OPENMP_PLAIN_FLAG "${OPENMP_FLAG}") - try_compile( OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG} ${CMAKE_BINARY_DIR} ${_OPENMP_TEST_SRC} + try_compile( OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG} + SOURCE_FROM_VAR "${_OPENMP_TEST_SRC_NAME}" _OPENMP_TEST_SRC_CONTENT CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OPENMP_FLAGS_TEST}" LINK_LIBRARIES ${CMAKE_${LANG}_VERBOSE_FLAG} OUTPUT_VARIABLE OpenMP_TRY_COMPILE_OUTPUT @@ -238,11 +237,29 @@ function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR) OpenMP_${LANG}_IMPLICIT_FWK_DIRS OpenMP_${LANG}_LOG_VAR "${CMAKE_${LANG}_IMPLICIT_OBJECT_REGEX}" + LANGUAGE ${LANG} ) file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Parsed ${LANG} OpenMP implicit link information from above output:\n${OpenMP_${LANG}_LOG_VAR}\n\n") + # For LCC we should additionally alanyze -print-search-dirs output + # to check for additional implicit_dirs. + # Note: This won't work if CMP0129 policy is set to OLD! + if("${CMAKE_${LANG}_COMPILER_ID}" STREQUAL "LCC") + execute_process( + COMMAND ${CMAKE_${LANG}_COMPILER} -print-search-dirs + OUTPUT_VARIABLE output_lines + COMMAND_ERROR_IS_FATAL ANY + ERROR_QUIET) + if("${output_lines}" MATCHES ".*\nlibraries:[ \t]+(.*:)\n.*") + string(REPLACE ":" ";" implicit_dirs_addon "${CMAKE_MATCH_1}") + list(PREPEND OpenMP_${LANG}_IMPLICIT_LINK_DIRS ${implicit_dirs_addon}) + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + " Extended OpenMP library search paths: [${implicit_dirs}]\n") + endif() + endif() + unset(_OPENMP_LIB_NAMES) foreach(_OPENMP_IMPLICIT_LIB IN LISTS OpenMP_${LANG}_IMPLICIT_LIBRARIES) get_filename_component(_OPENMP_IMPLICIT_LIB_DIR "${_OPENMP_IMPLICIT_LIB}" DIRECTORY) @@ -262,7 +279,9 @@ function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR) DOC "Path to the ${_OPENMP_IMPLICIT_LIB_PLAIN} library for OpenMP" HINTS ${OpenMP_${LANG}_IMPLICIT_LINK_DIRS} CMAKE_FIND_ROOT_PATH_BOTH - NO_DEFAULT_PATH + NO_PACKAGE_ROOT_PATH + NO_CMAKE_PATH + NO_CMAKE_ENVIRONMENT_PATH ) endif() mark_as_advanced(OpenMP_${_OPENMP_IMPLICIT_LIB_PLAIN}_LIBRARY) @@ -291,7 +310,8 @@ function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR) # Try without specifying include directory first. We only want to # explicitly add a search path if the header can't be found on the # default header search path already. - try_compile( OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG} ${CMAKE_BINARY_DIR} ${_OPENMP_TEST_SRC} + try_compile( OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG} + SOURCE_FROM_VAR "${_OPENMP_TEST_SRC_NAME}" _OPENMP_TEST_SRC_CONTENT CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OPENMP_FLAGS_TEST}" LINK_LIBRARIES ${CMAKE_${LANG}_VERBOSE_FLAG} ${OpenMP_libomp_LIBRARY} OUTPUT_VARIABLE OpenMP_TRY_COMPILE_OUTPUT @@ -301,7 +321,8 @@ function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR) mark_as_advanced(OpenMP_${LANG}_INCLUDE_DIR) set(OpenMP_${LANG}_INCLUDE_DIR "${OpenMP_${LANG}_INCLUDE_DIR}" PARENT_SCOPE) if(OpenMP_${LANG}_INCLUDE_DIR) - try_compile( OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG} ${CMAKE_BINARY_DIR} ${_OPENMP_TEST_SRC} + try_compile( OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG} + SOURCE_FROM_VAR "${_OPENMP_TEST_SRC_NAME}" _OPENMP_TEST_SRC_CONTENT CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OPENMP_FLAGS_TEST}" "-DINCLUDE_DIRECTORIES:STRING=${OpenMP_${LANG}_INCLUDE_DIR}" LINK_LIBRARIES ${CMAKE_${LANG}_VERBOSE_FLAG} ${OpenMP_libomp_LIBRARY} @@ -323,7 +344,8 @@ function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR) ) mark_as_advanced(OpenMP_libomp_LIBRARY) if(OpenMP_libomp_LIBRARY) - try_compile( OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG} ${CMAKE_BINARY_DIR} ${_OPENMP_TEST_SRC} + try_compile( OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG} + SOURCE_FROM_VAR "${_OPENMP_TEST_SRC_NAME}" _OPENMP_TEST_SRC_CONTENT CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OPENMP_FLAGS_TEST}" LINK_LIBRARIES ${CMAKE_${LANG}_VERBOSE_FLAG} ${OpenMP_libomp_LIBRARY} OUTPUT_VARIABLE OpenMP_TRY_COMPILE_OUTPUT @@ -385,7 +407,8 @@ set(OpenMP_Fortran_CHECK_VERSION_SOURCE ") function(_OPENMP_GET_SPEC_DATE LANG SPEC_DATE) - _OPENMP_WRITE_SOURCE_FILE("${LANG}" "CHECK_VERSION_SOURCE" OpenMPCheckVersion _OPENMP_TEST_SRC) + _OPENMP_PREPARE_SOURCE("${LANG}" CHECK_VERSION_SOURCE OpenMPCheckVersion + _OPENMP_TEST_SRC_NAME _OPENMP_TEST_SRC_CONTENT) unset(_includeDirFlags) if(OpenMP_${LANG}_INCLUDE_DIR) @@ -394,10 +417,11 @@ function(_OPENMP_GET_SPEC_DATE LANG SPEC_DATE) set(BIN_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindOpenMP/ompver_${LANG}.bin") string(REGEX REPLACE "[-/=+]" "" OPENMP_PLAIN_FLAG "${OPENMP_FLAG}") - try_compile(OpenMP_SPECTEST_${LANG}_${OPENMP_PLAIN_FLAG} "${CMAKE_BINARY_DIR}" "${_OPENMP_TEST_SRC}" - CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OpenMP_${LANG}_FLAGS}" ${_includeDirFlags} - COPY_FILE ${BIN_FILE} - OUTPUT_VARIABLE OpenMP_TRY_COMPILE_OUTPUT) + try_compile(OpenMP_SPECTEST_${LANG}_${OPENMP_PLAIN_FLAG} + SOURCE_FROM_VAR "${_OPENMP_TEST_SRC_NAME}" _OPENMP_TEST_SRC_CONTENT + CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OpenMP_${LANG}_FLAGS}" ${_includeDirFlags} + COPY_FILE "${BIN_FILE}" + OUTPUT_VARIABLE OpenMP_TRY_COMPILE_OUTPUT) if(${OpenMP_SPECTEST_${LANG}_${OPENMP_PLAIN_FLAG}}) file(STRINGS ${BIN_FILE} specstr LIMIT_COUNT 1 REGEX "INFO:OpenMP-date") @@ -460,10 +484,14 @@ foreach(LANG IN ITEMS C CXX) if(NOT DEFINED OpenMP_${LANG}_FLAGS OR "${OpenMP_${LANG}_FLAGS}" STREQUAL "NOTFOUND" OR NOT DEFINED OpenMP_${LANG}_LIB_NAMES OR "${OpenMP_${LANG}_LIB_NAMES}" STREQUAL "NOTFOUND") _OPENMP_GET_FLAGS("${LANG}" "${LANG}" OpenMP_${LANG}_FLAGS_WORK OpenMP_${LANG}_LIB_NAMES_WORK) - set(OpenMP_${LANG}_FLAGS "${OpenMP_${LANG}_FLAGS_WORK}" - CACHE STRING "${LANG} compiler flags for OpenMP parallelization" FORCE) - set(OpenMP_${LANG}_LIB_NAMES "${OpenMP_${LANG}_LIB_NAMES_WORK}" - CACHE STRING "${LANG} compiler libraries for OpenMP parallelization" FORCE) + if(NOT DEFINED OpenMP_${LANG}_FLAGS OR "${OpenMP_${LANG}_FLAGS}" STREQUAL "NOTFOUND") + set(OpenMP_${LANG}_FLAGS "${OpenMP_${LANG}_FLAGS_WORK}" + CACHE STRING "${LANG} compiler flags for OpenMP parallelization" FORCE) + endif() + if(NOT DEFINED OpenMP_${LANG}_LIB_NAMES OR "${OpenMP_${LANG}_LIB_NAMES}" STREQUAL "NOTFOUND") + set(OpenMP_${LANG}_LIB_NAMES "${OpenMP_${LANG}_LIB_NAMES_WORK}" + CACHE STRING "${LANG} compiler libraries for OpenMP parallelization" FORCE) + endif() mark_as_advanced(OpenMP_${LANG}_FLAGS OpenMP_${LANG}_LIB_NAMES) endif() endif() @@ -479,10 +507,14 @@ if(CMAKE_Fortran_COMPILER_LOADED) set(OpenMP_Fortran_HAVE_OMPLIB_MODULE TRUE CACHE BOOL INTERNAL "") endif() - set(OpenMP_Fortran_FLAGS "${OpenMP_Fortran_FLAGS_WORK}" - CACHE STRING "Fortran compiler flags for OpenMP parallelization") - set(OpenMP_Fortran_LIB_NAMES "${OpenMP_Fortran_LIB_NAMES_WORK}" - CACHE STRING "Fortran compiler libraries for OpenMP parallelization") + if(NOT DEFINED OpenMP_Fortran_FLAGS OR "${OpenMP_Fortran_FLAGS}" STREQUAL "NOTFOUND") + set(OpenMP_Fortran_FLAGS "${OpenMP_Fortran_FLAGS_WORK}" + CACHE STRING "Fortran compiler flags for OpenMP parallelization" FORCE) + endif() + if(NOT DEFINED OpenMP_Fortran_LIB_NAMES OR "${OpenMP_Fortran_LIB_NAMES}" STREQUAL "NOTFOUND") + set(OpenMP_Fortran_LIB_NAMES "${OpenMP_Fortran_LIB_NAMES_WORK}" + CACHE STRING "Fortran compiler libraries for OpenMP parallelization" FORCE) + endif() mark_as_advanced(OpenMP_Fortran_FLAGS OpenMP_Fortran_LIB_NAMES) endif() @@ -495,11 +527,14 @@ if(CMAKE_Fortran_COMPILER_LOADED) set(OpenMP_Fortran_HAVE_OMPLIB_HEADER TRUE CACHE BOOL INTERNAL "") endif() - set(OpenMP_Fortran_FLAGS "${OpenMP_Fortran_FLAGS_WORK}" - CACHE STRING "Fortran compiler flags for OpenMP parallelization") - - set(OpenMP_Fortran_LIB_NAMES "${OpenMP_Fortran_LIB_NAMES}" - CACHE STRING "Fortran compiler libraries for OpenMP parallelization") + if(NOT DEFINED OpenMP_Fortran_FLAGS OR "${OpenMP_Fortran_FLAGS}" STREQUAL "NOTFOUND") + set(OpenMP_Fortran_FLAGS "${OpenMP_Fortran_FLAGS_WORK}" + CACHE STRING "Fortran compiler flags for OpenMP parallelization" FORCE) + endif() + if(NOT DEFINED OpenMP_Fortran_LIB_NAMES OR "${OpenMP_Fortran_LIB_NAMES}" STREQUAL "NOTFOUND") + set(OpenMP_Fortran_LIB_NAMES "${OpenMP_Fortran_LIB_NAMES_WORK}" + CACHE STRING "Fortran compiler libraries for OpenMP parallelization" FORCE) + endif() endif() if(OpenMP_Fortran_HAVE_OMPLIB_MODULE) @@ -571,7 +606,8 @@ foreach(LANG IN LISTS OpenMP_FINDLIST) separate_arguments(_OpenMP_${LANG}_OPTIONS NATIVE_COMMAND "${OpenMP_${LANG}_FLAGS}") set_property(TARGET OpenMP::OpenMP_${LANG} PROPERTY INTERFACE_COMPILE_OPTIONS "$<$<COMPILE_LANGUAGE:${LANG}>:${_OpenMP_${LANG}_OPTIONS}>") - if(CMAKE_${LANG}_COMPILER_ID STREQUAL "Fujitsu") + if(CMAKE_${LANG}_COMPILER_ID STREQUAL "Fujitsu" + OR ${CMAKE_${LANG}_COMPILER_ID} STREQUAL "IntelLLVM") set_property(TARGET OpenMP::OpenMP_${LANG} PROPERTY INTERFACE_LINK_OPTIONS "${OpenMP_${LANG}_FLAGS}") endif() diff --git a/Modules/FindOpenSP.cmake b/Modules/FindOpenSP.cmake new file mode 100644 index 0000000..655dd65 --- /dev/null +++ b/Modules/FindOpenSP.cmake @@ -0,0 +1,155 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindOpenSP +---------- + +.. versionadded:: 3.25 + +Try to find the OpenSP library. + +Result Variables +^^^^^^^^^^^^^^^^ + +This will define the following variables: + +``OpenSP_FOUND`` + True if (the requested version of) ``OpenSP`` is available + +``OpenSP_VERSION`` + The version of ``OpenSP`` + +``OpenSP_VERSION_MAJOR`` + The major version of ``OpenSP`` + +``OpenSP_VERSION_MINOR`` + The minor version of ``OpenSP`` + +``OpenSP_VERSION_PATCH`` + The patch version of ``OpenSP`` + +``OpenSP_INCLUDE_DIRS`` + The include dirs of ``OpenSP`` with its headers + +``OpenSP_LIBRARIES`` + The OpenSP library for use with target_link_libraries(). + This can be passed to target_link_libraries() instead of + the :prop_tgt:`IMPORTED` ``OpenSP::OpenSP`` target + +``OpenSP_MULTI_BYTE`` + True if ``SP_MULTI_BYTE`` was found to be defined in OpenSP's ``config.h`` + header file, which indicates that the ``OpenSP`` library was compiled with + support for multi-byte characters. The consuming target needs to define the + ``SP_MULTI_BYTE`` to match this value in order to avoid issues with character + decoding. + +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +This module defines the :prop_tgt:`IMPORTED` target ``OpenSP::OpenSP``, if +OpenSP has been found. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``OpenSP_INCLUDE_DIR`` + the OpenSP include directory + +``OpenSP_LIBRARY`` + the absolute path of the osp library + +#]=======================================================================] + +if (NOT OpenSP_INCLUDE_DIR AND NOT OpenSP_LIBRARY) + find_package(PkgConfig) + if (PkgConfig_FOUND) + pkg_check_modules(OpenSP IMPORTED_TARGET GLOBAL opensp) + + if (OpenSP_FOUND) + add_library(OpenSP::OpenSP INTERFACE IMPORTED) + target_link_libraries(OpenSP::OpenSP INTERFACE PkgConfig::OpenSP) + + set(OpenSP_INCLUDE_DIR ${OpenSP_INCLUDE_DIRS}) + set(OpenSP_LIBRARY ${OpenSP_LIBRARIES}) + endif () + endif () +endif () + +if (NOT OpenSP_INCLUDE_DIR) + find_path(OpenSP_INCLUDE_DIR + NAMES ParserEventGeneratorKit.h + PATH_SUFFIXES OpenSP opensp + DOC "The OpenSP include directory" + ) +endif () + +if (NOT OpenSP_LIBRARY) + find_library(OpenSP_LIBRARY_RELEASE + NAMES osp libosp opensp libopensp sp133 libsp + ) + + find_library(OpenSP_LIBRARY_DEBUG + NAMES ospd libospd openspd libopenspd sp133d libspd + ) + + include(SelectLibraryConfigurations) + select_library_configurations(OpenSP) +endif () + +if (OpenSP_INCLUDE_DIR AND OpenSP_LIBRARY) + if (EXISTS "${OpenSP_INCLUDE_DIR}/config.h") + if (NOT OpenSP_VERSION) + file(STRINGS "${OpenSP_INCLUDE_DIR}/config.h" opensp_version_str REGEX "^#define[\t ]+SP_VERSION[\t ]+\".*\"") + string(REGEX REPLACE "^.*SP_VERSION[\t ]+\"([^\"]*)\".*$" "\\1" OpenSP_VERSION "${opensp_version_str}") + unset(opensp_version_str) + endif () + + if (OpenSP_VERSION MATCHES [=[([0-9]+)\.([0-9]+)\.([0-9]+)]=]) + set(OpenSP_VERSION_MAJOR "${CMAKE_MATCH_1}") + set(OpenSP_VERSION_MINOR "${CMAKE_MATCH_2}") + set(OpenSP_VERSION_PATCH "${CMAKE_MATCH_3}") + endif () + + include(CheckCXXSymbolExists) + check_cxx_symbol_exists(SP_MULTI_BYTE "${OpenSP_INCLUDE_DIR}/config.h" OpenSP_MULTI_BYTE) + endif () + + if (NOT TARGET OpenSP::OpenSP) + set(OpenSP_INCLUDE_DIRS ${OpenSP_INCLUDE_DIR}) + + add_library(OpenSP::OpenSP UNKNOWN IMPORTED) + set_target_properties(OpenSP::OpenSP PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${OpenSP_INCLUDE_DIRS}") + + if (OpenSP_LIBRARY_RELEASE) + set_target_properties(OpenSP::OpenSP PROPERTIES IMPORTED_LOCATION_RELEASE "${OpenSP_LIBRARY_RELEASE}") + set_property(TARGET OpenSP::OpenSP APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) + endif () + + if (OpenSP_LIBRARY_DEBUG) + set_target_properties(OpenSP::OpenSP PROPERTIES IMPORTED_LOCATION_DEBUG "${OpenSP_LIBRARY_DEBUG}") + set_property(TARGET OpenSP::OpenSP APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) + endif () + + if (NOT OpenSP_LIBRARY_RELEASE AND NOT OpenSP_LIBRARY_DEBUG) + set_property(TARGET OpenSP::OpenSP APPEND PROPERTY IMPORTED_LOCATION "${OpenSP_LIBRARY}") + endif () + endif () +endif () + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(OpenSP + FOUND_VAR OpenSP_FOUND + REQUIRED_VARS OpenSP_LIBRARY OpenSP_INCLUDE_DIR + VERSION_VAR OpenSP_VERSION + ) + +mark_as_advanced(OpenSP_INCLUDE_DIR OpenSP_LIBRARY OpenSP_MULTI_BYTE) + +include(FeatureSummary) +set_package_properties(OpenSP PROPERTIES + URL "http://openjade.sourceforge.net/doc/index.htm" + DESCRIPTION "An SGML System Conforming to International Standard ISO 8879" + ) diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index 9278566..352c4cc 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -90,13 +90,25 @@ This module will set the following variables in your project: Hints ^^^^^ -Set ``OPENSSL_ROOT_DIR`` to the root directory of an OpenSSL installation. +The following variables may be set to control search behavior: -.. versionadded:: 3.4 - Set ``OPENSSL_USE_STATIC_LIBS`` to ``TRUE`` to look for static libraries. +``OPENSSL_ROOT_DIR`` + Set to the root directory of an OpenSSL installation. + +``OPENSSL_USE_STATIC_LIBS`` + .. versionadded:: 3.4 + + Set to ``TRUE`` to look for static libraries. + +``OPENSSL_MSVC_STATIC_RT`` + .. versionadded:: 3.5 + + Set to ``TRUE`` to choose the MT version of the lib. -.. versionadded:: 3.5 - Set ``OPENSSL_MSVC_STATIC_RT`` set ``TRUE`` to choose the MT version of the lib. +``ENV{PKG_CONFIG_PATH}`` + On UNIX-like systems, ``pkg-config`` is used to locate the system OpenSSL. + Set the ``PKG_CONFIG_PATH`` environment varialbe to look in alternate + locations. Useful on multi-lib systems. #]=======================================================================] macro(_OpenSSL_test_and_find_dependencies ssl_library crypto_library) diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake index fbcf7cd..56ba1e6 100644 --- a/Modules/FindPackageHandleStandardArgs.cmake +++ b/Modules/FindPackageHandleStandardArgs.cmake @@ -535,18 +535,24 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) set(VERSION_MSG "") set(VERSION_OK TRUE) - # check with DEFINED here as the requested or found version may be "0" + # check that the version variable is not empty to avoid emitting a misleading + # message (i.e. `Found unsuitable version ""`) if (DEFINED ${_NAME}_FIND_VERSION) if(DEFINED ${FPHSA_VERSION_VAR}) - set(_FOUND_VERSION ${${FPHSA_VERSION_VAR}}) - if (FPHSA_HANDLE_VERSION_RANGE) - set (FPCV_HANDLE_VERSION_RANGE HANDLE_VERSION_RANGE) + if(NOT "${${FPHSA_VERSION_VAR}}" STREQUAL "") + set(_FOUND_VERSION ${${FPHSA_VERSION_VAR}}) + if (FPHSA_HANDLE_VERSION_RANGE) + set (FPCV_HANDLE_VERSION_RANGE HANDLE_VERSION_RANGE) + else() + set(FPCV_HANDLE_VERSION_RANGE NO_AUTHOR_WARNING_VERSION_RANGE) + endif() + find_package_check_version ("${_FOUND_VERSION}" VERSION_OK RESULT_MESSAGE_VARIABLE VERSION_MSG + ${FPCV_HANDLE_VERSION_RANGE}) else() - set(FPCV_HANDLE_VERSION_RANGE NO_AUTHOR_WARNING_VERSION_RANGE) + set(VERSION_OK FALSE) endif() - find_package_check_version ("${_FOUND_VERSION}" VERSION_OK RESULT_MESSAGE_VARIABLE VERSION_MSG - ${FPCV_HANDLE_VERSION_RANGE}) - else() + endif() + if("${${FPHSA_VERSION_VAR}}" STREQUAL "") # if the package was not found, but a version was given, add that to the output: if(${_NAME}_FIND_VERSION_EXACT) set(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")") diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index c4fae6b..7a127e4 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -14,6 +14,8 @@ cmake_policy(PUSH) cmake_policy (SET CMP0012 NEW) # IN_LIST operator cmake_policy (SET CMP0057 NEW) +# registry view behavior +cmake_policy (SET CMP0134 NEW) if (NOT DEFINED _PYTHON_PREFIX) message (FATAL_ERROR "FindPython: INTERNAL ERROR") @@ -175,30 +177,31 @@ function (_PYTHON_GET_REGISTRIES _PYTHON_PGR_REGISTRY_PATHS) foreach (version IN LISTS _PGR_VERSION) string (REPLACE "." "" version_no_dots ${version}) list (APPEND registries - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${version}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath] - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${version}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath]) + [HKEY_CURRENT_USER/SOFTWARE/Python/PythonCore/${version}-${_${_PYTHON_PREFIX}_ARCH}/InstallPath] + [HKEY_CURRENT_USER/SOFTWARE/Python/PythonCore/${version}-${_${_PYTHON_PREFIX}_ARCH2}/InstallPath]) if (version VERSION_GREATER_EQUAL "3.5") + # cmake_host_system_information is not usable in bootstrap get_filename_component (arch "[HKEY_CURRENT_USER\\Software\\Python\\PythonCore\\${version};SysArchitecture]" NAME) if (arch MATCHES "(${_${_PYTHON_PREFIX}_ARCH}|${_${_PYTHON_PREFIX}_ARCH2})bit") list (APPEND registries - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${version}\\InstallPath]) + [HKEY_CURRENT_USER/SOFTWARE/Python/PythonCore/${version}/InstallPath]) endif() else() list (APPEND registries - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${version}\\InstallPath]) + [HKEY_CURRENT_USER/SOFTWARE/Python/PythonCore/${version}/InstallPath]) endif() list (APPEND registries - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${version_no_dots}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath] - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${version_no_dots}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${version}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${version}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${version}\\InstallPath] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${version_no_dots}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${version_no_dots}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath]) + [HKEY_CURRENT_USER/SOFTWARE/Python/ContinuumAnalytics/Anaconda${version_no_dots}-${_${_PYTHON_PREFIX}_ARCH}/InstallPath] + [HKEY_CURRENT_USER/SOFTWARE/Python/ContinuumAnalytics/Anaconda${version_no_dots}-${_${_PYTHON_PREFIX}_ARCH2}/InstallPath] + [HKEY_LOCAL_MACHINE/SOFTWARE/Python/PythonCore/${version}-${_${_PYTHON_PREFIX}_ARCH}/InstallPath] + [HKEY_LOCAL_MACHINE/SOFTWARE/Python/PythonCore/${version}-${_${_PYTHON_PREFIX}_ARCH2}/InstallPath] + [HKEY_LOCAL_MACHINE/SOFTWARE/Python/PythonCore/${version}/InstallPath] + [HKEY_LOCAL_MACHINE/SOFTWARE/Python/ContinuumAnalytics/Anaconda${version_no_dots}-${_${_PYTHON_PREFIX}_ARCH}/InstallPath] + [HKEY_LOCAL_MACHINE/SOFTWARE/Python/ContinuumAnalytics/Anaconda${version_no_dots}-${_${_PYTHON_PREFIX}_ARCH2}/InstallPath]) endforeach() elseif (implementation STREQUAL "IronPython") foreach (version IN LISTS _PGR_VERSION) - list (APPEND registries [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${version}\\InstallPath]) + list (APPEND registries [HKEY_LOCAL_MACHINE/SOFTWARE/IronPython/${version}/InstallPath]) endforeach() endif() endforeach() @@ -711,7 +714,7 @@ function (_PYTHON_VALIDATE_INTERPRETER) if (_PVI_CHECK_EXISTS AND NOT EXISTS "${_${_PYTHON_PREFIX}_EXECUTABLE}") # interpreter does not exist anymore - set (_${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE "Cannot find the interpreter \"${_${_PYTHON_PREFIX}_EXECUTABLE}\"" PARENT_SCOPE) + set_property (CACHE _${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE PROPERTY VALUE "Cannot find the interpreter \"${_${_PYTHON_PREFIX}_EXECUTABLE}\"") set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND") return() endif() @@ -732,7 +735,7 @@ function (_PYTHON_VALIDATE_INTERPRETER) endif() if (NOT abi IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS) # incompatible ABI - set (_${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE "Wrong ABI for the interpreter \"${_${_PYTHON_PREFIX}_EXECUTABLE}\"" PARENT_SCOPE) + set_property (CACHE _${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE PROPERTY VALUE "Wrong ABI for the interpreter \"${_${_PYTHON_PREFIX}_EXECUTABLE}\"") set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND") return() endif() @@ -748,7 +751,7 @@ function (_PYTHON_VALIDATE_INTERPRETER) OUTPUT_STRIP_TRAILING_WHITESPACE) if (result) # interpreter is not usable - set (_${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE "Cannot use the interpreter \"${_${_PYTHON_PREFIX}_EXECUTABLE}\"" PARENT_SCOPE) + set_property (CACHE _${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE PROPERTY VALUE "Cannot use the interpreter \"${_${_PYTHON_PREFIX}_EXECUTABLE}\"") set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND") return() endif() @@ -773,7 +776,7 @@ function (_PYTHON_VALIDATE_INTERPRETER) if (_PVI_EXACT AND NOT version VERSION_EQUAL _PVI_VERSION) # interpreter has wrong version - set (_${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE "Wrong version for the interpreter \"${_${_PYTHON_PREFIX}_EXECUTABLE}\"" PARENT_SCOPE) + set_property (CACHE _${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE PROPERTY VALUE "Wrong version for the interpreter \"${_${_PYTHON_PREFIX}_EXECUTABLE}\"") set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND") return() else() @@ -782,7 +785,7 @@ function (_PYTHON_VALIDATE_INTERPRETER) string(REGEX REPLACE "^([0-9]+)\\.?.*$" "\\1" expected_major_version "${_PVI_VERSION}") if (NOT major_version VERSION_EQUAL expected_major_version OR NOT version VERSION_GREATER_EQUAL _PVI_VERSION) - set (_${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE "Wrong version for the interpreter \"${_${_PYTHON_PREFIX}_EXECUTABLE}\"" PARENT_SCOPE) + set_property (CACHE _${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE PROPERTY VALUE "Wrong version for the interpreter \"${_${_PYTHON_PREFIX}_EXECUTABLE}\"") set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND") return() endif() @@ -794,7 +797,7 @@ function (_PYTHON_VALIDATE_INTERPRETER) find_package_check_version ("${version}" in_range HANDLE_VERSION_RANGE) if (NOT in_range) # interpreter has invalid version - set (_${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE "Wrong version for the interpreter \"${_${_PYTHON_PREFIX}_EXECUTABLE}\"" PARENT_SCOPE) + set_property (CACHE _${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE PROPERTY VALUE "Wrong version for the interpreter \"${_${_PYTHON_PREFIX}_EXECUTABLE}\"") set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND") return() endif() @@ -813,9 +816,9 @@ function (_PYTHON_VALIDATE_INTERPRETER) if (result OR NOT version EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR) # interpreter not usable or has wrong major version if (result) - set (_${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE "Cannot use the interpreter \"${_${_PYTHON_PREFIX}_EXECUTABLE}\"" PARENT_SCOPE) + set_property (CACHE _${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE PROPERTY VALUE "Cannot use the interpreter \"${_${_PYTHON_PREFIX}_EXECUTABLE}\"") else() - set (_${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE "Wrong major version for the interpreter \"${_${_PYTHON_PREFIX}_EXECUTABLE}\"" PARENT_SCOPE) + set_property (CACHE _${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE PROPERTY VALUE "Wrong major version for the interpreter \"${_${_PYTHON_PREFIX}_EXECUTABLE}\"") endif() set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND") return() @@ -836,9 +839,9 @@ function (_PYTHON_VALIDATE_INTERPRETER) if (result OR NOT size EQUAL CMAKE_SIZEOF_VOID_P) # interpreter not usable or has wrong architecture if (result) - set (_${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE "Cannot use the interpreter \"${_${_PYTHON_PREFIX}_EXECUTABLE}\"" PARENT_SCOPE) + set_property (CACHE _${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE PROPERTY VALUE "Cannot use the interpreter \"${_${_PYTHON_PREFIX}_EXECUTABLE}\"") else() - set (_${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE "Wrong architecture for the interpreter \"${_${_PYTHON_PREFIX}_EXECUTABLE}\"" PARENT_SCOPE) + set_property (CACHE _${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE PROPERTY VALUE "Wrong architecture for the interpreter \"${_${_PYTHON_PREFIX}_EXECUTABLE}\"") endif() set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND") return() @@ -846,6 +849,14 @@ function (_PYTHON_VALIDATE_INTERPRETER) endif() endfunction() +function(_python_validate_find_interpreter status interpreter) + set(_${_PYTHON_PREFIX}_EXECUTABLE "${interpreter}" CACHE FILEPATH "" FORCE) + _python_validate_interpreter (${_${_PYTHON_PREFIX}_VALIDATE_OPTIONS}) + if (NOT _${_PYTHON_PREFIX}_EXECUTABLE) + set (${status} FALSE PARENT_SCOPE) + endif() +endfunction() + function (_PYTHON_VALIDATE_COMPILER) if (NOT _${_PYTHON_PREFIX}_COMPILER) @@ -856,7 +867,7 @@ function (_PYTHON_VALIDATE_COMPILER) if (_PVC_CHECK_EXISTS AND NOT EXISTS "${_${_PYTHON_PREFIX}_COMPILER}") # Compiler does not exist anymore - set (_${_PYTHON_PREFIX}_Compiler_REASON_FAILURE "Cannot find the compiler \"${_${_PYTHON_PREFIX}_COMPILER}\"" PARENT_SCOPE) + set_property (CACHE _${_PYTHON_PREFIX}_Compiler_REASON_FAILURE PROPERTY VALUE "Cannot find the compiler \"${_${_PYTHON_PREFIX}_COMPILER}\"") set_property (CACHE _${_PYTHON_PREFIX}_COMPILER PROPERTY VALUE "${_PYTHON_PREFIX}_COMPILER-NOTFOUND") return() endif() @@ -883,7 +894,7 @@ function (_PYTHON_VALIDATE_COMPILER) file (REMOVE_RECURSE "${working_dir}") if (result) # compiler is not usable - set (_${_PYTHON_PREFIX}_Compiler_REASON_FAILURE "Cannot use the compiler \"${_${_PYTHON_PREFIX}_COMPILER}\"" PARENT_SCOPE) + set_property (CACHE _${_PYTHON_PREFIX}_Compiler_REASON_FAILURE PROPERTY VALUE "Cannot use the compiler \"${_${_PYTHON_PREFIX}_COMPILER}\"") set_property (CACHE _${_PYTHON_PREFIX}_COMPILER PROPERTY VALUE "${_PYTHON_PREFIX}_COMPILER-NOTFOUND") return() endif() @@ -909,7 +920,7 @@ function (_PYTHON_VALIDATE_COMPILER) if (_PVC_EXACT AND NOT version VERSION_EQUAL _PVC_VERSION) # interpreter has wrong version - set (_${_PYTHON_PREFIX}_Compiler_REASON_FAILURE "Wrong version for the compiler \"${_${_PYTHON_PREFIX}_COMPILER}\"" PARENT_SCOPE) + set_property (CACHE _${_PYTHON_PREFIX}_Compiler_REASON_FAILURE PROPERTY VALUE "Wrong version for the compiler \"${_${_PYTHON_PREFIX}_COMPILER}\"") set_property (CACHE _${_PYTHON_PREFIX}_COMPILER PROPERTY VALUE "${_PYTHON_PREFIX}_COMPILER-NOTFOUND") return() else() @@ -918,7 +929,7 @@ function (_PYTHON_VALIDATE_COMPILER) string(REGEX REPLACE "^([0-9]+)\\.?.*$" "\\1" expected_major_version "${_PVC_VERSION}") if (NOT major_version VERSION_EQUAL expected_major_version OR NOT version VERSION_GREATER_EQUAL _PVC_VERSION) - set (_${_PYTHON_PREFIX}_Compiler_REASON_FAILURE "Wrong version for the compiler \"${_${_PYTHON_PREFIX}_COMPILER}\"" PARENT_SCOPE) + set_property (CACHE _${_PYTHON_PREFIX}_Compiler_REASON_FAILURE PROPERTY VALUE "Wrong version for the compiler \"${_${_PYTHON_PREFIX}_COMPILER}\"") set_property (CACHE _${_PYTHON_PREFIX}_COMPILER PROPERTY VALUE "${_PYTHON_PREFIX}_COMPILER-NOTFOUND") return() endif() @@ -930,7 +941,7 @@ function (_PYTHON_VALIDATE_COMPILER) find_package_check_version ("${version}" in_range HANDLE_VERSION_RANGE) if (NOT in_range) # interpreter has invalid version - set (_${_PYTHON_PREFIX}_Compiler_REASON_FAILURE "Wrong version for the compiler \"${_${_PYTHON_PREFIX}_COMPILER}\"" PARENT_SCOPE) + set_property (CACHE _${_PYTHON_PREFIX}_Compiler_REASON_FAILURE PROPERTY VALUE "Wrong version for the compiler \"${_${_PYTHON_PREFIX}_COMPILER}\"") set_property (CACHE _${_PYTHON_PREFIX}_COMPILER PROPERTY VALUE "${_PYTHON_PREFIX}_COMPILER-NOTFOUND") return() endif() @@ -939,13 +950,21 @@ function (_PYTHON_VALIDATE_COMPILER) string(REGEX REPLACE "^([0-9]+)\\.?.*$" "\\1" major_version "${version}") if (NOT major_version EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR) # Compiler has wrong major version - set (_${_PYTHON_PREFIX}_Compiler_REASON_FAILURE "Wrong major version for the compiler \"${_${_PYTHON_PREFIX}_COMPILER}\"" PARENT_SCOPE) + set_property (CACHE _${_PYTHON_PREFIX}_Compiler_REASON_FAILURE PROPERTY VALUE "Wrong major version for the compiler \"${_${_PYTHON_PREFIX}_COMPILER}\"") set_property (CACHE _${_PYTHON_PREFIX}_COMPILER PROPERTY VALUE "${_PYTHON_PREFIX}_COMPILER-NOTFOUND") return() endif() endif() endfunction() +function(_python_validate_find_compiler status compiler) + set(_${_PYTHON_PREFIX}_COMPILER "${compiler}" CACHE FILEPATH "" FORCE) + _python_validate_compiler (${_${_PYTHON_PREFIX}_VALIDATE_OPTIONS}) + if (NOT _${_PYTHON_PREFIX}_COMPILER) + set (${status} FALSE PARENT_SCOPE) + endif() +endfunction() + function (_PYTHON_VALIDATE_LIBRARY) if (NOT _${_PYTHON_PREFIX}_LIBRARY_RELEASE) @@ -957,7 +976,7 @@ function (_PYTHON_VALIDATE_LIBRARY) if (_PVL_CHECK_EXISTS AND NOT EXISTS "${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}") # library does not exist anymore - set (_${_PYTHON_PREFIX}_Development_REASON_FAILURE "Cannot find the library \"${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}\"" PARENT_SCOPE) + set_property (CACHE _${_PYTHON_PREFIX}_Development_REASON_FAILURE PROPERTY VALUE "Cannot find the library \"${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}\"") set_property (CACHE _${_PYTHON_PREFIX}_LIBRARY_RELEASE PROPERTY VALUE "${_PYTHON_PREFIX}_LIBRARY_RELEASE-NOTFOUND") if (WIN32) set_property (CACHE _${_PYTHON_PREFIX}_LIBRARY_DEBUG PROPERTY VALUE "${_PYTHON_PREFIX}_LIBRARY_DEBUG-NOTFOUND") @@ -971,7 +990,7 @@ function (_PYTHON_VALIDATE_LIBRARY) if (DEFINED _${_PYTHON_PREFIX}_FIND_ABI AND NOT lib_ABI IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS) # incompatible ABI - set (_${_PYTHON_PREFIX}_Development_REASON_FAILURE "Wrong ABI for the library \"${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}\"" PARENT_SCOPE) + set_property (CACHE _${_PYTHON_PREFIX}_Development_REASON_FAILURE PROPERTY VALUE "Wrong ABI for the library \"${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}\"") set_property (CACHE _${_PYTHON_PREFIX}_LIBRARY_RELEASE PROPERTY VALUE "${_PYTHON_PREFIX}_LIBRARY_RELEASE-NOTFOUND") else() if (_PVL_VERSION OR _PVL_IN_RANGE) @@ -980,7 +999,7 @@ function (_PYTHON_VALIDATE_LIBRARY) string (REGEX MATCH "[0-9](\\.[0-9]+)?" version "${_PVL_VERSION}") if ((_PVL_EXACT AND NOT lib_VERSION VERSION_EQUAL version) OR (lib_VERSION VERSION_LESS version)) # library has wrong version - set (_${_PYTHON_PREFIX}_Development_REASON_FAILURE "Wrong version for the library \"${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}\"" PARENT_SCOPE) + set_property (CACHE _${_PYTHON_PREFIX}_Development_REASON_FAILURE PROPERTY VALUE "Wrong version for the library \"${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}\"") set_property (CACHE _${_PYTHON_PREFIX}_LIBRARY_RELEASE PROPERTY VALUE "${_PYTHON_PREFIX}_LIBRARY_RELEASE-NOTFOUND") endif() endif() @@ -990,14 +1009,14 @@ function (_PYTHON_VALIDATE_LIBRARY) find_package_check_version ("${lib_VERSION}" in_range HANDLE_VERSION_RANGE) if (NOT in_range) # library has wrong version - set (_${_PYTHON_PREFIX}_Development_REASON_FAILURE "Wrong version for the library \"${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}\"" PARENT_SCOPE) + set_property (CACHE _${_PYTHON_PREFIX}_Development_REASON_FAILURE PROPERTY VALUE "Wrong version for the library \"${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}\"") set_property (CACHE _${_PYTHON_PREFIX}_LIBRARY_RELEASE PROPERTY VALUE "${_PYTHON_PREFIX}_LIBRARY_RELEASE-NOTFOUND") endif() endif() else() if (NOT lib_VERSION_MAJOR VERSION_EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR) # library has wrong major version - set (_${_PYTHON_PREFIX}_Development_REASON_FAILURE "Wrong major version for the library \"${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}\"" PARENT_SCOPE) + set_property (CACHE _${_PYTHON_PREFIX}_Development_REASON_FAILURE PROPERTY VALUE "Wrong major version for the library \"${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}\"") set_property (CACHE _${_PYTHON_PREFIX}_LIBRARY_RELEASE PROPERTY VALUE "${_PYTHON_PREFIX}_LIBRARY_RELEASE-NOTFOUND") endif() endif() @@ -1023,7 +1042,7 @@ function (_PYTHON_VALIDATE_INCLUDE_DIR) if (_PVID_CHECK_EXISTS AND NOT EXISTS "${_${_PYTHON_PREFIX}_INCLUDE_DIR}") # include file does not exist anymore - set (_${_PYTHON_PREFIX}_Development_REASON_FAILURE "Cannot find the directory \"${_${_PYTHON_PREFIX}_INCLUDE_DIR}\"" PARENT_SCOPE) + set_property (CACHE _${_PYTHON_PREFIX}_Development_REASON_FAILURE PROPERTY VALUE "Cannot find the directory \"${_${_PYTHON_PREFIX}_INCLUDE_DIR}\"") set_property (CACHE _${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND") return() endif() @@ -1033,14 +1052,14 @@ function (_PYTHON_VALIDATE_INCLUDE_DIR) if (DEFINED _${_PYTHON_PREFIX}_FIND_ABI AND NOT inc_ABI IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS) # incompatible ABI - set (_${_PYTHON_PREFIX}_Development_REASON_FAILURE "Wrong ABI for the directory \"${_${_PYTHON_PREFIX}_INCLUDE_DIR}\"" PARENT_SCOPE) + set_property (CACHE _${_PYTHON_PREFIX}_Development_REASON_FAILURE PROPERTY VALUE "Wrong ABI for the directory \"${_${_PYTHON_PREFIX}_INCLUDE_DIR}\"") set_property (CACHE _${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND") else() if (_PVID_VERSION OR _PVID_IN_RANGE) if (_PVID_VERSION) if ((_PVID_EXACT AND NOT inc_VERSION VERSION_EQUAL expected_version) OR (inc_VERSION VERSION_LESS expected_version)) # include dir has wrong version - set (_${_PYTHON_PREFIX}_Development_REASON_FAILURE "Wrong version for the directory \"${_${_PYTHON_PREFIX}_INCLUDE_DIR}\"" PARENT_SCOPE) + set_property (CACHE _${_PYTHON_PREFIX}_Development_REASON_FAILURE PROPERTY VALUE "Wrong version for the directory \"${_${_PYTHON_PREFIX}_INCLUDE_DIR}\"") set_property (CACHE _${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND") endif() endif() @@ -1050,14 +1069,14 @@ function (_PYTHON_VALIDATE_INCLUDE_DIR) find_package_check_version ("${inc_VERSION}" in_range HANDLE_VERSION_RANGE) if (NOT in_range) # include dir has wrong version - set (_${_PYTHON_PREFIX}_Development_REASON_FAILURE "Wrong version for the directory \"${_${_PYTHON_PREFIX}_INCLUDE_DIR}\"" PARENT_SCOPE) + set_property (CACHE _${_PYTHON_PREFIX}_Development_REASON_FAILURE PROPERTY VALUE "Wrong version for the directory \"${_${_PYTHON_PREFIX}_INCLUDE_DIR}\"") set_property (CACHE _${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND") endif() endif() else() if (NOT inc_VERSION_MAJOR VERSION_EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR) # include dir has wrong major version - set (_${_PYTHON_PREFIX}_Development_REASON_FAILURE "Wrong major version for the directory \"${_${_PYTHON_PREFIX}_INCLUDE_DIR}\"" PARENT_SCOPE) + set_property (CACHE _${_PYTHON_PREFIX}_Development_REASON_FAILURE PROPERTY VALUE "Wrong major version for the directory \"${_${_PYTHON_PREFIX}_INCLUDE_DIR}\"") set_property (CACHE _${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND") endif() endif() @@ -1247,12 +1266,14 @@ if (DEFINED ${_PYTHON_PREFIX}_FIND_STRATEGY) endif() # Python and Anaconda distributions: define which architectures can be used +unset (_${_PYTHON_PREFIX}_REGISTRY_VIEW) if (CMAKE_SIZEOF_VOID_P) math (EXPR _${_PYTHON_PREFIX}_ARCH "${CMAKE_SIZEOF_VOID_P} * 8") if ("Development.Module" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS OR "Development.Embed" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) # In this case, search only for 64bit or 32bit set (_${_PYTHON_PREFIX}_ARCH2 ${_${_PYTHON_PREFIX}_ARCH}) + set (_${_PYTHON_PREFIX}_REGISTRY_VIEW REGISTRY_VIEW ${_${_PYTHON_PREFIX}_ARCH}) else() if (_${_PYTHON_PREFIX}_ARCH EQUAL "32") set (_${_PYTHON_PREFIX}_ARCH2 64) @@ -1506,9 +1527,13 @@ endfunction() unset (_${_PYTHON_PREFIX}_REQUIRED_VARS) unset (_${_PYTHON_PREFIX}_CACHED_VARS) unset (_${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE) +set (_${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE CACHE INTERNAL "Interpreter reason failure") unset (_${_PYTHON_PREFIX}_Compiler_REASON_FAILURE) +set (_${_PYTHON_PREFIX}_Compiler_REASON_FAILURE CACHE INTERNAL "Compiler reason failure") unset (_${_PYTHON_PREFIX}_Development_REASON_FAILURE) +set (_${_PYTHON_PREFIX}_Development_REASON_FAILURE CACHE INTERNAL "Development reason failure") unset (_${_PYTHON_PREFIX}_NumPy_REASON_FAILURE) +set (_${_PYTHON_PREFIX}_NumPy_REASON_FAILURE CACHE INTERNAL "NumPy reason failure") # preamble @@ -1590,9 +1615,8 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) - - _python_validate_interpreter (${_${_PYTHON_PREFIX}_VALIDATE_OPTIONS}) + NO_CMAKE_SYSTEM_PATH + VALIDATOR _python_validate_find_interpreter) if (_${_PYTHON_PREFIX}_EXECUTABLE) break() endif() @@ -1612,8 +1636,8 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) - _python_validate_interpreter (${${_PYTHON_PREFIX}_VALIDATE_OPTIONS}) + NO_CMAKE_SYSTEM_PATH + VALIDATOR _python_validate_find_interpreter) if (_${_PYTHON_PREFIX}_EXECUTABLE) break() endif() @@ -1626,9 +1650,10 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) HINTS ${_${_PYTHON_PREFIX}_HINTS} PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} + ${_${_PYTHON_PREFIX}_REGISTRY_VIEW} NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) - _python_validate_interpreter (${${_PYTHON_PREFIX}_VALIDATE_OPTIONS}) + NO_CMAKE_SYSTEM_PATH + VALIDATOR _python_validate_find_interpreter) if (_${_PYTHON_PREFIX}_EXECUTABLE) break() endif() @@ -1641,8 +1666,8 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) HINTS ${_${_PYTHON_PREFIX}_HINTS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) - _python_validate_interpreter (${${_PYTHON_PREFIX}_VALIDATE_OPTIONS}) + NO_CMAKE_SYSTEM_PATH + VALIDATOR _python_validate_find_interpreter) if (_${_PYTHON_PREFIX}_EXECUTABLE) break() endif() @@ -1650,8 +1675,8 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) find_program (_${_PYTHON_PREFIX}_EXECUTABLE NAMES ${_${_PYTHON_PREFIX}_NAMES} NAMES_PER_DIR - PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES}) - _python_validate_interpreter (${${_PYTHON_PREFIX}_VALIDATE_OPTIONS}) + PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} + VALIDATOR _python_validate_find_interpreter) if (_${_PYTHON_PREFIX}_EXECUTABLE) break() endif() @@ -1663,8 +1688,8 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) NAMES_PER_DIR PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} - NO_DEFAULT_PATH) - _python_validate_interpreter (${${_PYTHON_PREFIX}_VALIDATE_OPTIONS}) + NO_DEFAULT_PATH + VALIDATOR _python_validate_find_interpreter) if (_${_PYTHON_PREFIX}_EXECUTABLE) break() endif() @@ -1676,8 +1701,9 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) NAMES_PER_DIR PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} - NO_DEFAULT_PATH) - _python_validate_interpreter (${${_PYTHON_PREFIX}_VALIDATE_OPTIONS}) + ${_${_PYTHON_PREFIX}_REGISTRY_VIEW} + NO_DEFAULT_PATH + VALIDATOR _python_validate_find_interpreter) if (_${_PYTHON_PREFIX}_EXECUTABLE) break() endif() @@ -1687,9 +1713,9 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) endwhile() else() # look-up for various versions and locations - set (_${_PYTHON_PREFIX}_VALIDATE_OPTIONS EXACT) + set (_${_PYTHON_PREFIX}_COMMON_VALIDATE_OPTIONS EXACT) if (${_PYTHON_PREFIX}_FIND_VERSION_RANGE) - list (APPEND _${_PYTHON_PREFIX}_VALIDATE_OPTIONS IN_RANGE) + list (APPEND _${_PYTHON_PREFIX}_COMMON_VALIDATE_OPTIONS IN_RANGE) endif() foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS) @@ -1698,6 +1724,7 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) _python_get_frameworks (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS VERSION ${_${_PYTHON_PREFIX}_VERSION}) _python_get_registries (_${_PYTHON_PREFIX}_REGISTRY_PATHS VERSION ${_${_PYTHON_PREFIX}_VERSION}) + set (_${_PYTHON_PREFIX}_VALIDATE_OPTIONS VERSION ${_${_PYTHON_PREFIX}_VERSION} ${_${_PYTHON_PREFIX}_COMMON_VALIDATE_OPTIONS}) # Virtual environments handling if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$") @@ -1710,8 +1737,8 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) - _python_validate_interpreter (VERSION ${_${_PYTHON_PREFIX}_VERSION} ${_${_PYTHON_PREFIX}_VALIDATE_OPTIONS}) + NO_CMAKE_SYSTEM_PATH + VALIDATOR _python_validate_find_interpreter) if (_${_PYTHON_PREFIX}_EXECUTABLE) break() endif() @@ -1731,7 +1758,8 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) + NO_CMAKE_SYSTEM_PATH + VALIDATOR _python_validate_find_interpreter) endif() # Windows registry @@ -1742,11 +1770,12 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) HINTS ${_${_PYTHON_PREFIX}_HINTS} PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} + ${_${_PYTHON_PREFIX}_REGISTRY_VIEW} NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) + NO_CMAKE_SYSTEM_PATH + VALIDATOR _python_validate_find_interpreter) endif() - _python_validate_interpreter (VERSION ${_${_PYTHON_PREFIX}_VERSION} ${_${_PYTHON_PREFIX}_VALIDATE_OPTIONS}) if (_${_PYTHON_PREFIX}_EXECUTABLE) break() endif() @@ -1758,21 +1787,18 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) HINTS ${_${_PYTHON_PREFIX}_HINTS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) - _python_validate_interpreter (VERSION ${_${_PYTHON_PREFIX}_VERSION} ${_${_PYTHON_PREFIX}_VALIDATE_OPTIONS}) + NO_CMAKE_SYSTEM_PATH + VALIDATOR _python_validate_find_interpreter) if (_${_PYTHON_PREFIX}_EXECUTABLE) break() endif() + # try using standard paths. - # NAMES_PER_DIR is not defined on purpose to have a chance to find - # expected version. - # For example, typical systems have 'python' for version 2.* and 'python3' - # for version 3.*. So looking for names per dir will find, potentially, - # systematically 'python' (i.e. version 2) even if version 3 is searched. find_program (_${_PYTHON_PREFIX}_EXECUTABLE NAMES ${_${_PYTHON_PREFIX}_NAMES} - PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES}) - _python_validate_interpreter (VERSION ${_${_PYTHON_PREFIX}_VERSION} ${_${_PYTHON_PREFIX}_VALIDATE_OPTIONS}) + NAMES_PER_DIR + PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} + VALIDATOR _python_validate_find_interpreter) if (_${_PYTHON_PREFIX}_EXECUTABLE) break() endif() @@ -1784,7 +1810,8 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) NAMES_PER_DIR PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} - NO_DEFAULT_PATH) + NO_DEFAULT_PATH + VALIDATOR _python_validate_find_interpreter) endif() # Windows registry @@ -1794,10 +1821,11 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) NAMES_PER_DIR PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} - NO_DEFAULT_PATH) + ${_${_PYTHON_PREFIX}_REGISTRY_VIEW} + NO_DEFAULT_PATH + VALIDATOR _python_validate_find_interpreter) endif() - _python_validate_interpreter (VERSION ${_${_PYTHON_PREFIX}_VERSION} ${_${_PYTHON_PREFIX}_VALIDATE_OPTIONS}) if (_${_PYTHON_PREFIX}_EXECUTABLE) break() endif() @@ -1806,15 +1834,12 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) if (NOT _${_PYTHON_PREFIX}_EXECUTABLE AND NOT _${_PYTHON_PREFIX}_FIND_VIRTUALENV STREQUAL "ONLY") # No specific version found. Retry with generic names and standard paths. - # NAMES_PER_DIR is not defined on purpose to have a chance to find - # expected version. - # For example, typical systems have 'python' for version 2.* and 'python3' - # for version 3.*. So looking for names per dir will find, potentially, - # systematically 'python' (i.e. version 2) even if version 3 is searched. _python_get_names (_${_PYTHON_PREFIX}_NAMES POSIX INTERPRETER) + unset (_${_PYTHON_PREFIX}_VALIDATE_OPTIONS) find_program (_${_PYTHON_PREFIX}_EXECUTABLE - NAMES ${_${_PYTHON_PREFIX}_NAMES}) - _python_validate_interpreter () + NAMES ${_${_PYTHON_PREFIX}_NAMES} + NAMES_PER_DIR + VALIDATOR _python_validate_find_interpreter) endif() endif() endif() @@ -1836,7 +1861,7 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) # Interpreter is not usable set (_${_PYTHON_PREFIX}_EXECUTABLE_USABLE FALSE) unset (${_PYTHON_PREFIX}_VERSION) - set (_${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE "Cannot run the interpreter \"${_${_PYTHON_PREFIX}_EXECUTABLE}\"") + set_property (CACHE _${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE PROPERTY VALUE "Cannot run the interpreter \"${_${_PYTHON_PREFIX}_EXECUTABLE}\"") endif() endif() @@ -1884,7 +1909,7 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) endif() if (${_PYTHON_PREFIX}_Interpreter_FOUND) - unset (_${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE) + unset (_${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE CACHE) # compute and save interpreter signature string (MD5 __${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${_${_PYTHON_PREFIX}_EXECUTABLE}") @@ -2058,8 +2083,8 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) - _python_validate_compiler (${_${_PYTHON_PREFIX}_VALIDATE_OPTIONS}) + NO_CMAKE_SYSTEM_PATH + VALIDATOR _python_validate_find_compiler) if (_${_PYTHON_PREFIX}_COMPILER) break() endif() @@ -2072,9 +2097,10 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS} PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} + ${_${_PYTHON_PREFIX}_REGISTRY_VIEW} NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) - _python_validate_compiler (${_${_PYTHON_PREFIX}_VALIDATE_OPTIONS}) + NO_CMAKE_SYSTEM_PATH + VALIDATOR _python_validate_find_compiler) if (_${_PYTHON_PREFIX}_COMPILER) break() endif() @@ -2087,8 +2113,8 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) - _python_validate_compiler (${_${_PYTHON_PREFIX}_VALIDATE_OPTIONS}) + NO_CMAKE_SYSTEM_PATH + VALIDATOR _python_validate_find_compiler) if (_${_PYTHON_PREFIX}_COMPILER) break() endif() @@ -2097,8 +2123,8 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) find_program (_${_PYTHON_PREFIX}_COMPILER NAMES ${_${_PYTHON_PREFIX}_COMPILER_NAMES} NAMES_PER_DIR - PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES}) - _python_validate_compiler (${_${_PYTHON_PREFIX}_VALIDATE_OPTIONS}) + PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} + VALIDATOR _python_validate_find_compiler) if (_${_PYTHON_PREFIX}_COMPILER) break() endif() @@ -2110,12 +2136,13 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) NAMES_PER_DIR PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} - NO_DEFAULT_PATH) - _python_validate_compiler (${_${_PYTHON_PREFIX}_VALIDATE_OPTIONS}) + NO_DEFAULT_PATH + VALIDATOR _python_validate_find_compiler) if (_${_PYTHON_PREFIX}_COMPILER) break() endif() endif() + # Windows registry if (CMAKE_HOST_WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST") find_program (_${_PYTHON_PREFIX}_COMPILER @@ -2123,8 +2150,9 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) NAMES_PER_DIR PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} - NO_DEFAULT_PATH) - _python_validate_compiler (${_${_PYTHON_PREFIX}_VALIDATE_OPTIONS}) + ${_${_PYTHON_PREFIX}_REGISTRY_VIEW} + NO_DEFAULT_PATH + VALIDATOR _python_validate_find_compiler) if (_${_PYTHON_PREFIX}_COMPILER) break() endif() @@ -2134,9 +2162,9 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) endwhile() else() # try using root dir and registry - set (_${_PYTHON_PREFIX}_VALIDATE_OPTIONS EXACT) + set (_${_PYTHON_PREFIX}_COMMON_VALIDATE_OPTIONS EXACT) if (${_PYTHON_PREFIX}_FIND_VERSION_RANGE) - list (APPEND _${_PYTHON_PREFIX}_VALIDATE_OPTIONS IN_RANGE) + list (APPEND _${_PYTHON_PREFIX}_COMMON_VALIDATE_OPTIONS IN_RANGE) endif() foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS) @@ -2157,6 +2185,8 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) IMPLEMENTATIONS IronPython VERSION ${_${_PYTHON_PREFIX}_VERSION}) + set (_${_PYTHON_PREFIX}_VALIDATE_OPTIONS VERSION ${_${_PYTHON_PREFIX}_VERSION} ${_${_PYTHON_PREFIX}_COMMON_VALIDATE_OPTIONS}) + # Apple frameworks handling if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST") find_program (_${_PYTHON_PREFIX}_COMPILER @@ -2168,8 +2198,8 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) - _python_validate_compiler (VERSION ${_${_PYTHON_PREFIX}_VERSION} ${_${_PYTHON_PREFIX}_VALIDATE_OPTIONS}) + NO_CMAKE_SYSTEM_PATH + VALIDATOR _python_validate_find_compiler) if (_${_PYTHON_PREFIX}_COMPILER) break() endif() @@ -2182,9 +2212,10 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS} PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} + ${_${_PYTHON_PREFIX}_REGISTRY_VIEW} NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) - _python_validate_compiler (VERSION ${_${_PYTHON_PREFIX}_VERSION} ${_${_PYTHON_PREFIX}_VALIDATE_OPTIONS}) + NO_CMAKE_SYSTEM_PATH + VALIDATOR _python_validate_find_compiler) if (_${_PYTHON_PREFIX}_COMPILER) break() endif() @@ -2197,8 +2228,8 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) - _python_validate_compiler (VERSION ${_${_PYTHON_PREFIX}_VERSION} ${_${_PYTHON_PREFIX}_VALIDATE_OPTIONS}) + NO_CMAKE_SYSTEM_PATH + VALIDATOR _python_validate_find_compiler) if (_${_PYTHON_PREFIX}_COMPILER) break() endif() @@ -2210,8 +2241,8 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) NAMES_PER_DIR PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} - NO_DEFAULT_PATH) - _python_validate_compiler (VERSION ${_${_PYTHON_PREFIX}_VERSION} ${_${_PYTHON_PREFIX}_VALIDATE_OPTIONS}) + NO_DEFAULT_PATH + VALIDATOR _python_validate_find_compiler) if (_${_PYTHON_PREFIX}_COMPILER) break() endif() @@ -2223,8 +2254,9 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) NAMES_PER_DIR PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} - NO_DEFAULT_PATH) - _python_validate_compiler (VERSION ${_${_PYTHON_PREFIX}_VERSION} ${_${_PYTHON_PREFIX}_VALIDATE_OPTIONS}) + ${_${_PYTHON_PREFIX}_REGISTRY_VIEW} + NO_DEFAULT_PATH + VALIDATOR _python_validate_find_compiler) if (_${_PYTHON_PREFIX}_COMPILER) break() endif() @@ -2240,11 +2272,13 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) IMPLEMENTATIONS IronPython VERSION ${_${_PYTHON_PREFIX}_FIND_VERSIONS} COMPILER) + unset (_${_PYTHON_PREFIX}_VALIDATE_OPTIONS) find_program (_${_PYTHON_PREFIX}_COMPILER NAMES ${_${_PYTHON_PREFIX}_COMPILER_NAMES} + NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS} - PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES}) - _python_validate_compiler () + PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} + VALIDATOR _python_validate_find_compiler) endif() endif() @@ -2285,7 +2319,7 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) else() # compiler not usable set (_${_PYTHON_PREFIX}_COMPILER_USABLE FALSE) - set (_${_PYTHON_PREFIX}_Compiler_REASON_FAILURE "Cannot run the compiler \"${_${_PYTHON_PREFIX}_COMPILER}\"") + set_property (CACHE _${_PYTHON_PREFIX}_Compiler_REASON_FAILURE PROPERTY VALUE "Cannot run the compiler \"${_${_PYTHON_PREFIX}_COMPILER}\"") endif() file (REMOVE_RECURSE "${_${_PYTHON_PREFIX}_VERSION_DIR}") endif() @@ -2304,7 +2338,7 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) endif() if (${_PYTHON_PREFIX}_Compiler_FOUND) - unset (_${_PYTHON_PREFIX}_Compiler_REASON_FAILURE) + unset (_${_PYTHON_PREFIX}_Compiler_REASON_FAILURE CACHE) # compute and save compiler signature string (MD5 __${_PYTHON_PREFIX}_COMPILER_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${_${_PYTHON_PREFIX}_COMPILER}") @@ -2786,7 +2820,7 @@ if (("Development.Module" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS set (${_PYTHON_PREFIX}_LIBRARY_RELEASE "${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}") if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE AND NOT EXISTS "${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}") - set (_${_PYTHON_PREFIX}_Development_REASON_FAILURE "Cannot find the library \"${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}\"") + set_property (CACHE _${_PYTHON_PREFIX}_Development_REASON_FAILURE PROPERTY VALUE "Cannot find the library \"${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}\"") set_property (CACHE _${_PYTHON_PREFIX}_LIBRARY_RELEASE PROPERTY VALUE "${_PYTHON_PREFIX}_LIBRARY_RELEASE-NOTFOUND") endif() @@ -2837,7 +2871,15 @@ if (("Development.Module" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS if ("INCLUDE_DIR" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_ARTIFACTS) while (NOT _${_PYTHON_PREFIX}_INCLUDE_DIR) - if ("LIBRARY" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_ARTIFACTS + set (_${_PYTHON_PREFIX}_LIBRARY_REQUIRED TRUE) + foreach (_${_PYTHON_PREFIX}_COMPONENT IN ITEMS Module Embed) + string (TOUPPER "${_${_PYTHON_PREFIX}_COMPONENT}" _${_PYTHON_PREFIX}_ID) + if ("Development.${_${_PYTHON_PREFIX}_COMPONENT}" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS + AND NOT "LIBRARY" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_${_${_PYTHON_PREFIX}_ID}_ARTIFACTS) + set (_${_PYTHON_PREFIX}_LIBRARY_REQUIRED FALSE) + endif() + endforeach() + if (_${_PYTHON_PREFIX}_LIBRARY_REQUIRED AND NOT _${_PYTHON_PREFIX}_LIBRARY_RELEASE) # Don't search for include dir if no library was founded break() @@ -2939,7 +2981,7 @@ if (("Development.Module" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS set (${_PYTHON_PREFIX}_INCLUDE_DIRS "${_${_PYTHON_PREFIX}_INCLUDE_DIR}") if (_${_PYTHON_PREFIX}_INCLUDE_DIR AND NOT EXISTS "${_${_PYTHON_PREFIX}_INCLUDE_DIR}") - set (_${_PYTHON_PREFIX}_Development_REASON_FAILURE "Cannot find the directory \"${_${_PYTHON_PREFIX}_INCLUDE_DIR}\"") + set_property (CACHE _${_PYTHON_PREFIX}_Development_REASON_FAILURE PROPERTY VALUE "Cannot find the directory \"${_${_PYTHON_PREFIX}_INCLUDE_DIR}\"") set_property (CACHE _${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND") endif() @@ -3033,7 +3075,7 @@ if (("Development.Module" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS AND ${_PYTHON_PREFIX}_Development.Embed_FOUND) OR (NOT "Development.Embed" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS AND ${_PYTHON_PREFIX}_Development.Module_FOUND)) - unset (_${_PYTHON_PREFIX}_Development_REASON_FAILURE) + unset (_${_PYTHON_PREFIX}_Development_REASON_FAILURE CACHE) endif() if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS @@ -3144,7 +3186,7 @@ if ("NumPy" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS AND ${_PYTHON_PREFIX}_Inte set (${_PYTHON_PREFIX}_NumPy_INCLUDE_DIRS "${_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}") if(_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR AND NOT EXISTS "${_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}") - set (_${_PYTHON_PREFIX}_NumPy_REASON_FAILURE "Cannot find the directory \"${_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}\"") + set_property (CACHE _${_PYTHON_PREFIX}_NumPy_REASON_FAILURE PROPERTY VALUE "Cannot find the directory \"${_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}\"") set_property (CACHE _${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR PROPERTY VALUE "${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR-NOTFOUND") endif() @@ -3166,7 +3208,7 @@ if ("NumPy" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS AND ${_PYTHON_PREFIX}_Inte endif() if (${_PYTHON_PREFIX}_NumPy_FOUND) - unset (_${_PYTHON_PREFIX}_NumPy_REASON_FAILURE) + unset (_${_PYTHON_PREFIX}_NumPy_REASON_FAILURE CACHE) # compute and save numpy signature string (MD5 __${_PYTHON_PREFIX}_NUMPY_SIGNATURE "${_${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE}:${_${_PYTHON_PREFIX}_DEVELOPMENT_MODULE_SIGNATURE}:${${_PYTHON_PREFIX}_NumPyINCLUDE_DIR}") @@ -3196,7 +3238,7 @@ unset (_${_PYTHON_PREFIX}_REASON_FAILURE) foreach (_${_PYTHON_PREFIX}_COMPONENT IN ITEMS Interpreter Compiler Development NumPy) if (_${_PYTHON_PREFIX}_${_${_PYTHON_PREFIX}_COMPONENT}_REASON_FAILURE) string (APPEND _${_PYTHON_PREFIX}_REASON_FAILURE "\n ${_${_PYTHON_PREFIX}_COMPONENT}: ${_${_PYTHON_PREFIX}_${_${_PYTHON_PREFIX}_COMPONENT}_REASON_FAILURE}") - unset (_${_PYTHON_PREFIX}_${_${_PYTHON_PREFIX}_COMPONENT}_REASON_FAILURE) + unset (_${_PYTHON_PREFIX}_${_${_PYTHON_PREFIX}_COMPONENT}_REASON_FAILURE CACHE) endif() endforeach() diff --git a/Modules/FindRuby.cmake b/Modules/FindRuby.cmake index a80758d..b14349f 100644 --- a/Modules/FindRuby.cmake +++ b/Modules/FindRuby.cmake @@ -369,56 +369,17 @@ if(Ruby_EXECUTABLE AND NOT Ruby_VERSION_MAJOR) set(Ruby_VERSION_MAJOR 1) set(Ruby_VERSION_MINOR 9) endif() - # check whether we found 2.0.x - if(${Ruby_EXECUTABLE} MATCHES "ruby2\\.?0") + # check whether we found 2.[0-7].x + if(${Ruby_EXECUTABLE} MATCHES "ruby2") set(Ruby_VERSION_MAJOR 2) - set(Ruby_VERSION_MINOR 0) + string(REGEX_REPLACE ${Ruby_EXECUTABLE} "ruby2\\.?([0-7])" "\\1" Ruby_VERSION_MINOR) endif() - # check whether we found 2.1.x - if(${Ruby_EXECUTABLE} MATCHES "ruby2\\.?1") - set(Ruby_VERSION_MAJOR 2) - set(Ruby_VERSION_MINOR 1) - endif() - # check whether we found 2.2.x - if(${Ruby_EXECUTABLE} MATCHES "ruby2\\.?2") - set(Ruby_VERSION_MAJOR 2) - set(Ruby_VERSION_MINOR 2) - endif() - # check whether we found 2.3.x - if(${Ruby_EXECUTABLE} MATCHES "ruby2\\.?3") - set(Ruby_VERSION_MAJOR 2) - set(Ruby_VERSION_MINOR 3) - endif() - # check whether we found 2.4.x - if(${Ruby_EXECUTABLE} MATCHES "ruby2\\.?4") - set(Ruby_VERSION_MAJOR 2) - set(Ruby_VERSION_MINOR 4) - endif() - # check whether we found 2.5.x - if(${Ruby_EXECUTABLE} MATCHES "ruby2\\.?5") - set(Ruby_VERSION_MAJOR 2) - set(Ruby_VERSION_MINOR 5) - endif() - # check whether we found 2.6.x - if(${Ruby_EXECUTABLE} MATCHES "ruby2\\.?6") - set(Ruby_VERSION_MAJOR 2) - set(Ruby_VERSION_MINOR 6) - endif() - # check whether we found 2.7.x - if(${Ruby_EXECUTABLE} MATCHES "ruby2\\.?7") - set(Ruby_VERSION_MAJOR 2) - set(Ruby_VERSION_MINOR 7) - endif() - # check whether we found 3.0.x - if(${Ruby_EXECUTABLE} MATCHES "ruby3\\.?0") - set(Ruby_VERSION_MAJOR 3) - set(Ruby_VERSION_MINOR 0) - endif() - # check whether we found 3.1.x - if(${Ruby_EXECUTABLE} MATCHES "ruby3\\.?1") + # check whether we found 3.[0-1].x + if(${Ruby_EXECUTABLE} MATCHES "ruby3") set(Ruby_VERSION_MAJOR 3) - set(Ruby_VERSION_MINOR 1) + string(REGEX_REPLACE ${Ruby_EXECUTABLE} "ruby3\\.?([0-1])" "\\1" Ruby_VERSION_MINOR) endif() + endif() if(Ruby_VERSION_MAJOR) diff --git a/Modules/FindSDL_gfx.cmake b/Modules/FindSDL_gfx.cmake new file mode 100644 index 0000000..2dd96e9 --- /dev/null +++ b/Modules/FindSDL_gfx.cmake @@ -0,0 +1,86 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindSDL_gfx +----------- + +.. versionadded:: 3.25 + +Locate SDL_gfx library + +This module defines: + +:: + + SDL::SDL_gfx, the name of the target to use with target_*() commands + SDL_GFX_LIBRARIES, the name of the library to link against + SDL_GFX_INCLUDE_DIRS, where to find the headers + SDL_GFX_FOUND, if false, do not try to link against + SDL_GFX_VERSION_STRING - human-readable string containing the + version of SDL_gfx + +``$SDLDIR`` is an environment variable that would correspond to the +``./configure --prefix=$SDLDIR`` used in building SDL. +#]=======================================================================] + +find_path(SDL_GFX_INCLUDE_DIRS + NAMES + SDL_framerate.h + SDL_gfxBlitFunc.h + SDL_gfxPrimitives.h + SDL_gfxPrimitives_font.h + SDL_imageFilter.h + SDL_rotozoom.h + HINTS + ENV SDLGFXDIR + ENV SDLDIR + PATH_SUFFIXES SDL + # path suffixes to search inside ENV{SDLDIR} + include/SDL include/SDL12 include/SDL11 include +) + +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(VC_LIB_PATH_SUFFIX lib/x64) +else() + set(VC_LIB_PATH_SUFFIX lib/x86) +endif() + +find_library(SDL_GFX_LIBRARIES + NAMES SDL_gfx + HINTS + ENV SDLGFXDIR + ENV SDLDIR + PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX} +) + +if(SDL_GFX_INCLUDE_DIRS AND EXISTS "${SDL_GFX_INCLUDE_DIRS}/SDL_gfxPrimitives.h") + file(STRINGS "${SDL_GFX_INCLUDE_DIRS}/SDL_gfxPrimitives.h" SDL_GFX_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_GFXPRIMITIVES_MAJOR[ \t]+[0-9]+$") + file(STRINGS "${SDL_GFX_INCLUDE_DIRS}/SDL_gfxPrimitives.h" SDL_GFX_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_GFXPRIMITIVES_MINOR[ \t]+[0-9]+$") + file(STRINGS "${SDL_GFX_INCLUDE_DIRS}/SDL_gfxPrimitives.h" SDL_GFX_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_GFXPRIMITIVES_MICRO[ \t]+[0-9]+$") + string(REGEX REPLACE "^#define[ \t]+SDL_GFXPRIMITIVES_MAJOR[ \t]+([0-9]+)$" "\\1" SDL_GFX_VERSION_MAJOR "${SDL_GFX_VERSION_MAJOR_LINE}") + string(REGEX REPLACE "^#define[ \t]+SDL_GFXPRIMITIVES_MINOR[ \t]+([0-9]+)$" "\\1" SDL_GFX_VERSION_MINOR "${SDL_GFX_VERSION_MINOR_LINE}") + string(REGEX REPLACE "^#define[ \t]+SDL_GFXPRIMITIVES_MICRO[ \t]+([0-9]+)$" "\\1" SDL_GFX_VERSION_PATCH "${SDL_GFX_VERSION_PATCH_LINE}") + set(SDL_GFX_VERSION_STRING ${SDL_GFX_VERSION_MAJOR}.${SDL_GFX_VERSION_MINOR}.${SDL_GFX_VERSION_PATCH}) + unset(SDL_GFX_VERSION_MAJOR_LINE) + unset(SDL_GFX_VERSION_MINOR_LINE) + unset(SDL_GFX_VERSION_PATCH_LINE) + unset(SDL_GFX_VERSION_MAJOR) + unset(SDL_GFX_VERSION_MINOR) + unset(SDL_GFX_VERSION_PATCH) +endif() + +include(FindPackageHandleStandardArgs) + +FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL_gfx + REQUIRED_VARS SDL_GFX_LIBRARIES SDL_GFX_INCLUDE_DIRS + VERSION_VAR SDL_GFX_VERSION_STRING) + +if(SDL_gfx_FOUND) + if(NOT TARGET SDL::SDL_gfx) + add_library(SDL::SDL_gfx INTERFACE IMPORTED) + set_target_properties(SDL::SDL_gfx PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${SDL_GFX_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${SDL_GFX_LIBRARIES}") + endif() +endif() diff --git a/Modules/FindSDL_image.cmake b/Modules/FindSDL_image.cmake index e687b49..324fef5 100644 --- a/Modules/FindSDL_image.cmake +++ b/Modules/FindSDL_image.cmake @@ -31,10 +31,6 @@ For backward compatibility the following variables are also set: $SDLDIR is an environment variable that would correspond to the ./configure --prefix=$SDLDIR used in building SDL. - -Created by Eric Wing. This was influenced by the FindSDL.cmake -module, but with modifications to recognize OS X frameworks and -additional Unix paths (FreeBSD, etc). #]=======================================================================] if(NOT SDL_IMAGE_INCLUDE_DIR AND SDLIMAGE_INCLUDE_DIR) diff --git a/Modules/FindSDL_mixer.cmake b/Modules/FindSDL_mixer.cmake index 315400a..8ed3cb4 100644 --- a/Modules/FindSDL_mixer.cmake +++ b/Modules/FindSDL_mixer.cmake @@ -31,10 +31,6 @@ For backward compatibility the following variables are also set: $SDLDIR is an environment variable that would correspond to the ./configure --prefix=$SDLDIR used in building SDL. - -Created by Eric Wing. This was influenced by the FindSDL.cmake -module, but with modifications to recognize OS X frameworks and -additional Unix paths (FreeBSD, etc). #]=======================================================================] if(NOT SDL_MIXER_INCLUDE_DIR AND SDLMIXER_INCLUDE_DIR) diff --git a/Modules/FindSDL_net.cmake b/Modules/FindSDL_net.cmake index 28cb4d6..639e5bd 100644 --- a/Modules/FindSDL_net.cmake +++ b/Modules/FindSDL_net.cmake @@ -30,10 +30,6 @@ For backward compatibility the following variables are also set: $SDLDIR is an environment variable that would correspond to the ./configure --prefix=$SDLDIR used in building SDL. - -Created by Eric Wing. This was influenced by the FindSDL.cmake -module, but with modifications to recognize OS X frameworks and -additional Unix paths (FreeBSD, etc). #]=======================================================================] if(NOT SDL_NET_INCLUDE_DIR AND SDLNET_INCLUDE_DIR) diff --git a/Modules/FindSDL_sound.cmake b/Modules/FindSDL_sound.cmake index 8d2f9f8..d863e3c 100644 --- a/Modules/FindSDL_sound.cmake +++ b/Modules/FindSDL_sound.cmake @@ -54,7 +54,19 @@ Typically, you should not use these variables directly, and you should use SDL_SOUND_LIBRARIES which contains SDL_SOUND_LIBRARY and the other audio libraries (if needed) to successfully compile on your system. -Created by Eric Wing. This module is a bit more complicated than the +Responds to the $SDLDIR and $SDLSOUNDDIR environmental variable that +would correspond to the ./configure --prefix=$SDLDIR used in building +SDL. + +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 selectionor set the CMake environment CMAKE_INCLUDE_PATH +to modify the search paths. +#]=======================================================================] + + +#[[ +This module is a bit more complicated than the other FindSDL* family modules. The reason is that SDL_sound can be compiled in a large variety of different ways which are independent of platform. SDL_sound may dynamically link against other 3rd party @@ -70,16 +82,7 @@ This module uses a brute force approach to create a test program that uses SDL_sound, and then tries to build it. If the build fails, it parses the error output for known symbol names to figure out which libraries are needed. - -Responds to the $SDLDIR and $SDLSOUNDDIR environmental variable that -would correspond to the ./configure --prefix=$SDLDIR used in building -SDL. - -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 selectionor set the CMake environment CMAKE_INCLUDE_PATH -to modify the search paths. -#]=======================================================================] +#]] set(SDL_SOUND_EXTRAS "" CACHE STRING "SDL_sound extra flags") mark_as_advanced(SDL_SOUND_EXTRAS) @@ -182,9 +185,9 @@ if(SDL_FOUND AND SDL_SOUND_INCLUDE_DIR AND SDL_SOUND_LIBRARY) try_compile( MY_RESULT - ${PROJECT_BINARY_DIR}/CMakeTmp - ${PROJECT_BINARY_DIR}/CMakeTmp - DetermineSoundLibs + PROJECT DetermineSoundLibs + SOURCE_DIR ${PROJECT_BINARY_DIR}/CMakeTmp + BINARY_DIR ${PROJECT_BINARY_DIR}/CMakeTmp OUTPUT_VARIABLE MY_OUTPUT ) diff --git a/Modules/FindSDL_ttf.cmake b/Modules/FindSDL_ttf.cmake index d5721da..d67c089 100644 --- a/Modules/FindSDL_ttf.cmake +++ b/Modules/FindSDL_ttf.cmake @@ -30,10 +30,6 @@ For backward compatibility the following variables are also set: $SDLDIR is an environment variable that would correspond to the ./configure --prefix=$SDLDIR used in building SDL. - -Created by Eric Wing. This was influenced by the FindSDL.cmake -module, but with modifications to recognize OS X frameworks and -additional Unix paths (FreeBSD, etc). #]=======================================================================] if(NOT SDL_TTF_INCLUDE_DIR AND SDLTTF_INCLUDE_DIR) diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake index a675fd6..7326ef9 100644 --- a/Modules/FindThreads.cmake +++ b/Modules/FindThreads.cmake @@ -129,14 +129,12 @@ macro(_threads_check_flag_pthread) elseif(NOT DEFINED THREADS_HAVE_PTHREAD_ARG) message(CHECK_START "Check if compiler accepts -pthread") if(CMAKE_C_COMPILER_LOADED) - set(_threads_src ${CMAKE_CURRENT_LIST_DIR}/CheckForPthreads.c) + set(_threads_src CheckForPthreads.c) elseif(CMAKE_CXX_COMPILER_LOADED) - set(_threads_src ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindThreads/CheckForPthreads.cxx) - configure_file(${CMAKE_CURRENT_LIST_DIR}/CheckForPthreads.c "${_threads_src}" COPYONLY) + set(_threads_src CheckForPthreads.cxx) endif() try_compile(THREADS_HAVE_PTHREAD_ARG - ${CMAKE_BINARY_DIR} - ${_threads_src} + SOURCE_FROM_FILE "${_threads_src}" "${CMAKE_CURRENT_LIST_DIR}/CheckForPthreads.c" CMAKE_FLAGS -DLINK_LIBRARIES:STRING=-pthread OUTPUT_VARIABLE _cmake_check_pthreads_output) diff --git a/Modules/FindVulkan.cmake b/Modules/FindVulkan.cmake index 7ca7d03..3817987 100644 --- a/Modules/FindVulkan.cmake +++ b/Modules/FindVulkan.cmake @@ -36,6 +36,11 @@ There are corresponding imported targets for each of these. ``MoltenVK`` On macOS, an additional component ``MoltenVK`` is available. +``dxc`` + .. versionadded:: 3.25 + + The DirectX Shader Compiler. + The ``glslc`` and ``glslangValidator`` components are provided even if not explicitly requested (for backward compatibility). @@ -89,6 +94,21 @@ This module defines :prop_tgt:`IMPORTED` targets if Vulkan has been found: Defined if SDK has the Khronos library which implement a subset of Vulkan API over Apple Metal graphics framework. (MoltenVK). +``Vulkan::volk`` + .. versionadded:: 3.25 + + Defined if SDK has the Vulkan meta-loader (volk). + +``Vulkan::dxc_lib`` + .. versionadded:: 3.25 + + Defined if SDK has the DirectX shader compiler library. + +``Vulkan::dxc_exe`` + .. versionadded:: 3.25 + + Defined if SDK has the DirectX shader compiler CLI tool. + Result Variables ^^^^^^^^^^^^^^^^ @@ -128,6 +148,21 @@ This module defines the following variables: .. versionadded:: 3.24 True, if the SDK has the MoltenVK library. +``Vulkan_volk_FOUND`` + .. versionadded:: 3.25 + + True, if the SDK has the volk library. + +``Vulkan_dxc_lib_FOUND`` + .. versionadded:: 3.25 + + True, if the SDK has the DirectX shader compiler library. + +``Vulkan_dxc_exe_FOUND`` + .. versionadded:: 3.25 + + True, if the SDK has the DirectX shader compiler CLI tool. + The module will also defines these cache variables: @@ -156,6 +191,21 @@ The module will also defines these cache variables: Path to the MoltenVK library. +``Vulkan_volk_LIBRARY`` + .. versionadded:: 3.25 + + Path to the volk library. + +``Vulkan_dxc_LIBRARY`` + .. versionadded:: 3.25 + + Path to the DirectX shader compiler library. + +``Vulkan_dxc_EXECUTABLE`` + .. versionadded:: 3.25 + + Path to the DirectX shader compiler CLI tool. + Hints ^^^^^ @@ -403,6 +453,27 @@ if(MoltenVK IN_LIST Vulkan_FIND_COMPONENTS) ) mark_as_advanced(Vulkan_MoltenVK_INCLUDE_DIR) endif() +if(volk IN_LIST Vulkan_FIND_COMPONENTS) + find_library(Vulkan_volk_LIBRARY + NAMES volk + HINTS + ${_Vulkan_hint_library_search_paths}) + mark_as_advanced(Vulkan_Volk_LIBRARY) +endif() + +if (dxc IN_LIST Vulkan_FIND_COMPONENTS) + find_library(Vulkan_dxc_LIBRARY + NAMES dxcompiler + HINTS + ${_Vulkan_hint_library_search_paths}) + mark_as_advanced(Vulkan_dxc_LIBRARY) + + find_program(Vulkan_dxc_EXECUTABLE + NAMES dxc + HINTS + ${_Vulkan_hint_executable_search_paths}) + mark_as_advanced(Vulkan_dxc_EXECUTABLE) +endif() if(Vulkan_GLSLC_EXECUTABLE) set(Vulkan_glslc_FOUND TRUE) @@ -416,6 +487,12 @@ else() set(Vulkan_glslangValidator_FOUND FALSE) endif() +if (Vulkan_dxc_EXECUTABLE) + set(Vulkan_dxc_exe_FOUND TRUE) +else() + set(Vulkan_dxc_exe_FOUND FALSE) +endif() + function(_Vulkan_set_library_component_found component) cmake_parse_arguments(PARSE_ARGV 1 _ARG "NO_WARNING" @@ -466,6 +543,8 @@ _Vulkan_set_library_component_found(glslang glslang-genericcodegen) _Vulkan_set_library_component_found(shaderc_combined) _Vulkan_set_library_component_found(SPIRV-Tools) +_Vulkan_set_library_component_found(volk) +_Vulkan_set_library_component_found(dxc) if(Vulkan_MoltenVK_INCLUDE_DIR AND Vulkan_MoltenVK_LIBRARY) set(Vulkan_MoltenVK_FOUND TRUE) @@ -752,6 +831,44 @@ if(Vulkan_FOUND) IMPORTED_LOCATION_DEBUG "${Vulkan_SPIRV-Tools_DEBUG_LIBRARY}") endif() endif() + + if(Vulkan_volk_LIBRARY AND NOT TARGET Vulkan::volk) + add_library(Vulkan::volk STATIC IMPORTED) + set_property(TARGET Vulkan::volk + PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") + set_property(TARGET Vulkan::volk APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Release) + set_property(TARGET Vulkan::volk APPEND + PROPERTY + IMPORTED_LOCATION_RELEASE "${Vulkan_volk_LIBRARY}") + + if (NOT WIN32) + set_property(TARGET Vulkan::volk APPEND + PROPERTY + IMPORTED_LINK_INTERFACE_LIBRARIES dl) + endif() + endif() + + if (Vulkan_dxc_LIBRARY AND NOT TARGET Vulkan::dxc_lib) + add_library(Vulkan::dxc_lib STATIC IMPORTED) + set_property(TARGET Vulkan::dxc_lib + PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") + set_property(TARGET Vulkan::dxc_lib APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Release) + set_property(TARGET Vulkan::dxc_lib APPEND + PROPERTY + IMPORTED_LOCATION_RELEASE "${Vulkan_dxc_LIBRARY}") + endif() + + if(Vulkan_dxc_EXECUTABLE AND NOT TARGET Vulkan::dxc_exe) + add_executable(Vulkan::dxc_exe IMPORTED) + set_property(TARGET Vulkan::dxc_exe PROPERTY IMPORTED_LOCATION "${Vulkan_dxc_EXECUTABLE}") + endif() + endif() if(Vulkan_MoltenVK_FOUND) diff --git a/Modules/FindZLIB.cmake b/Modules/FindZLIB.cmake index be5c775..cfe6715 100644 --- a/Modules/FindZLIB.cmake +++ b/Modules/FindZLIB.cmake @@ -60,6 +60,14 @@ module where to look. #]=======================================================================] +if(ZLIB_FIND_COMPONENTS AND NOT ZLIB_FIND_QUIETLY) + message(AUTHOR_WARNING + "ZLIB does not provide any COMPONENTS. Calling\n" + " find_package(ZLIB COMPONENTS ...)\n" + "will always fail." + ) +endif() + set(_ZLIB_SEARCHES) # Search ZLIB_ROOT first if it is set. @@ -164,7 +172,8 @@ endif() include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZLIB REQUIRED_VARS ZLIB_LIBRARY ZLIB_INCLUDE_DIR - VERSION_VAR ZLIB_VERSION_STRING) + VERSION_VAR ZLIB_VERSION_STRING + HANDLE_COMPONENTS) if(ZLIB_FOUND) set(ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR}) diff --git a/Modules/FortranCInterface.cmake b/Modules/FortranCInterface.cmake index 53df01a..af025af 100644 --- a/Modules/FortranCInterface.cmake +++ b/Modules/FortranCInterface.cmake @@ -361,10 +361,10 @@ function(FortranCInterface_VERIFY) # Build a sample project which reports symbols. set(CMAKE_TRY_COMPILE_CONFIGURATION Release) try_compile(FortranCInterface_VERIFY_${lang}_COMPILED - ${FortranCInterface_BINARY_DIR}/Verify${lang} - ${FortranCInterface_SOURCE_DIR}/Verify - VerifyFortranC # project name - VerifyFortranC # target name + PROJECT VerifyFortranC + TARGET VerifyFortranC + SOURCE_DIR ${FortranCInterface_SOURCE_DIR}/Verify + BINARY_DIR ${FortranCInterface_BINARY_DIR}/Verify${lang} CMAKE_FLAGS -DVERIFY_CXX=${verify_cxx} -DCMAKE_VERBOSE_MAKEFILE=ON "-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS}" diff --git a/Modules/FortranCInterface/Detect.cmake b/Modules/FortranCInterface/Detect.cmake index 567fc37..6401aed 100644 --- a/Modules/FortranCInterface/Detect.cmake +++ b/Modules/FortranCInterface/Detect.cmake @@ -47,10 +47,10 @@ unset(_FortranCInterface_CMP0056) # Build a sample project which reports symbols. set(CMAKE_TRY_COMPILE_CONFIGURATION Release) try_compile(FortranCInterface_COMPILED - ${FortranCInterface_BINARY_DIR} - ${FortranCInterface_SOURCE_DIR} - FortranCInterface # project name - FortranCInterface # target name + PROJECT FortranCInterface + TARGET FortranCInterface + SOURCE_DIR ${FortranCInterface_SOURCE_DIR} + BINARY_DIR ${FortranCInterface_BINARY_DIR} CMAKE_FLAGS "-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS}" "-DCMAKE_Fortran_FLAGS:STRING=${CMAKE_Fortran_FLAGS}" diff --git a/Modules/GoogleTest.cmake b/Modules/GoogleTest.cmake index f5f4f02..b8dc482 100644 --- a/Modules/GoogleTest.cmake +++ b/Modules/GoogleTest.cmake @@ -348,7 +348,7 @@ function(gtest_add_tests) unset(testList) set(gtest_case_name_regex ".*\\( *([A-Za-z_0-9]+) *, *([A-Za-z_0-9]+) *\\).*") - set(gtest_test_type_regex "(TYPED_TEST|TEST_?[FP]?)") + set(gtest_test_type_regex "(TYPED_TEST|TEST)_?[FP]?") foreach(source IN LISTS ARGS_SOURCES) if(NOT ARGS_SKIP_DEPENDENCY) @@ -361,7 +361,9 @@ function(gtest_add_tests) # Parameterized tests have a different signature for the filter if("x${test_type}" STREQUAL "xTEST_P") - string(REGEX REPLACE ${gtest_case_name_regex} "*/\\1.\\2/*" gtest_test_name ${hit}) + string(REGEX REPLACE ${gtest_case_name_regex} "*/\\1.\\2/*" gtest_test_name ${hit}) + elseif("x${test_type}" STREQUAL "xTYPED_TEST_P") + string(REGEX REPLACE ${gtest_case_name_regex} "*/\\1/*.\\2" gtest_test_name ${hit}) elseif("x${test_type}" STREQUAL "xTEST_F" OR "x${test_type}" STREQUAL "xTEST") string(REGEX REPLACE ${gtest_case_name_regex} "\\1.\\2" gtest_test_name ${hit}) elseif("x${test_type}" STREQUAL "xTYPED_TEST") diff --git a/Modules/Internal/CPack/CPackDeb.cmake b/Modules/Internal/CPack/CPackDeb.cmake index 958a6db..38e32c2 100644 --- a/Modules/Internal/CPack/CPackDeb.cmake +++ b/Modules/Internal/CPack/CPackDeb.cmake @@ -37,8 +37,8 @@ endfunction() #extract library name and version for given shared object function(extract_so_info shared_object libname version) - if(READELF_EXECUTABLE) - execute_process(COMMAND "${READELF_EXECUTABLE}" -d "${shared_object}" + if(CPACK_READELF_EXECUTABLE) + execute_process(COMMAND "${CPACK_READELF_EXECUTABLE}" -d "${shared_object}" WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" RESULT_VARIABLE result OUTPUT_VARIABLE output @@ -197,15 +197,15 @@ function(cpack_deb_prepare_package_vars) endforeach() endif() - find_program(READELF_EXECUTABLE NAMES readelf) + find_program(CPACK_READELF_EXECUTABLE NAMES readelf) if(CPACK_DEBIAN_DEBUGINFO_PACKAGE AND CPACK_DEB_UNSTRIPPED_FILES) - find_program(OBJCOPY_EXECUTABLE NAMES objcopy) + find_program(CPACK_OBJCOPY_EXECUTABLE NAMES objcopy) - if(NOT OBJCOPY_EXECUTABLE) + if(NOT CPACK_OBJCOPY_EXECUTABLE) message(FATAL_ERROR "debuginfo packages require the objcopy tool") endif() - if(NOT READELF_EXECUTABLE) + if(NOT CPACK_READELF_EXECUTABLE) message(FATAL_ERROR "debuginfo packages require the readelf tool") endif() @@ -213,7 +213,7 @@ function(cpack_deb_prepare_package_vars) foreach(_FILE IN LISTS CPACK_DEB_UNSTRIPPED_FILES) # Get the file's Build ID - execute_process(COMMAND env LC_ALL=C ${READELF_EXECUTABLE} -n "${_FILE}" + execute_process(COMMAND env LC_ALL=C ${CPACK_READELF_EXECUTABLE} -n "${_FILE}" WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" OUTPUT_VARIABLE READELF_OUTPUT RESULT_VARIABLE READELF_RESULT @@ -221,7 +221,7 @@ function(cpack_deb_prepare_package_vars) OUTPUT_STRIP_TRAILING_WHITESPACE ) if(NOT READELF_RESULT EQUAL 0) message(FATAL_ERROR "CPackDeb: readelf: '${READELF_ERROR}';\n" - "executed command: '${READELF_EXECUTABLE} -n ${_FILE}'") + "executed command: '${CPACK_READELF_EXECUTABLE} -n ${_FILE}'") endif() if(READELF_OUTPUT MATCHES "Build ID: ([0-9a-zA-Z][0-9a-zA-Z])([0-9a-zA-Z]*)") set(_BUILD_ID_START ${CMAKE_MATCH_1}) @@ -235,7 +235,7 @@ function(cpack_deb_prepare_package_vars) set(_FILE_DBGSYM ${_DBGSYM_ROOT}/usr/lib/debug/.build-id/${_BUILD_ID_START}/${_BUILD_ID_REMAINING}.debug) get_filename_component(_OUT_DIR "${_FILE_DBGSYM}" DIRECTORY) file(MAKE_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}/${_OUT_DIR}") - execute_process(COMMAND ${OBJCOPY_EXECUTABLE} --only-keep-debug "${_FILE}" "${_FILE_DBGSYM}" + execute_process(COMMAND ${CPACK_OBJCOPY_EXECUTABLE} --only-keep-debug "${_FILE}" "${_FILE_DBGSYM}" WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" OUTPUT_VARIABLE OBJCOPY_OUTPUT RESULT_VARIABLE OBJCOPY_RESULT @@ -243,9 +243,9 @@ function(cpack_deb_prepare_package_vars) OUTPUT_STRIP_TRAILING_WHITESPACE ) if(NOT OBJCOPY_RESULT EQUAL 0) message(FATAL_ERROR "CPackDeb: objcopy: '${OBJCOPY_ERROR}';\n" - "executed command: '${OBJCOPY_EXECUTABLE} --only-keep-debug ${_FILE} ${_FILE_DBGSYM}'") + "executed command: '${CPACK_OBJCOPY_EXECUTABLE} --only-keep-debug ${_FILE} ${_FILE_DBGSYM}'") endif() - execute_process(COMMAND ${OBJCOPY_EXECUTABLE} --strip-unneeded ${_FILE} + execute_process(COMMAND ${CPACK_OBJCOPY_EXECUTABLE} --strip-unneeded ${_FILE} WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" OUTPUT_VARIABLE OBJCOPY_OUTPUT RESULT_VARIABLE OBJCOPY_RESULT @@ -253,9 +253,9 @@ function(cpack_deb_prepare_package_vars) OUTPUT_STRIP_TRAILING_WHITESPACE ) if(NOT OBJCOPY_RESULT EQUAL 0) message(FATAL_ERROR "CPackDeb: objcopy: '${OBJCOPY_ERROR}';\n" - "executed command: '${OBJCOPY_EXECUTABLE} --strip-debug ${_FILE}'") + "executed command: '${CPACK_OBJCOPY_EXECUTABLE} --strip-debug ${_FILE}'") endif() - execute_process(COMMAND ${OBJCOPY_EXECUTABLE} --add-gnu-debuglink=${_FILE_DBGSYM} ${_FILE} + execute_process(COMMAND ${CPACK_OBJCOPY_EXECUTABLE} --add-gnu-debuglink=${_FILE_DBGSYM} ${_FILE} WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" OUTPUT_VARIABLE OBJCOPY_OUTPUT RESULT_VARIABLE OBJCOPY_RESULT @@ -263,7 +263,7 @@ function(cpack_deb_prepare_package_vars) OUTPUT_STRIP_TRAILING_WHITESPACE ) if(NOT OBJCOPY_RESULT EQUAL 0) message(FATAL_ERROR "CPackDeb: objcopy: '${OBJCOPY_ERROR}';\n" - "executed command: '${OBJCOPY_EXECUTABLE} --add-gnu-debuglink=${_FILE_DBGSYM} ${_FILE}'") + "executed command: '${CPACK_OBJCOPY_EXECUTABLE} --add-gnu-debuglink=${_FILE_DBGSYM} ${_FILE}'") endif() endforeach() endif() @@ -652,7 +652,7 @@ function(cpack_deb_prepare_package_vars) unset(CPACK_DEBIAN_PACKAGE_SHLIBS_LIST) if(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS) - if(READELF_EXECUTABLE) + if(CPACK_READELF_EXECUTABLE) foreach(_FILE IN LISTS CPACK_DEB_SHARED_OBJECT_FILES) extract_so_info("${_FILE}" libname soversion) if(libname AND DEFINED soversion) diff --git a/Modules/Internal/CPack/CPackRPM.cmake b/Modules/Internal/CPack/CPackRPM.cmake index cd631b8..7c10280 100644 --- a/Modules/Internal/CPack/CPackRPM.cmake +++ b/Modules/Internal/CPack/CPackRPM.cmake @@ -625,8 +625,8 @@ function(cpack_rpm_debugsymbol_check INSTALL_FILES WORKING_DIR) endif() # With objdump we should check the debug symbols - find_program(OBJDUMP_EXECUTABLE objdump) - if(NOT OBJDUMP_EXECUTABLE) + find_program(CPACK_OBJDUMP_EXECUTABLE objdump) + if(NOT CPACK_OBJDUMP_EXECUTABLE) message(FATAL_ERROR "CPackRPM: objdump binary could not be found!" " Required for debuginfo packaging. See documentation of" " CPACK_RPM_DEBUGINFO_PACKAGE variable for details.") @@ -649,7 +649,7 @@ function(cpack_rpm_debugsymbol_check INSTALL_FILES WORKING_DIR) continue() endif() - execute_process(COMMAND "${OBJDUMP_EXECUTABLE}" -h ${WORKING_DIR}/${F} + execute_process(COMMAND "${CPACK_OBJDUMP_EXECUTABLE}" -h ${WORKING_DIR}/${F} WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}" RESULT_VARIABLE OBJDUMP_EXEC_RESULT OUTPUT_VARIABLE OBJDUMP_OUT diff --git a/Modules/Internal/CheckSourceCompiles.cmake b/Modules/Internal/CheckSourceCompiles.cmake index 27aa3e0..eadf3da 100644 --- a/Modules/Internal/CheckSourceCompiles.cmake +++ b/Modules/Internal/CheckSourceCompiles.cmake @@ -86,15 +86,13 @@ function(CMAKE_CHECK_SOURCE_COMPILES _lang _source _var) else() set(CHECK_${LANG}_SOURCE_COMPILES_ADD_INCLUDES) endif() - file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT}" - "${_source}\n") if(NOT CMAKE_REQUIRED_QUIET) message(CHECK_START "Performing Test ${_var}") endif() + string(APPEND _source "\n") try_compile(${_var} - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT} + SOURCE_FROM_VAR "src.${_SRC_EXT}" _source COMPILE_DEFINITIONS -D${_var} ${CMAKE_REQUIRED_DEFINITIONS} ${CHECK_${LANG}_SOURCE_COMPILES_ADD_LINK_OPTIONS} ${CHECK_${LANG}_SOURCE_COMPILES_ADD_LIBRARIES} diff --git a/Modules/Internal/CheckSourceRuns.cmake b/Modules/Internal/CheckSourceRuns.cmake index 75e9896..09c85c5 100644 --- a/Modules/Internal/CheckSourceRuns.cmake +++ b/Modules/Internal/CheckSourceRuns.cmake @@ -85,15 +85,13 @@ function(CMAKE_CHECK_SOURCE_RUNS _lang _source _var) else() set(CHECK_${_lang}_SOURCE_COMPILES_ADD_INCLUDES) endif() - file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT}" - "${_source}\n") if(NOT CMAKE_REQUIRED_QUIET) message(CHECK_START "Performing Test ${_var}") endif() + string(APPEND _source "\n") try_run(${_var}_EXITCODE ${_var}_COMPILED - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT} + SOURCE_FROM_VAR "src.${_SRC_EXT}" _source COMPILE_DEFINITIONS -D${_var} ${CMAKE_REQUIRED_DEFINITIONS} ${CHECK_${_lang}_SOURCE_COMPILES_ADD_LINK_OPTIONS} ${CHECK_${_lang}_SOURCE_COMPILES_ADD_LIBRARIES} diff --git a/Modules/Internal/FeatureTesting.cmake b/Modules/Internal/FeatureTesting.cmake index b6f3c09..5c144ec 100644 --- a/Modules/Internal/FeatureTesting.cmake +++ b/Modules/Internal/FeatureTesting.cmake @@ -4,7 +4,7 @@ macro(_record_compiler_features lang compile_flags feature_list) string(TOLOWER ${lang} lang_lc) file(REMOVE "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.bin") - file(WRITE "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.${lang_lc}" " + set(_content " const char features[] = {\"\\n\"\n") get_property(known_features GLOBAL PROPERTY CMAKE_${lang}_KNOWN_FEATURES) @@ -16,10 +16,11 @@ macro(_record_compiler_features lang compile_flags feature_list) else() set(_feature_condition "#if ${_cmake_feature_test_${feature}}\n\"1\"\n#else\n\"0\"\n#endif\n") endif() - file(APPEND "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.${lang_lc}" "\"${lang}_FEATURE:\"\n${_feature_condition}\"${feature}\\n\"\n") + string(APPEND _content + "\"${lang}_FEATURE:\"\n${_feature_condition}\"${feature}\\n\"\n") endif() endforeach() - file(APPEND "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.${lang_lc}" + string(APPEND _content "\n};\n\nint main(int argc, char** argv) { (void)argv; return features[argc]; }\n") if(CMAKE_${lang}_LINK_WITH_STANDARD_COMPILE_OPTION) @@ -31,7 +32,7 @@ macro(_record_compiler_features lang compile_flags feature_list) endif() try_compile(CMAKE_${lang}_FEATURE_TEST - ${CMAKE_BINARY_DIR} "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.${lang_lc}" + SOURCE_FROM_VAR "feature_tests.${lang_lc}" _content COMPILE_DEFINITIONS "${compile_flags}" LINK_LIBRARIES "${compile_flags_for_link}" OUTPUT_VARIABLE _output diff --git a/Modules/Platform/AIX-GNU.cmake b/Modules/Platform/AIX-GNU.cmake index 5a532c7..a9aa8e0 100644 --- a/Modules/Platform/AIX-GNU.cmake +++ b/Modules/Platform/AIX-GNU.cmake @@ -23,11 +23,11 @@ macro(__aix_compiler_gnu lang) # Construct the export list ourselves to pass only the object files so # that we export only the symbols actually provided by the sources. set(CMAKE_${lang}_CREATE_SHARED_LIBRARY - "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <OBJECT_DIR>/exports.exp <AIX_EXPORTS> <OBJECTS>" + "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <OBJECT_DIR>/exports.exp -c <CMAKE_${lang}_COMPILER> <AIX_EXPORTS> <OBJECTS>" "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> -Wl,-bE:<OBJECT_DIR>/exports.exp <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" ) set(CMAKE_${lang}_LINK_EXECUTABLE_WITH_EXPORTS - "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <TARGET_IMPLIB> -l . <AIX_EXPORTS> <OBJECTS>" + "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <TARGET_IMPLIB> -c <CMAKE_${lang}_COMPILER> -l . <AIX_EXPORTS> <OBJECTS>" "<CMAKE_${lang}_COMPILER> <FLAGS> <CMAKE_${lang}_LINK_FLAGS> -Wl,-bE:<TARGET_IMPLIB> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") endmacro() diff --git a/Modules/Platform/AIX-XL.cmake b/Modules/Platform/AIX-XL.cmake index 2a8c159..902cbb3 100644 --- a/Modules/Platform/AIX-XL.cmake +++ b/Modules/Platform/AIX-XL.cmake @@ -29,12 +29,12 @@ macro(__aix_compiler_xl lang) # Construct the export list ourselves to pass only the object files so # that we export only the symbols actually provided by the sources. set(CMAKE_${lang}_CREATE_SHARED_LIBRARY - "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <OBJECT_DIR>/exports.exp <AIX_EXPORTS>${_OBJECTS}" + "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <OBJECT_DIR>/exports.exp -c <CMAKE_${lang}_COMPILER> <AIX_EXPORTS>${_OBJECTS}" "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> -Wl,-bE:<OBJECT_DIR>/exports.exp <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" ) set(CMAKE_${lang}_LINK_EXECUTABLE_WITH_EXPORTS - "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <TARGET_IMPLIB> -l . <AIX_EXPORTS> <OBJECTS>" + "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <TARGET_IMPLIB> -c <CMAKE_${lang}_COMPILER> -l . <AIX_EXPORTS> <OBJECTS>" "<CMAKE_${lang}_COMPILER> <FLAGS> <CMAKE_${lang}_LINK_FLAGS> -Wl,-bE:<TARGET_IMPLIB> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") unset(_OBJECTS) diff --git a/Modules/Platform/AIX/ExportImportList b/Modules/Platform/AIX/ExportImportList index 891bce7..5e16fcb 100755 --- a/Modules/Platform/AIX/ExportImportList +++ b/Modules/Platform/AIX/ExportImportList @@ -5,7 +5,7 @@ # This script is internal to CMake and meant only to be # invoked by CMake-generated build systems on AIX. -usage='usage: ExportImportList -o <out-file> [-l <lib>] [-n] [--] <objects>...' +usage='usage: ExportImportList -o <out-file> -c <compiler> [-l <lib>] [-n] [--] <objects>...' die() { echo "$@" 1>&2; exit 1 @@ -15,11 +15,13 @@ die() { out='' lib='' no_objects='' +compiler='' while test "$#" != 0; do case "$1" in -l) shift; lib="$1" ;; -o) shift; out="$1" ;; -n) no_objects='1' ;; + -c) shift; compiler="$1" ;; --) shift; break ;; -*) die "$usage" ;; *) break ;; @@ -27,27 +29,47 @@ while test "$#" != 0; do shift done test -n "$out" || die "$usage" +# We need the compiler executable to resolve where the ibm-llvm-nm executable is +test -n "$compiler" || die "$usage" # Build a temporary file that atomically replaces the output later. out_tmp="$out.tmp$$" trap 'rm -f "$out_tmp"' EXIT INT TERM > "$out_tmp" +# If IPA was enabled and a compiler from the IBMClang family is used, then +# the object files contain LLVM bitcode[0] rather than XCOFF objects and so +# need to be handled differently. +# +# [0]: https://www.ibm.com/docs/en/openxl-c-and-cpp-aix/17.1.0?topic=compatibility-link-time-optimization-lto +NM="$(dirname "$compiler")/../libexec/ibm-llvm-nm" + +function IsBitcode { + # N4 = first 4 bytes, -tx = output in hexadecimal, -An = don't display offset + # cut: trim off the preceding whitespace where the offset would be + # 4243code is the hexadecimal magic number for LLVM bitcode + [ "$(od -N4 -tx -An $1 | cut -d ' ' -f 2)" == "4243c0de" ]; +} + # Collect symbols exported from all object files. if test -z "$no_objects"; then for f in "$@"; do - dump -tov -X 32_64 "$f" | - awk ' - BEGIN { - V["EXPORTED"]=" export" - V["PROTECTED"]=" protected" - } - /^\[[0-9]+\]\tm +[^ ]+ +\.(text|data|bss) +[^ ]+ +(extern|weak) +(EXPORTED|PROTECTED| ) / { - if (!match($NF,/^(\.|__sinit|__sterm|__[0-9]+__)/)) { - print $NF V[$(NF-1)] + if IsBitcode "$f"; then + "$NM" "$f" --defined-only --extern-only --just-symbol-name 2>/dev/null + else + dump -tov -X 32_64 "$f" | + awk ' + BEGIN { + V["EXPORTED"]=" export" + V["PROTECTED"]=" protected" + } + /^\[[0-9]+\]\tm +[^ ]+ +\.(text|data|bss) +[^ ]+ +(extern|weak) +(EXPORTED|PROTECTED| ) / { + if (!match($NF,/^(\.|__sinit|__sterm|__[0-9]+__)/)) { + print $NF V[$(NF-1)] + } } - } - ' + ' + fi done >> "$out_tmp" fi diff --git a/Modules/Platform/DragonFly.cmake b/Modules/Platform/DragonFly.cmake index 12e5f3c..994ba79 100644 --- a/Modules/Platform/DragonFly.cmake +++ b/Modules/Platform/DragonFly.cmake @@ -3,6 +3,7 @@ # see http://archive.netbsd.se/?ml=dfbsd-users&a=2007-07&m=4678361 include(Platform/FreeBSD) +set(BSD "DragonFlyBSD") # DragonFly BSD requires -z origin to enable $ORIGIN expansion in RPATH. # This is not required for FreeBSD since 10.2-RELEASE. diff --git a/Modules/Platform/FreeBSD.cmake b/Modules/Platform/FreeBSD.cmake index bd5a786..9cd9399 100644 --- a/Modules/Platform/FreeBSD.cmake +++ b/Modules/Platform/FreeBSD.cmake @@ -1,3 +1,4 @@ +set(BSD "FreeBSD") set(CMAKE_DL_LIBS "") set(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC") set(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE") diff --git a/Modules/Platform/Linux-IntelLLVM.cmake b/Modules/Platform/Linux-IntelLLVM.cmake index 1363b44..992f80e 100644 --- a/Modules/Platform/Linux-IntelLLVM.cmake +++ b/Modules/Platform/Linux-IntelLLVM.cmake @@ -8,18 +8,6 @@ if(__LINUX_COMPILER_INTEL_LLVM) endif() set(__LINUX_COMPILER_INTEL_LLVM 1) -if(NOT XIAR) - set(_intel_xiar_hints) - foreach(lang C CXX Fortran) - if(IS_ABSOLUTE "${CMAKE_${lang}_COMPILER}") - get_filename_component(_hint "${CMAKE_${lang}_COMPILER}" PATH) - list(APPEND _intel_xiar_hints ${_hint}) - endif() - endforeach() - find_program(XIAR NAMES xiar HINTS ${_intel_xiar_hints}) - mark_as_advanced(XIAR) -endif() - macro(__linux_compiler_intel_llvm lang) set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC") set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE") @@ -37,19 +25,5 @@ macro(__linux_compiler_intel_llvm lang) set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Wl,") set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP ",") - set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES) - - if(XIAR) - # INTERPROCEDURAL_OPTIMIZATION - set(CMAKE_${lang}_COMPILE_OPTIONS_IPO -ipo) - set(CMAKE_${lang}_CREATE_STATIC_LIBRARY_IPO - "${XIAR} cr <TARGET> <LINK_FLAGS> <OBJECTS> " - "${XIAR} -s <TARGET> ") - set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES) - set(_CMAKE_${lang}_IPO_LEGACY_BEHAVIOR YES) - else() - set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER NO) - endif() - set(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY "-fvisibility=") endmacro() diff --git a/Modules/Platform/Linux-NVHPC.cmake b/Modules/Platform/Linux-NVHPC.cmake index aad17f1..602b417 100644 --- a/Modules/Platform/Linux-NVHPC.cmake +++ b/Modules/Platform/Linux-NVHPC.cmake @@ -3,13 +3,15 @@ # This module is shared by multiple languages; use include blocker. -if(__LINUX_COMPILER_NVIDIA) - return() -endif() -set(__LINUX_COMPILER_NVIDIA 1) - -include(Platform/Linux-PGI) +include_guard() macro(__linux_compiler_nvhpc lang) - __linux_compiler_pgi(${lang}) + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC") + set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE") + set(_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER YES) + set(CMAKE_${lang}_LINK_OPTIONS_PIE "-fPIE") + set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "") + set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") + set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "") endmacro() diff --git a/Modules/Platform/Linux.cmake b/Modules/Platform/Linux.cmake index a7e58ab..e3d444e 100644 --- a/Modules/Platform/Linux.cmake +++ b/Modules/Platform/Linux.cmake @@ -1,3 +1,4 @@ +set(LINUX 1) set(CMAKE_DL_LIBS "dl") set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") diff --git a/Modules/Platform/NetBSD.cmake b/Modules/Platform/NetBSD.cmake index ab85923..52c6594 100644 --- a/Modules/Platform/NetBSD.cmake +++ b/Modules/Platform/NetBSD.cmake @@ -1,3 +1,4 @@ +set(BSD "NetBSD") set(CMAKE_DL_LIBS "") set(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC") set(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE") diff --git a/Modules/Platform/OpenBSD.cmake b/Modules/Platform/OpenBSD.cmake index 97e2a6a..51ea60d 100644 --- a/Modules/Platform/OpenBSD.cmake +++ b/Modules/Platform/OpenBSD.cmake @@ -1,4 +1,5 @@ include(Platform/NetBSD) +set(BSD "OpenBSD") # On OpenBSD, the compile time linker does not share it's configuration with # the runtime linker. This will extract the library search paths from the diff --git a/Modules/Platform/SerenityOS-Clang-ASM.cmake b/Modules/Platform/SerenityOS-Clang-ASM.cmake new file mode 100644 index 0000000..ba1e18c --- /dev/null +++ b/Modules/Platform/SerenityOS-Clang-ASM.cmake @@ -0,0 +1,2 @@ +include(Platform/SerenityOS-GNU) +__serenity_compiler_gnu(ASM) diff --git a/Modules/Platform/SerenityOS-Clang-C.cmake b/Modules/Platform/SerenityOS-Clang-C.cmake new file mode 100644 index 0000000..791a197 --- /dev/null +++ b/Modules/Platform/SerenityOS-Clang-C.cmake @@ -0,0 +1,2 @@ +include(Platform/SerenityOS-GNU) +__serenity_compiler_gnu(C) diff --git a/Modules/Platform/SerenityOS-Clang-CXX.cmake b/Modules/Platform/SerenityOS-Clang-CXX.cmake new file mode 100644 index 0000000..084e319 --- /dev/null +++ b/Modules/Platform/SerenityOS-Clang-CXX.cmake @@ -0,0 +1,2 @@ +include(Platform/SerenityOS-GNU) +__serenity_compiler_gnu(CXX) diff --git a/Modules/Platform/SerenityOS-GNU-ASM.cmake b/Modules/Platform/SerenityOS-GNU-ASM.cmake new file mode 100644 index 0000000..ba1e18c --- /dev/null +++ b/Modules/Platform/SerenityOS-GNU-ASM.cmake @@ -0,0 +1,2 @@ +include(Platform/SerenityOS-GNU) +__serenity_compiler_gnu(ASM) diff --git a/Modules/Platform/SerenityOS-GNU-C.cmake b/Modules/Platform/SerenityOS-GNU-C.cmake new file mode 100644 index 0000000..791a197 --- /dev/null +++ b/Modules/Platform/SerenityOS-GNU-C.cmake @@ -0,0 +1,2 @@ +include(Platform/SerenityOS-GNU) +__serenity_compiler_gnu(C) diff --git a/Modules/Platform/SerenityOS-GNU-CXX.cmake b/Modules/Platform/SerenityOS-GNU-CXX.cmake new file mode 100644 index 0000000..084e319 --- /dev/null +++ b/Modules/Platform/SerenityOS-GNU-CXX.cmake @@ -0,0 +1,2 @@ +include(Platform/SerenityOS-GNU) +__serenity_compiler_gnu(CXX) diff --git a/Modules/Platform/SerenityOS-GNU.cmake b/Modules/Platform/SerenityOS-GNU.cmake new file mode 100644 index 0000000..ed39477 --- /dev/null +++ b/Modules/Platform/SerenityOS-GNU.cmake @@ -0,0 +1,24 @@ +# This module is shared by multiple languages; use include blocker. +include_guard() + +set(CMAKE_EXE_LINKER_FLAGS_INIT "-Wl,--hash-style=gnu,-z,relro,-z,now,-z,noexecstack,-z,separate-code,-z,max-page-size=0x1000") + +macro(__serenity_compiler_gnu lang) + set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-rpath,") + set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":") + set(CMAKE_SHARED_LIBRARY_RPATH_LINK_${lang}_FLAG "-Wl,-rpath-link,") + set(CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG "-Wl,-soname,") + set(CMAKE_EXE_EXPORTS_${lang}_FLAG "-Wl,--export-dynamic") + + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared -Wl,--hash-style=gnu,-z,relro,-z,now,-z,noexecstack,-z,separate-code") + + # Initialize link type selection flags. These flags are used when + # building a shared library, shared module, or executable that links + # to other libraries to select whether to use the static or shared + # versions of the libraries. + foreach(type SHARED_LIBRARY SHARED_MODULE EXE) + set(CMAKE_${type}_LINK_STATIC_${lang}_FLAGS "-Wl,-Bstatic") + set(CMAKE_${type}_LINK_DYNAMIC_${lang}_FLAGS "-Wl,-Bdynamic") + endforeach() + +endmacro() diff --git a/Modules/Platform/SerenityOS.cmake b/Modules/Platform/SerenityOS.cmake new file mode 100644 index 0000000..dc4f369 --- /dev/null +++ b/Modules/Platform/SerenityOS.cmake @@ -0,0 +1,12 @@ + +set(SERENITYOS 1) + +set(CMAKE_DL_LIBS "") +set(CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN "\$ORIGIN") +set(CMAKE_SHARED_LIBRARY_SUFFIX ".so") + +# Shared libraries with no builtin soname may not be linked safely by +# specifying the file path. +set(CMAKE_PLATFORM_USES_PATH_WHEN_NO_SONAME 1) + +include(Platform/UnixPaths) diff --git a/Modules/Platform/Windows-Clang-HIP.cmake b/Modules/Platform/Windows-Clang-HIP.cmake new file mode 100644 index 0000000..20879fa --- /dev/null +++ b/Modules/Platform/Windows-Clang-HIP.cmake @@ -0,0 +1,19 @@ +include(Platform/Windows-Clang) +set(_COMPILE_HIP_MSVC " -TP") +__windows_compiler_clang(HIP) + +if("x${CMAKE_HIP_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC") + if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) + AND CMAKE_GENERATOR MATCHES "Makefiles|WMake" + AND CMAKE_DEPFILE_FLAGS_HIP) + set(CMAKE_HIP_DEPENDS_USE_COMPILER TRUE) + endif() +elseif("x${CMAKE_HIP_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU") + if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) + AND CMAKE_GENERATOR MATCHES "Makefiles|WMake" + AND CMAKE_DEPFILE_FLAGS_HIP) + # dependencies are computed by the compiler itself + set(CMAKE_HIP_DEPFILE_FORMAT gcc) + set(CMAKE_HIP_DEPENDS_USE_COMPILER TRUE) + endif() +endif() diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake index 3941311..33d271d 100644 --- a/Modules/Platform/Windows-Clang.cmake +++ b/Modules/Platform/Windows-Clang.cmake @@ -89,17 +89,27 @@ macro(__windows_compiler_clang_gnu lang) set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd) if(CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT) - set(__ADDED_FLAGS "") - set(__ADDED_FLAGS_DEBUG "") + set(_RTL_FLAGS "") + set(_RTL_FLAGS_DEBUG "") else() - set(__ADDED_FLAGS_DEBUG "-D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd") - set(__ADDED_FLAGS "-D_DLL -D_MT -Xclang --dependent-lib=msvcrt") + set(_RTL_FLAGS_DEBUG " -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd") + set(_RTL_FLAGS " -D_DLL -D_MT -Xclang --dependent-lib=msvcrt") endif() - string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g -Xclang -gcodeview -O0 ${__ADDED_FLAGS_DEBUG}") - string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os -DNDEBUG ${__ADDED_FLAGS}") - string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3 -DNDEBUG ${__ADDED_FLAGS}") - string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g -DNDEBUG -Xclang -gcodeview ${__ADDED_FLAGS}") + if(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT) + set(_DBG_FLAGS "") + else() + set(_DBG_FLAGS " -g -Xclang -gcodeview") + endif() + + string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -O0${_DBG_FLAGS}${_RTL_FLAGS_DEBUG}") + string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os -DNDEBUG${_RTL_FLAGS}") + string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3 -DNDEBUG${_RTL_FLAGS}") + string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -DNDEBUG${_DBG_FLAGS}${_RTL_FLAGS}") + + set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_Embedded -g -Xclang -gcodeview) + #set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_ProgramDatabase) # not supported by Clang + #set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_EditAndContinue) # not supported by Clang endif() set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ") set(CMAKE_${lang}_LINKER_SUPPORTS_PDB ON) @@ -109,8 +119,9 @@ macro(__windows_compiler_clang_gnu lang) set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -Xclang -include-pch -Xclang <PCH_FILE> -Xclang -include -Xclang <PCH_HEADER>) set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -Xclang -emit-pch -Xclang -include -Xclang <PCH_HEADER> -x ${__pch_header_${lang}}) - unset(__ADDED_FLAGS) - unset(__ADDED_FLAGS_DEBUG) + unset(_DBG_FLAGS) + unset(_RTL_FLAGS) + unset(_RTL_FLAGS_DEBUG) string(TOLOWER "${CMAKE_BUILD_TYPE}" BUILD_TYPE_LOWER) set(CMAKE_${lang}_STANDARD_LIBRARIES_INIT "-lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -loldnames") @@ -146,24 +157,36 @@ macro(__enable_llvm_rc_preprocessing clang_option_prefix extra_pp_flags) endif() endmacro() +macro(__verify_same_language_values variable) + foreach(lang "C" "CXX" "HIP") + if(DEFINED CMAKE_${lang}_${variable}) + list(APPEND __LANGUAGE_VALUES_${variable} "${CMAKE_${lang}_${variable}}") + endif() + endforeach() + list(REMOVE_DUPLICATES __LANGUAGE_VALUES_${variable}) + list(LENGTH __LANGUAGE_VALUES_${variable} __NUM_VALUES) + + if(__NUM_VALUES GREATER 1) + message(FATAL_ERROR ${ARGN}) + endif() + unset(__NUM_VALUES) + unset(__LANGUAGE_VALUES_${variable}) +endmacro() if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" - OR "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") + OR "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC" + OR "x${CMAKE_HIP_SIMULATE_ID}" STREQUAL "xMSVC") - if ( DEFINED CMAKE_C_COMPILER_ID AND DEFINED CMAKE_CXX_COMPILER_ID - AND NOT "x${CMAKE_C_COMPILER_ID}" STREQUAL "x${CMAKE_CXX_COMPILER_ID}") - message(FATAL_ERROR "The current configuration mixes Clang and MSVC or " - "some other CL compatible compiler tool. This is not supported. " - "Use either clang or MSVC as both C and C++ compilers.") - endif() + __verify_same_language_values(COMPILER_ID + "The current configuration mixes Clang and MSVC or " + "some other CL compatible compiler tool. This is not supported. " + "Use either clang or MSVC as both C, C++ and/or HIP compilers.") - if ( DEFINED CMAKE_C_COMPILER_FRONTEND_VARIANT AND DEFINED CMAKE_CXX_COMPILER_FRONTEND_VARIANT - AND NOT "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}") - message(FATAL_ERROR "The current configuration uses the Clang compiler " - "tool with mixed frontend variants, both the GNU and in MSVC CL " - "like variants. This is not supported. Use either clang/clang++ " - "or clang-cl as both C and C++ compilers.") - endif() + __verify_same_language_values(COMPILER_FRONTEND_VARIANT + "The current configuration uses the Clang compiler " + "tool with mixed frontend variants, both the GNU and in MSVC CL " + "like variants. This is not supported. Use either clang/clang++ " + "or clang-cl as both C, C++ and/or HIP compilers.") if(NOT CMAKE_RC_COMPILER_INIT) # Check if rc is already in the path @@ -183,13 +206,17 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" unset(__RC_COMPILER_PATH CACHE) endif() - if ( "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" OR "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" ) + if ( "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" + OR "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" + OR "x${CMAKE_HIP_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC") + include(Platform/Windows-MSVC) # Set the clang option forwarding prefix for clang-cl usage in the llvm-rc processing stage __enable_llvm_rc_preprocessing("-clang:" "") macro(__windows_compiler_clang_base lang) set(_COMPILE_${lang} "${_COMPILE_${lang}_MSVC}") __windows_compiler_msvc(${lang}) + unset(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_EditAndContinue) # -ZI not supported by Clang set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-WX") set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-imsvc") endmacro() @@ -202,6 +229,14 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" endif() unset(__WINDOWS_CLANG_CMP0091) + cmake_policy(GET CMP0141 __WINDOWS_MSVC_CMP0141) + if(__WINDOWS_MSVC_CMP0141 STREQUAL "NEW") + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT "$<$<CONFIG:Debug,RelWithDebInfo>:Embedded>") + else() + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT "") + endif() + unset(__WINDOWS_MSVC_CMP0141) + set(CMAKE_BUILD_TYPE_INIT Debug) __enable_llvm_rc_preprocessing("" "-x c") diff --git a/Modules/Platform/Windows-Intel-C.cmake b/Modules/Platform/Windows-Intel-C.cmake index e4d9b93..8ae6852 100644 --- a/Modules/Platform/Windows-Intel-C.cmake +++ b/Modules/Platform/Windows-Intel-C.cmake @@ -19,9 +19,8 @@ if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) set(CMAKE_C_DEPENDS_USE_COMPILER TRUE) endif() -if("${CMAKE_SOURCE_DIR}${CMAKE_BINARY_DIR}" MATCHES " ") - # The Intel compiler does not properly escape spaces in a depfile. - # Fall back to msvc depfile format. - set(CMAKE_DEPFILE_FLAGS_C "/showIncludes") - set(CMAKE_C_DEPFILE_FORMAT msvc) -endif() +# The Intel compiler does not properly escape spaces in a depfile which can +# occur in source and binary cmake paths as well as external include paths. +# Until Intel fixes this bug, fall back unconditionally to msvc depfile format. +set(CMAKE_DEPFILE_FLAGS_C "/showIncludes") +set(CMAKE_C_DEPFILE_FORMAT msvc) diff --git a/Modules/Platform/Windows-Intel-CXX.cmake b/Modules/Platform/Windows-Intel-CXX.cmake index 6adbb6e..e2fa2af 100644 --- a/Modules/Platform/Windows-Intel-CXX.cmake +++ b/Modules/Platform/Windows-Intel-CXX.cmake @@ -20,9 +20,8 @@ if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) set(CMAKE_CXX_DEPENDS_USE_COMPILER TRUE) endif() -if("${CMAKE_SOURCE_DIR}${CMAKE_BINARY_DIR}" MATCHES " ") - # The Intel compiler does not properly escape spaces in a depfile. - # Fall back to msvc depfile format. - set(CMAKE_DEPFILE_FLAGS_CXX "/showIncludes") - set(CMAKE_CXX_DEPFILE_FORMAT msvc) -endif() +# The Intel compiler does not properly escape spaces in a depfile which can +# occur in source and binary cmake paths as well as external include paths. +# Until Intel fixes this bug, fall back unconditionally to msvc depfile format. +set(CMAKE_DEPFILE_FLAGS_CXX "/showIncludes") +set(CMAKE_CXX_DEPFILE_FORMAT msvc) diff --git a/Modules/Platform/Windows-Intel-Fortran.cmake b/Modules/Platform/Windows-Intel-Fortran.cmake index e3804fb..c9b70d5 100644 --- a/Modules/Platform/Windows-Intel-Fortran.cmake +++ b/Modules/Platform/Windows-Intel-Fortran.cmake @@ -33,6 +33,8 @@ set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -th set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -threads -libs:dll) set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -threads -libs:static -dbglibs) set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -threads -libs:dll -dbglibs) +set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_Embedded -Z7) +set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_ProgramDatabase -Zi) # Intel Fortran for Windows supports single-threaded RTL but it is # not implemented by the Visual Studio integration. diff --git a/Modules/Platform/Windows-IntelLLVM-Fortran.cmake b/Modules/Platform/Windows-IntelLLVM-Fortran.cmake index 06d0a00..202ba23 100644 --- a/Modules/Platform/Windows-IntelLLVM-Fortran.cmake +++ b/Modules/Platform/Windows-IntelLLVM-Fortran.cmake @@ -33,6 +33,8 @@ set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -th set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -threads -libs:dll) set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -threads -libs:static -dbglibs) set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -threads -libs:dll -dbglibs) +set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_Embedded -Z7) +set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_ProgramDatabase -Zi) # Intel Fortran for Windows supports single-threaded RTL but it is # not implemented by the Visual Studio integration. diff --git a/Modules/Platform/Windows-IntelLLVM.cmake b/Modules/Platform/Windows-IntelLLVM.cmake index f24dcdb..43f5874 100644 --- a/Modules/Platform/Windows-IntelLLVM.cmake +++ b/Modules/Platform/Windows-IntelLLVM.cmake @@ -3,26 +3,61 @@ # This module is shared by multiple languages; use include blocker. -if(__WINDOWS_INTEL) +if(__WINDOWS_INTEL_LLVM) return() endif() -set(__WINDOWS_INTEL 1) +set(__WINDOWS_INTEL_LLVM 1) +# Platform/Windows-MSVC adds some linking options icx/ifx do not understand, +# but that need to be passed to the linker. Wrap all the linking options from +# Platform/Windows-MSVC so that the compiler will hand them off to the linker +# without interpreting them. + +# Save original CMAKE_${t}_LINKER_FLAGS_INIT +foreach(t EXE SHARED MODULE STATIC) + set(_saved_cmake_${t}_linker_flags_init ${CMAKE_${t}_LINKER_FLAGS_INIT}) + set(CMAKE_${t}_LINKER_FLAGS_INIT "") +endforeach() include(Platform/Windows-MSVC) +# Wrap linker flags from Windows-MSVC +set(_IntelLLVM_LINKER_WRAPPER_FLAG "/Qoption,link,") +set(_IntelLLVM_LINKER_WRAPPER_FLAG_SEP ",") +foreach(t EXE SHARED MODULE STATIC) + set(_wrapped_linker_flags "") + foreach(flag ${CMAKE_${t}_LINKER_FLAGS_INIT}) + string(STRIP ${flag} flag) + list(APPEND _wrapped_linker_flags "${_IntelLLVM_LINKER_WRAPPER_FLAG}${flag}") + endforeach() + set(CMAKE_${t}_LINKER_FLAGS_INIT "") + list(APPEND CMAKE_${t}_LINKER_FLAGS_INIT + ${_saved_cmake_${t}_linker_flags_init} ${_wrapped_linker_flags}) +endforeach() + macro(__windows_compiler_intel lang) __windows_compiler_msvc(${lang}) - # For DPCPP other offload cases, some link flags need to go to the compiler - # driver and others need to go to the linker. Pass the compiler linking flags - # in CMAKE_${lang}_LINK_FLAGS and linker flags in LINK_FLAGS + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "${_IntelLLVM_LINKER_WRAPPER_FLAG}") + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP "${_IntelLLVM_LINKER_WRAPPER_FLAG_SEP}") + set(CMAKE_${lang}_CREATE_WIN32_EXE "${CMAKE_${lang}_LINKER_WRAPPER_FLAG}/subsystem:windows") + set(CMAKE_${lang}_CREATE_CONSOLE_EXE "${CMAKE_${lang}_LINKER_WRAPPER_FLAG}/subsystem:console") + set(CMAKE_LINK_DEF_FILE_FLAG "${CMAKE_${lang}_LINKER_WRAPPER_FLAG}/DEF:") + set(CMAKE_LIBRARY_PATH_FLAG "${CMAKE_${lang}_LINKER_WRAPPER_FLAG}/LIBPATH:") + + # Features for LINK_LIBRARY generator expression + if(MSVC_VERSION GREATER "1900") + ## WHOLE_ARCHIVE: Force loading all members of an archive + set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE "LINKER:/WHOLEARCHIVE:<LIBRARY>") + set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED TRUE) + endif() + set(CMAKE_${lang}_LINK_EXECUTABLE - "${_CMAKE_VS_LINK_EXE}<CMAKE_${lang}_COMPILER> ${CMAKE_CL_NOLOGO} <CMAKE_${lang}_LINK_FLAGS> <OBJECTS> ${CMAKE_START_TEMP_FILE} /link /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR>${_PLATFORM_LINK_FLAGS} <LINK_FLAGS> <LINK_LIBRARIES>${CMAKE_END_TEMP_FILE}") + "${_CMAKE_VS_LINK_EXE}<CMAKE_${lang}_COMPILER> ${CMAKE_CL_NOLOGO} <CMAKE_${lang}_LINK_FLAGS> <OBJECTS> ${CMAKE_START_TEMP_FILE} <LINK_FLAGS> <LINK_LIBRARIES> /link /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR>${_PLATFORM_LINK_FLAGS} ${CMAKE_END_TEMP_FILE}") set(CMAKE_${lang}_CREATE_SHARED_LIBRARY - "${_CMAKE_VS_LINK_DLL}<CMAKE_${lang}_COMPILER> ${CMAKE_CL_NOLOGO} <CMAKE_${lang}_LINK_FLAGS> <OBJECTS> ${CMAKE_START_TEMP_FILE} -LD -link /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR>${_PLATFORM_LINK_FLAGS} <LINK_FLAGS> <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}") + "${_CMAKE_VS_LINK_DLL}<CMAKE_${lang}_COMPILER> ${CMAKE_CL_NOLOGO} <CMAKE_${lang}_LINK_FLAGS> <OBJECTS> ${CMAKE_START_TEMP_FILE} -LD <LINK_FLAGS> <LINK_LIBRARIES> -link /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR>${_PLATFORM_LINK_FLAGS} ${CMAKE_END_TEMP_FILE}") if (NOT "${lang}" STREQUAL "Fortran" OR CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 2022.1) # The Fortran driver does not support -fuse-ld=llvm-lib before compiler version 2022.1 set(CMAKE_${lang}_CREATE_STATIC_LIBRARY - "<CMAKE_${lang}_COMPILER> ${CMAKE_CL_NOLOGO} <CMAKE_${lang}_LINK_FLAGS> <OBJECTS> ${CMAKE_START_TEMP_FILE} -fuse-ld=llvm-lib -o <TARGET> -link <LINK_FLAGS> <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}") + "<CMAKE_${lang}_COMPILER> ${CMAKE_CL_NOLOGO} <CMAKE_${lang}_LINK_FLAGS> <OBJECTS> ${CMAKE_START_TEMP_FILE} -fuse-ld=llvm-lib -o <TARGET> <LINK_FLAGS> <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}") endif() set(CMAKE_DEPFILE_FLAGS_${lang} "-QMD -QMT <DEP_TARGET> -QMF <DEP_FILE>") diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index e74ec9e..8e96bf4 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -331,6 +331,13 @@ else() endif() unset(__WINDOWS_MSVC_CMP0091) +cmake_policy(GET CMP0141 __WINDOWS_MSVC_CMP0141) +if(__WINDOWS_MSVC_CMP0141 STREQUAL "NEW") + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT "$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>") +else() + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT "") +endif() +unset(__WINDOWS_MSVC_CMP0141) # Features for LINK_LIBRARY generator expression if(MSVC_VERSION GREATER "1900") @@ -441,6 +448,12 @@ macro(__windows_compiler_msvc lang) endif() unset(_cmp0092) + if(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT) + set(_Zi "") + else() + set(_Zi " /Zi") + endif() + if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "v[0-9]+_clang_.*") # note: MSVC 14 2015 Update 1 sets -fno-ms-compatibility by default, but this does not allow one to compile many projects # that include MS's own headers. CMake itself is affected project too. @@ -451,20 +464,24 @@ macro(__windows_compiler_msvc lang) string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "${_MD} -DNDEBUG") # TODO: Add '-Os' once VS generator maps it properly for Clang else() string(APPEND CMAKE_${lang}_FLAGS_INIT " ${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_${lang}} /D_WINDOWS${_W3}${_FLAGS_${lang}}") - string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT "${_MDd} /Zi /Ob0 /Od ${_RTC1}") + string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT "${_MDd}${_Zi} /Ob0 /Od ${_RTC1}") string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT "${_MD} /O2 /Ob2 /DNDEBUG") - string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "${_MD} /Zi /O2 /Ob1 /DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "${_MD}${_Zi} /O2 /Ob1 /DNDEBUG") string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "${_MD} /O1 /Ob1 /DNDEBUG") endif() unset(_Wall) unset(_W3) unset(_MDd) unset(_MD) + unset(_Zi) set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -MT) set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -MD) set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -MTd) set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -MDd) + set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_Embedded -Z7) + set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_ProgramDatabase -Zi) + set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_EditAndContinue -ZI) endif() set(CMAKE_${lang}_LINKER_SUPPORTS_PDB ON) diff --git a/Modules/Platform/Windows-NVIDIA-CUDA.cmake b/Modules/Platform/Windows-NVIDIA-CUDA.cmake index 6c1699b..326e715 100644 --- a/Modules/Platform/Windows-NVIDIA-CUDA.cmake +++ b/Modules/Platform/Windows-NVIDIA-CUDA.cmake @@ -57,6 +57,12 @@ else() set(_MD "-MD ") endif() +if(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT_DEFAULT) + set(_Zi "") +else() + set(_Zi " -Zi") +endif() + cmake_policy(GET CMP0092 _cmp0092) if(_cmp0092 STREQUAL "NEW") set(_W3 "") @@ -66,11 +72,12 @@ endif() unset(_cmp0092) string(APPEND CMAKE_CUDA_FLAGS_INIT " ${PLATFORM_DEFINES_CUDA} -D_WINDOWS -Xcompiler=\"${_W3}${_FLAGS_CXX}\"") -string(APPEND CMAKE_CUDA_FLAGS_DEBUG_INIT " -Xcompiler=\"${_MDd}-Zi -Ob0 -Od ${_RTC1}\"") +string(APPEND CMAKE_CUDA_FLAGS_DEBUG_INIT " -Xcompiler=\"${_MDd}${_Zi} -Ob0 -Od ${_RTC1}\"") string(APPEND CMAKE_CUDA_FLAGS_RELEASE_INIT " -Xcompiler=\"${_MD}-O2 -Ob2\" -DNDEBUG") -string(APPEND CMAKE_CUDA_FLAGS_RELWITHDEBINFO_INIT " -Xcompiler=\"${_MD}-Zi -O2 -Ob1\" -DNDEBUG") +string(APPEND CMAKE_CUDA_FLAGS_RELWITHDEBINFO_INIT " -Xcompiler=\"${_MD}${_Zi} -O2 -Ob1\" -DNDEBUG") string(APPEND CMAKE_CUDA_FLAGS_MINSIZEREL_INIT " -Xcompiler=\"${_MD}-O1 -Ob1\" -DNDEBUG") unset(_W3) +unset(_Zi) unset(_MDd) unset(_MD) @@ -78,6 +85,9 @@ set(CMAKE_CUDA_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -Xcomp set(CMAKE_CUDA_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -Xcompiler=-MD) set(CMAKE_CUDA_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -Xcompiler=-MTd) set(CMAKE_CUDA_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -Xcompiler=-MDd) +set(CMAKE_CUDA_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_Embedded -Xcompiler=-Z7) +set(CMAKE_CUDA_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_ProgramDatabase -Xcompiler=-Zi) +set(CMAKE_CUDA_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_EditAndContinue -Xcompiler=-ZI) set(CMAKE_CUDA_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}") diff --git a/Modules/Platform/Windows.cmake b/Modules/Platform/Windows.cmake index d8b3957..5263161 100644 --- a/Modules/Platform/Windows.cmake +++ b/Modules/Platform/Windows.cmake @@ -19,8 +19,8 @@ set(CMAKE_LINK_LIBRARY_SUFFIX ".lib") set(CMAKE_DL_LIBS "") set(CMAKE_EXTRA_LINK_EXTENSIONS ".targets") -set(CMAKE_FIND_LIBRARY_PREFIXES "") -set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib") +set(CMAKE_FIND_LIBRARY_PREFIXES "" "lib") +set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".a") # for borland make long command lines are redirected to a file # with the following syntax, see Windows-bcc32.cmake for use diff --git a/Modules/Platform/kFreeBSD.cmake b/Modules/Platform/kFreeBSD.cmake index c1db259..09c240d 100644 --- a/Modules/Platform/kFreeBSD.cmake +++ b/Modules/Platform/kFreeBSD.cmake @@ -1,4 +1,5 @@ -# kFreeBSD looks just like Linux. +# kFreeBSD is a Debian GNU distribution with a kernel from FreeBSD, +# and should be marked as LINUX include(Platform/Linux) set(CMAKE_LIBRARY_ARCHITECTURE_REGEX "[a-z0-9_]+(-[a-z0-9_]+)?-kfreebsd-gnu[a-z0-9_]*") diff --git a/Modules/TestBigEndian.cmake b/Modules/TestBigEndian.cmake index ea8ca73..096c90c 100644 --- a/Modules/TestBigEndian.cmake +++ b/Modules/TestBigEndian.cmake @@ -77,20 +77,16 @@ macro(__TEST_BIG_ENDIAN_LEGACY_IMPL VARIABLE) endif() if(_test_language STREQUAL "CXX") - set(_test_file "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/TestEndianess.cpp") + set(_test_file TestEndianess.cpp) else() - set(_test_file "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/TestEndianess.c") + set(_test_file TestEndianess.c) endif() - configure_file("${CMAKE_ROOT}/Modules/TestEndianess.c.in" - ${_test_file} - @ONLY) - - file(READ ${_test_file} TEST_ENDIANESS_FILE_CONTENT) + file(READ "${CMAKE_ROOT}/Modules/TestEndianess.c.in" TEST_ENDIANESS_FILE_CONTENT) + string(CONFIGURE "${TEST_ENDIANESS_FILE_CONTENT}" TEST_ENDIANESS_FILE_CONTENT @ONLY) try_compile(HAVE_${VARIABLE} - "${CMAKE_BINARY_DIR}" - ${_test_file} + SOURCE_FROM_VAR "${_test_file}" TEST_ENDIANESS_FILE_CONTENT OUTPUT_VARIABLE OUTPUT COPY_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestEndianess.bin" ) @@ -131,12 +127,12 @@ macro(__TEST_BIG_ENDIAN_LEGACY_IMPL VARIABLE) endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining if the system is big endian passed with the following output:\n${OUTPUT}\nTestEndianess.c:\n${TEST_ENDIANESS_FILE_CONTENT}\n\n") + "Determining if the system is big endian passed with the following output:\n${OUTPUT}\n${_test_file}:\n${TEST_ENDIANESS_FILE_CONTENT}\n\n") else() message(CHECK_FAIL "failed") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining if the system is big endian failed with the following output:\n${OUTPUT}\nTestEndianess.c:\n${TEST_ENDIANESS_FILE_CONTENT}\n\n") + "Determining if the system is big endian failed with the following output:\n${OUTPUT}\n${_test_file}:\n${TEST_ENDIANESS_FILE_CONTENT}\n\n") set(${VARIABLE}) endif() endif() diff --git a/Modules/TestCXXAcceptsFlag.cmake b/Modules/TestCXXAcceptsFlag.cmake index ce505f3..2e511ae 100644 --- a/Modules/TestCXXAcceptsFlag.cmake +++ b/Modules/TestCXXAcceptsFlag.cmake @@ -25,8 +25,7 @@ macro(CHECK_CXX_ACCEPTS_FLAG FLAGS VARIABLE) if(NOT DEFINED ${VARIABLE}) message(CHECK_START "Checking to see if CXX compiler accepts flag ${FLAGS}") try_compile(${VARIABLE} - ${CMAKE_BINARY_DIR} - ${CMAKE_ROOT}/Modules/DummyCXXFile.cxx + SOURCES ${CMAKE_ROOT}/Modules/DummyCXXFile.cxx CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${FLAGS} OUTPUT_VARIABLE OUTPUT) if(${VARIABLE}) diff --git a/Modules/TestForANSIForScope.cmake b/Modules/TestForANSIForScope.cmake index 0f2dc01..06db586 100644 --- a/Modules/TestForANSIForScope.cmake +++ b/Modules/TestForANSIForScope.cmake @@ -17,8 +17,8 @@ for-init-statement to the loop body. if(NOT DEFINED CMAKE_ANSI_FOR_SCOPE) message(CHECK_START "Check for ANSI scope") - try_compile(CMAKE_ANSI_FOR_SCOPE ${CMAKE_BINARY_DIR} - ${CMAKE_ROOT}/Modules/TestForAnsiForScope.cxx + try_compile(CMAKE_ANSI_FOR_SCOPE + SOURCES ${CMAKE_ROOT}/Modules/TestForAnsiForScope.cxx OUTPUT_VARIABLE OUTPUT) if (CMAKE_ANSI_FOR_SCOPE) message(CHECK_PASS "found") diff --git a/Modules/TestForSSTREAM.cmake b/Modules/TestForSSTREAM.cmake index 545b7ec..9a09ac7 100644 --- a/Modules/TestForSSTREAM.cmake +++ b/Modules/TestForSSTREAM.cmake @@ -16,8 +16,8 @@ check if the compiler supports the standard ANSI sstream header if(NOT DEFINED CMAKE_HAS_ANSI_STRING_STREAM) message(CHECK_START "Check for sstream") - try_compile(CMAKE_HAS_ANSI_STRING_STREAM ${CMAKE_BINARY_DIR} - ${CMAKE_ROOT}/Modules/TestForSSTREAM.cxx + try_compile(CMAKE_HAS_ANSI_STRING_STREAM + SOURCES ${CMAKE_ROOT}/Modules/TestForSSTREAM.cxx OUTPUT_VARIABLE OUTPUT) if (CMAKE_HAS_ANSI_STRING_STREAM) message(CHECK_PASS "found") diff --git a/Modules/TestForSTDNamespace.cmake b/Modules/TestForSTDNamespace.cmake index d101c83..cd9c782 100644 --- a/Modules/TestForSTDNamespace.cmake +++ b/Modules/TestForSTDNamespace.cmake @@ -16,8 +16,8 @@ check if the compiler supports std:: on stl classes if(NOT DEFINED CMAKE_STD_NAMESPACE) message(CHECK_START "Check for STD namespace") - try_compile(CMAKE_STD_NAMESPACE ${CMAKE_BINARY_DIR} - ${CMAKE_ROOT}/Modules/TestForSTDNamespace.cxx + try_compile(CMAKE_STD_NAMESPACE + SOURCES ${CMAKE_ROOT}/Modules/TestForSTDNamespace.cxx OUTPUT_VARIABLE OUTPUT) if (CMAKE_STD_NAMESPACE) message(CHECK_PASS "found") diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index 35b1704..e0e01f5 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -377,6 +377,8 @@ set(SWIG_EXTRA_LIBRARIES "") set(SWIG_PYTHON_EXTRA_FILE_EXTENSIONS ".py") set(SWIG_JAVA_EXTRA_FILE_EXTENSIONS ".java" "JNI.java") set(SWIG_CSHARP_EXTRA_FILE_EXTENSIONS ".cs" "PINVOKE.cs") +set(SWIG_PERL_EXTRA_FILE_EXTENSIONS ".pm") +set(SWIG_PERL5_EXTRA_FILE_EXTENSIONS ".pm") set(SWIG_MANAGE_SUPPORT_FILES_SCRIPT "${CMAKE_CURRENT_LIST_DIR}/UseSWIG/ManageSupportFiles.cmake") @@ -413,8 +415,8 @@ macro(SWIG_MODULE_INITIALIZE name language) endif() if(SWIG_MODULE_${name}_LANGUAGE STREQUAL "UNKNOWN") message(FATAL_ERROR "SWIG Error: Language \"${language}\" not found") - elseif(SWIG_MODULE_${name}_LANGUAGE STREQUAL "PERL" AND - NOT "-shadow" IN_LIST SWIG_MODULE_${name}_EXTRA_FLAGS) + elseif((SWIG_MODULE_${name}_LANGUAGE STREQUAL "PERL" OR SWIG_MODULE_${name}_LANGUAGE STREQUAL "PERL5") + AND NOT "-shadow" IN_LIST SWIG_MODULE_${name}_EXTRA_FLAGS) list(APPEND SWIG_MODULE_${name}_EXTRA_FLAGS "-shadow") endif() endmacro() @@ -970,7 +972,7 @@ function(SWIG_ADD_LIBRARY name) if (APPLE) set_target_properties (${target_name} PROPERTIES SUFFIX ".bundle") endif () - elseif (swig_lowercase_language STREQUAL "perl") + elseif (swig_lowercase_language STREQUAL "perl" OR swig_lowercase_language STREQUAL "perl5") # assume empty prefix because we expect the module to be dynamically loaded set_target_properties (${target_name} PROPERTIES PREFIX "") if (APPLE) @@ -989,6 +991,9 @@ function(SWIG_ADD_LIBRARY name) endif() set_target_properties (${target_name} PROPERTIES PREFIX "") endif() + if (APPLE) + set_target_properties (${target_name} PROPERTIES SUFFIX ".dylib") + endif () else() # assume empty prefix because we expect the module to be dynamically loaded set_target_properties (${target_name} PROPERTIES PREFIX "") |