diff options
Diffstat (limited to 'Modules')
146 files changed, 3129 insertions, 1366 deletions
diff --git a/Modules/AndroidTestUtilities.cmake b/Modules/AndroidTestUtilities.cmake index e333cdb..95e2ef7 100644 --- a/Modules/AndroidTestUtilities.cmake +++ b/Modules/AndroidTestUtilities.cmake @@ -76,8 +76,6 @@ Module Functions include(${CMAKE_CURRENT_LIST_DIR}/ExternalData.cmake) -set(_AndroidTestUtilities_SELF_DIR "${CMAKE_CURRENT_LIST_DIR}") - # The parameters to this function should be set to the list of directories, # files, and libraries that need to be installed prior to testing. function(android_add_test_data test_name) @@ -159,6 +157,6 @@ function(android_add_test_data test_name) "-Darg_files=${processed_FILES}" "-Darg_libs=${AST_LIBS}" "-Darg_src_dir=${CMAKE_CURRENT_SOURCE_DIR}" - -P ${_AndroidTestUtilities_SELF_DIR}/AndroidTestUtilities/PushToAndroidDevice.cmake) + -P ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/AndroidTestUtilities/PushToAndroidDevice.cmake) endif() endfunction() diff --git a/Modules/CMakeASM_MASMInformation.cmake b/Modules/CMakeASM_MASMInformation.cmake index a38c114..9f7e934 100644 --- a/Modules/CMakeASM_MASMInformation.cmake +++ b/Modules/CMakeASM_MASMInformation.cmake @@ -10,5 +10,11 @@ set(CMAKE_ASM${ASM_DIALECT}_SOURCE_FILE_EXTENSIONS asm) set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT "<CMAKE_ASM${ASM_DIALECT}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> /c /Fo <OBJECT> <SOURCE>") +# The ASM_MASM compiler id for this compiler is "MSVC", so fill out the runtime library table. +set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded "") +set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL "") +set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug "") +set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL "") + include(CMakeASMInformation) set(ASM_DIALECT) diff --git a/Modules/CMakeAddFortranSubdirectory.cmake b/Modules/CMakeAddFortranSubdirectory.cmake index 2613569..69a8417 100644 --- a/Modules/CMakeAddFortranSubdirectory.cmake +++ b/Modules/CMakeAddFortranSubdirectory.cmake @@ -43,7 +43,6 @@ future version that supports installation of the external project binaries during ``make install``. #]=======================================================================] -set(_MS_MINGW_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}) include(CheckLanguage) include(ExternalProject) @@ -87,11 +86,11 @@ function(_setup_mingw_config_and_build source_dir build_dir) file(TO_NATIVE_PATH "${MINGW_PATH}" MINGW_PATH) string(REPLACE "\\" "\\\\" MINGW_PATH "${MINGW_PATH}") configure_file( - ${_MS_MINGW_SOURCE_DIR}/CMakeAddFortranSubdirectory/config_mingw.cmake.in + ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/CMakeAddFortranSubdirectory/config_mingw.cmake.in ${build_dir}/config_mingw.cmake @ONLY) configure_file( - ${_MS_MINGW_SOURCE_DIR}/CMakeAddFortranSubdirectory/build_mingw.cmake.in + ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/CMakeAddFortranSubdirectory/build_mingw.cmake.in ${build_dir}/build_mingw.cmake @ONLY) endfunction() @@ -150,17 +149,9 @@ function(cmake_add_fortran_subdirectory subdir) -P ${build_dir}/config_mingw.cmake BUILD_COMMAND ${CMAKE_COMMAND} -P ${build_dir}/build_mingw.cmake + BUILD_ALWAYS 1 INSTALL_COMMAND "" ) - # make the external project always run make with each build - externalproject_add_step(${project_name}_build forcebuild - COMMAND ${CMAKE_COMMAND} - -E remove - ${CMAKE_CURRENT_BUILD_DIR}/${project_name}-prefix/src/${project_name}-stamp/${project_name}-build - DEPENDEES configure - DEPENDERS build - ALWAYS 1 - ) # create imported targets for all libraries foreach(lib ${libraries}) add_library(${lib} SHARED IMPORTED GLOBAL) diff --git a/Modules/CMakeCInformation.cmake b/Modules/CMakeCInformation.cmake index df43559..1e08bb7 100644 --- a/Modules/CMakeCInformation.cmake +++ b/Modules/CMakeCInformation.cmake @@ -110,6 +110,11 @@ if(CMAKE_C_STANDARD_LIBRARIES_INIT) mark_as_advanced(CMAKE_C_STANDARD_LIBRARIES) endif() +if(NOT CMAKE_C_COMPILER_LAUNCHER AND DEFINED ENV{CMAKE_C_COMPILER_LAUNCHER}) + set(CMAKE_C_COMPILER_LAUNCHER "$ENV{CMAKE_C_COMPILER_LAUNCHER}" + CACHE STRING "Compiler launcher for C.") +endif() + include(CMakeCommonLanguageInclude) # now define the following rule variables diff --git a/Modules/CMakeCSharpInformation.cmake b/Modules/CMakeCSharpInformation.cmake index 48e1a1e..41cd449 100644 --- a/Modules/CMakeCSharpInformation.cmake +++ b/Modules/CMakeCSharpInformation.cmake @@ -10,7 +10,7 @@ get_filename_component(CMAKE_BASE_NAME "${CMAKE_CSharp_COMPILER}" NAME_WE) set(CMAKE_BUILD_TYPE_INIT Debug) -set(CMAKE_CSharp_FLAGS_INIT "/define:TRACE /langversion:3") +set(CMAKE_CSharp_FLAGS_INIT "/define:TRACE") set(CMAKE_CSharp_FLAGS_DEBUG_INIT "/debug:full /optimize- /warn:3 /errorreport:prompt /define:DEBUG") set(CMAKE_CSharp_FLAGS_RELEASE_INIT "/debug:none /optimize /warn:1 /errorreport:queue") set(CMAKE_CSharp_FLAGS_RELWITHDEBINFO_INIT "/debug:full /optimize-") diff --git a/Modules/CMakeCUDACompiler.cmake.in b/Modules/CMakeCUDACompiler.cmake.in index 711129a..4a615a3 100644 --- a/Modules/CMakeCUDACompiler.cmake.in +++ b/Modules/CMakeCUDACompiler.cmake.in @@ -4,7 +4,16 @@ set(CMAKE_CUDA_HOST_LINK_LAUNCHER "@CMAKE_CUDA_HOST_LINK_LAUNCHER@") set(CMAKE_CUDA_COMPILER_ID "@CMAKE_CUDA_COMPILER_ID@") set(CMAKE_CUDA_COMPILER_VERSION "@CMAKE_CUDA_COMPILER_VERSION@") set(CMAKE_CUDA_STANDARD_COMPUTED_DEFAULT "@CMAKE_CUDA_STANDARD_COMPUTED_DEFAULT@") +set(CMAKE_CUDA_COMPILE_FEATURES "@CMAKE_CUDA_COMPILE_FEATURES@") +set(CMAKE_CUDA03_COMPILE_FEATURES "@CMAKE_CUDA03_COMPILE_FEATURES@") +set(CMAKE_CUDA11_COMPILE_FEATURES "@CMAKE_CUDA11_COMPILE_FEATURES@") +set(CMAKE_CUDA14_COMPILE_FEATURES "@CMAKE_CUDA14_COMPILE_FEATURES@") +set(CMAKE_CUDA17_COMPILE_FEATURES "@CMAKE_CUDA17_COMPILE_FEATURES@") +set(CMAKE_CUDA20_COMPILE_FEATURES "@CMAKE_CUDA20_COMPILE_FEATURES@") + +set(CMAKE_CUDA_PLATFORM_ID "@CMAKE_CUDA_PLATFORM_ID@") set(CMAKE_CUDA_SIMULATE_ID "@CMAKE_CUDA_SIMULATE_ID@") +set(CMAKE_CUDA_COMPILER_FRONTEND_VARIANT "@CMAKE_CUDA_COMPILER_FRONTEND_VARIANT@") set(CMAKE_CUDA_SIMULATE_VERSION "@CMAKE_CUDA_SIMULATE_VERSION@") @SET_MSVC_CUDA_ARCHITECTURE_ID@ @@ -17,6 +26,22 @@ set(CMAKE_CUDA_SOURCE_FILE_EXTENSIONS cu) set(CMAKE_CUDA_LINKER_PREFERENCE 15) set(CMAKE_CUDA_LINKER_PREFERENCE_PROPAGATES 1) +set(CMAKE_CUDA_SIZEOF_DATA_PTR "@CMAKE_CUDA_SIZEOF_DATA_PTR@") +set(CMAKE_CUDA_COMPILER_ABI "@CMAKE_CUDA_COMPILER_ABI@") +set(CMAKE_CUDA_LIBRARY_ARCHITECTURE "@CMAKE_CUDA_LIBRARY_ARCHITECTURE@") + +if(CMAKE_CUDA_SIZEOF_DATA_PTR) + set(CMAKE_SIZEOF_VOID_P "${CMAKE_CUDA_SIZEOF_DATA_PTR}") +endif() + +if(CMAKE_CUDA_COMPILER_ABI) + set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_CUDA_COMPILER_ABI}") +endif() + +if(CMAKE_CUDA_LIBRARY_ARCHITECTURE) + set(CMAKE_LIBRARY_ARCHITECTURE "@CMAKE_CUDA_LIBRARY_ARCHITECTURE@") +endif() + set(CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES "@CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES@") set(CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES "@CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES@") diff --git a/Modules/CMakeCUDACompilerId.cu.in b/Modules/CMakeCUDACompilerId.cu.in index 6eda924..2055de2 100644 --- a/Modules/CMakeCUDACompilerId.cu.in +++ b/Modules/CMakeCUDACompilerId.cu.in @@ -26,7 +26,7 @@ const char* info_language_dialect_default = "INFO" ":" "dialect_default[" #elif __cplusplus >= 201103L "11" #else - "98" + "03" #endif "]"; diff --git a/Modules/CMakeCUDAInformation.cmake b/Modules/CMakeCUDAInformation.cmake index b0d80d1..974f5fa 100644 --- a/Modules/CMakeCUDAInformation.cmake +++ b/Modules/CMakeCUDAInformation.cmake @@ -82,6 +82,11 @@ if(CMAKE_CUDA_STANDARD_LIBRARIES_INIT) mark_as_advanced(CMAKE_CUDA_STANDARD_LIBRARIES) endif() +if(NOT CMAKE_CUDA_COMPILER_LAUNCHER AND DEFINED ENV{CMAKE_CUDA_COMPILER_LAUNCHER}) + set(CMAKE_CUDA_COMPILER_LAUNCHER "$ENV{CMAKE_CUDA_COMPILER_LAUNCHER}" + CACHE STRING "Compiler launcher for CUDA.") +endif() + include(CMakeCommonLanguageInclude) # now define the following rules: @@ -93,9 +98,7 @@ include(CMakeCommonLanguageInclude) # CMAKE_CUDA_LINK_EXECUTABLE if(CMAKE_CUDA_HOST_COMPILER) - set(CMAKE_CUDA_HOST_FLAGS "-ccbin=<CMAKE_CUDA_HOST_COMPILER>") -else() - set(CMAKE_CUDA_HOST_FLAGS "") + string(APPEND _CMAKE_CUDA_EXTRA_FLAGS " -ccbin=<CMAKE_CUDA_HOST_COMPILER>") endif() set(__IMPLICT_LINKS ) @@ -135,26 +138,26 @@ endif() #Specify how to compile when ptx has been requested if(NOT CMAKE_CUDA_COMPILE_PTX_COMPILATION) set(CMAKE_CUDA_COMPILE_PTX_COMPILATION - "<CMAKE_CUDA_COMPILER> ${CMAKE_CUDA_HOST_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -ptx <SOURCE> -o <OBJECT>") + "<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -ptx <SOURCE> -o <OBJECT>") endif() #Specify how to compile when separable compilation has been requested if(NOT CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION) set(CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION - "<CMAKE_CUDA_COMPILER> ${CMAKE_CUDA_HOST_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -dc <SOURCE> -o <OBJECT>") + "<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -dc <SOURCE> -o <OBJECT>") endif() #Specify how to compile when whole compilation has been requested if(NOT CMAKE_CUDA_COMPILE_WHOLE_COMPILATION) set(CMAKE_CUDA_COMPILE_WHOLE_COMPILATION - "<CMAKE_CUDA_COMPILER> ${CMAKE_CUDA_HOST_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -c <SOURCE> -o <OBJECT>") + "<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -c <SOURCE> -o <OBJECT>") endif() -if(CMAKE_GENERATOR STREQUAL "Ninja") +if(CMAKE_GENERATOR STREQUAL "Ninja" AND NOT CMAKE_DEPFILE_FLAGS_CUDA ) set(CMAKE_CUDA_COMPILE_DEPENDENCY_DETECTION - "<CMAKE_CUDA_COMPILER> ${CMAKE_CUDA_HOST_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -M <SOURCE> -MT <OBJECT> -o $DEP_FILE") + "<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -M <SOURCE> -MT <OBJECT> -o $DEP_FILE") #The Ninja generator uses the make file dependency files to determine what - #files need to be recompiled. Unfortunately, nvcc doesn't support building + #files need to be recompiled. Unfortunately, nvcc < 10.2 doesn't support building #a source file and generating the dependencies of said file in a single #invocation. Instead we have to state that you need to chain two commands. # @@ -171,13 +174,6 @@ if(NOT CMAKE_CUDA_LINK_EXECUTABLE) "<CMAKE_CUDA_HOST_LINK_LAUNCHER> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>${__IMPLICT_LINKS}") endif() -if( CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA" AND - CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "8.0.0") - set(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS "-Wno-deprecated-gpu-targets") -else() - set(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS "") -endif() - # Add implicit host link directories that contain device libraries # to the device link line. set(__IMPLICT_DLINK_DIRS ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) @@ -192,14 +188,15 @@ foreach(dir ${__IMPLICT_DLINK_DIRS}) endforeach() unset(__IMPLICT_DLINK_DIRS) + #These are used when linking relocatable (dc) cuda code if(NOT CMAKE_CUDA_DEVICE_LINK_LIBRARY) set(CMAKE_CUDA_DEVICE_LINK_LIBRARY - "<CMAKE_CUDA_COMPILER> ${CMAKE_CUDA_HOST_FLAGS} <LANGUAGE_COMPILE_FLAGS> ${CMAKE_CUDA_COMPILE_OPTIONS_PIC} ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES>${__IMPLICT_DLINK_FLAGS}") + "<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <LANGUAGE_COMPILE_FLAGS> ${CMAKE_CUDA_COMPILE_OPTIONS_PIC} ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES>${__IMPLICT_DLINK_FLAGS}") endif() if(NOT CMAKE_CUDA_DEVICE_LINK_EXECUTABLE) set(CMAKE_CUDA_DEVICE_LINK_EXECUTABLE - "<CMAKE_CUDA_COMPILER> ${CMAKE_CUDA_HOST_FLAGS} <FLAGS> ${CMAKE_CUDA_COMPILE_OPTIONS_PIC} ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES>${__IMPLICT_DLINK_FLAGS}") + "<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <FLAGS> ${CMAKE_CUDA_COMPILE_OPTIONS_PIC} ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES>${__IMPLICT_DLINK_FLAGS}") endif() unset(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS) diff --git a/Modules/CMakeCXXInformation.cmake b/Modules/CMakeCXXInformation.cmake index a896b99..da7440a 100644 --- a/Modules/CMakeCXXInformation.cmake +++ b/Modules/CMakeCXXInformation.cmake @@ -207,6 +207,11 @@ if(CMAKE_CXX_STANDARD_LIBRARIES_INIT) mark_as_advanced(CMAKE_CXX_STANDARD_LIBRARIES) endif() +if(NOT CMAKE_CXX_COMPILER_LAUNCHER AND DEFINED ENV{CMAKE_CXX_COMPILER_LAUNCHER}) + set(CMAKE_CXX_COMPILER_LAUNCHER "$ENV{CMAKE_CXX_COMPILER_LAUNCHER}" + CACHE STRING "Compiler launcher for CXX.") +endif() + include(CMakeCommonLanguageInclude) # now define the following rules: diff --git a/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake b/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake index e1ce617..2dc75d6 100644 --- a/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake +++ b/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake @@ -9,6 +9,7 @@ macro (CHECK_COMPILER_FLAG_COMMON_PATTERNS _VAR) set(${_VAR} FAIL_REGEX "[Uu]nrecogni[sz]ed .*option" # GNU, NAG + FAIL_REGEX "switch .* is no longer supported" # GNU FAIL_REGEX "unknown .*option" # Clang FAIL_REGEX "optimization flag .* not supported" # Clang FAIL_REGEX "unknown argument ignored" # Clang (cl) diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake index 490d659..7d7fb9a 100644 --- a/Modules/CMakeDetermineCUDACompiler.cmake +++ b/Modules/CMakeDetermineCUDACompiler.cmake @@ -186,33 +186,32 @@ elseif(CMAKE_CUDA_COMPILER_ID STREQUAL NVIDIA) "Failed to parsed CUDA nvcc implicit link information:\n${_nvcc_log}\n\n") message(FATAL_ERROR "Failed to extract nvcc implicit link line.") endif() +endif() - set(CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES ) - if(_nvcc_output_orig MATCHES "#\\\$ +INCLUDES= *([^\n]*)\n") - set(_nvcc_includes "${CMAKE_MATCH_1}") - string(APPEND _nvcc_log " found 'INCLUDES=' string: [${_nvcc_includes}]\n") - else() - set(_nvcc_includes "") - string(REPLACE "\n" "\n " _nvcc_output_log "\n${_nvcc_output_orig}") - string(APPEND _nvcc_log " no 'INCLUDES=' string found in nvcc output:${_nvcc_output_log}\n") - endif() - if(_nvcc_includes) - # across all operating system each include directory is prefixed with -I - separate_arguments(_nvcc_output UNIX_COMMAND "${_nvcc_includes}") - foreach(line IN LISTS _nvcc_output) - string(REGEX REPLACE "^-I" "" line "${line}") - get_filename_component(line "${line}" ABSOLUTE) - list(APPEND CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES "${line}") - endforeach() - - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Parsed CUDA nvcc include information from above output:\n${_nvcc_log}\n${log}\n\n") - else() - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Failed to detect CUDA nvcc include information:\n${_nvcc_log}\n\n") - endif() - - +set(CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES ) +string(REPLACE "\r" "" _nvcc_output_orig "${CMAKE_CUDA_COMPILER_PRODUCED_OUTPUT}") +if(_nvcc_output_orig MATCHES "#\\\$ +INCLUDES= *([^\n]*)\n") + set(_nvcc_includes "${CMAKE_MATCH_1}") + string(APPEND _nvcc_log " found 'INCLUDES=' string: [${_nvcc_includes}]\n") +else() + set(_nvcc_includes "") + string(REPLACE "\n" "\n " _nvcc_output_log "\n${_nvcc_output_orig}") + string(APPEND _nvcc_log " no 'INCLUDES=' string found in nvcc output:${_nvcc_output_log}\n") +endif() +if(_nvcc_includes) + # across all operating system each include directory is prefixed with -I + separate_arguments(_nvcc_output NATIVE_COMMAND "${_nvcc_includes}") + foreach(line IN LISTS _nvcc_output) + string(REGEX REPLACE "^-I" "" line "${line}") + get_filename_component(line "${line}" ABSOLUTE) + list(APPEND CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES "${line}") + endforeach() + + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Parsed CUDA nvcc include information from above output:\n${_nvcc_log}\n${log}\n\n") +else() + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Failed to detect CUDA nvcc include information:\n${_nvcc_log}\n\n") endif() # configure all variables set in this file diff --git a/Modules/CMakeDetermineCompileFeatures.cmake b/Modules/CMakeDetermineCompileFeatures.cmake index 01a81a1..b50e5f1 100644 --- a/Modules/CMakeDetermineCompileFeatures.cmake +++ b/Modules/CMakeDetermineCompileFeatures.cmake @@ -5,7 +5,7 @@ function(cmake_determine_compile_features lang) if(lang STREQUAL C AND COMMAND cmake_record_c_compile_features) - message(STATUS "Detecting ${lang} compile features") + message(CHECK_START "Detecting ${lang} compile features") set(CMAKE_C90_COMPILE_FEATURES) set(CMAKE_C99_COMPILE_FEATURES) @@ -16,7 +16,7 @@ function(cmake_determine_compile_features lang) cmake_record_c_compile_features() if(NOT _result EQUAL 0) - message(STATUS "Detecting ${lang} compile features - failed") + message(CHECK_FAIL "failed") return() endif() @@ -40,10 +40,10 @@ function(cmake_determine_compile_features lang) set(CMAKE_C99_COMPILE_FEATURES ${CMAKE_C99_COMPILE_FEATURES} PARENT_SCOPE) set(CMAKE_C11_COMPILE_FEATURES ${CMAKE_C11_COMPILE_FEATURES} PARENT_SCOPE) - message(STATUS "Detecting ${lang} compile features - done") + message(CHECK_PASS "done") elseif(lang STREQUAL CXX AND COMMAND cmake_record_cxx_compile_features) - message(STATUS "Detecting ${lang} compile features") + message(CHECK_START "Detecting ${lang} compile features") set(CMAKE_CXX98_COMPILE_FEATURES) set(CMAKE_CXX11_COMPILE_FEATURES) @@ -56,7 +56,7 @@ function(cmake_determine_compile_features lang) cmake_record_cxx_compile_features() if(NOT _result EQUAL 0) - message(STATUS "Detecting ${lang} compile features - failed") + message(CHECK_FAIL "failed") return() endif() @@ -90,7 +90,58 @@ 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) - message(STATUS "Detecting ${lang} compile features - done") + message(CHECK_PASS "done") + + elseif(lang STREQUAL CUDA AND COMMAND cmake_record_cuda_compile_features) + message(CHECK_START "Detecting ${lang} compile features") + + set(CMAKE_CUDA03_COMPILE_FEATURES) + set(CMAKE_CUDA11_COMPILE_FEATURES) + set(CMAKE_CUDA14_COMPILE_FEATURES) + set(CMAKE_CUDA17_COMPILE_FEATURES) + set(CMAKE_CUDA20_COMPILE_FEATURES) + + include("${CMAKE_ROOT}/Modules/Internal/FeatureTesting.cmake") + + cmake_record_cuda_compile_features() + + if(NOT _result EQUAL 0) + message(CHECK_FAIL "failed") + return() + endif() + + if (CMAKE_CUDA17_COMPILE_FEATURES AND CMAKE_CUDA20_COMPILE_FEATURES) + list(REMOVE_ITEM CMAKE_CUDA20_COMPILE_FEATURES ${CMAKE_CUDA17_COMPILE_FEATURES}) + endif() + if (CMAKE_CUDA14_COMPILE_FEATURES AND CMAKE_CUDA17_COMPILE_FEATURES) + list(REMOVE_ITEM CMAKE_CUDA17_COMPILE_FEATURES ${CMAKE_CUDA14_COMPILE_FEATURES}) + endif() + if (CMAKE_CUDA11_COMPILE_FEATURES AND CMAKE_CUDA14_COMPILE_FEATURES) + list(REMOVE_ITEM CMAKE_CUDA14_COMPILE_FEATURES ${CMAKE_CUDA11_COMPILE_FEATURES}) + endif() + if (CMAKE_CUDA03_COMPILE_FEATURES AND CMAKE_CUDA11_COMPILE_FEATURES) + list(REMOVE_ITEM CMAKE_CUDA11_COMPILE_FEATURES ${CMAKE_CUDA03_COMPILE_FEATURES}) + endif() + + if(NOT CMAKE_CUDA_COMPILE_FEATURES) + set(CMAKE_CUDA_COMPILE_FEATURES + ${CMAKE_CUDA03_COMPILE_FEATURES} + ${CMAKE_CUDA11_COMPILE_FEATURES} + ${CMAKE_CUDA14_COMPILE_FEATURES} + ${CMAKE_CUDA17_COMPILE_FEATURES} + ${CMAKE_CUDA20_COMPILE_FEATURES} + ) + endif() + + set(CMAKE_CUDA_COMPILE_FEATURES ${CMAKE_CUDA_COMPILE_FEATURES} PARENT_SCOPE) + set(CMAKE_CUDA03_COMPILE_FEATURES ${CMAKE_CUDA03_COMPILE_FEATURES} PARENT_SCOPE) + set(CMAKE_CUDA11_COMPILE_FEATURES ${CMAKE_CUDA11_COMPILE_FEATURES} PARENT_SCOPE) + set(CMAKE_CUDA14_COMPILE_FEATURES ${CMAKE_CUDA14_COMPILE_FEATURES} PARENT_SCOPE) + set(CMAKE_CUDA17_COMPILE_FEATURES ${CMAKE_CUDA17_COMPILE_FEATURES} PARENT_SCOPE) + set(CMAKE_CUDA20_COMPILE_FEATURES ${CMAKE_CUDA20_COMPILE_FEATURES} PARENT_SCOPE) + + message(CHECK_PASS "done") + endif() endfunction() diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index 06f3ba2..99447e4 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -12,7 +12,7 @@ include(CMakeTestCompilerCommon) function(CMAKE_DETERMINE_COMPILER_ABI lang src) if(NOT DEFINED CMAKE_${lang}_ABI_COMPILED) - message(STATUS "Detecting ${lang} compiler ABI info") + message(CHECK_START "Detecting ${lang} compiler ABI info") # Compile the ABI identification source. set(BIN "${CMAKE_PLATFORM_INFO_DIR}/CMakeDetermineCompilerABI_${lang}.bin") @@ -66,7 +66,7 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) # Load the resulting information strings. if(CMAKE_${lang}_ABI_COMPILED AND NOT _copy_error) - message(STATUS "Detecting ${lang} compiler ABI info - done") + message(CHECK_PASS "done") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Detecting ${lang} compiler ABI info compiled with the following output:\n${OUTPUT}\n\n") file(STRINGS "${BIN}" ABI_STRINGS LIMIT_COUNT 2 REGEX "INFO:[A-Za-z0-9_]+\\[[^]]*\\]") @@ -124,8 +124,7 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) # a try-compile if("${lang}" MATCHES "Fortran" AND "${CMAKE_GENERATOR}" MATCHES "Visual Studio") - set(_desc "Determine Intel Fortran Compiler Implicit Link Path") - message(STATUS "${_desc}") + 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 @@ -138,8 +137,7 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) "${CMAKE_BINARY_DIR}/CMakeFiles/IntelVSImplicitPath/output.txt" "${_output}") include(${CMAKE_BINARY_DIR}/CMakeFiles/IntelVSImplicitPath/output.cmake OPTIONAL) - set(_desc "Determine Intel Fortran Compiler Implicit Link Path -- done") - message(STATUS "${_desc}") + message(CHECK_PASS "done") endif() # Implicit link libraries cannot be used explicitly for multiple @@ -163,10 +161,22 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) break() endif() endforeach() + elseif(CMAKE_CXX_COMPILER_ID STREQUAL QCC) + foreach(dir ${implicit_dirs}) + if (dir MATCHES "/lib$") + get_filename_component(assumedArchDir "${dir}" DIRECTORY) + get_filename_component(archParentDir "${assumedArchDir}" DIRECTORY) + if (archParentDir STREQUAL CMAKE_SYSROOT) + get_filename_component(archDirName "${assumedArchDir}" NAME) + set(CMAKE_${lang}_LIBRARY_ARCHITECTURE "${archDirName}" PARENT_SCOPE) + break() + endif() + endif() + endforeach() endif() else() - message(STATUS "Detecting ${lang} compiler ABI info - failed") + message(CHECK_FAIL "failed") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Detecting ${lang} compiler ABI info failed to compile with the following output:\n${OUTPUT}\n${_copy_error}\n\n") endif() diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 7b571c3..d125791 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -182,6 +182,10 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) message(STATUS "The ${lang} compiler identification is unknown") endif() + if(lang STREQUAL "Fortran" AND CMAKE_${lang}_COMPILER_ID STREQUAL "XL") + set(CMAKE_${lang}_XL_CPP "${CMAKE_${lang}_COMPILER_ID_CPP}" PARENT_SCOPE) + endif() + set(CMAKE_${lang}_COMPILER_ID "${CMAKE_${lang}_COMPILER_ID}" PARENT_SCOPE) set(CMAKE_${lang}_PLATFORM_ID "${CMAKE_${lang}_PLATFORM_ID}" PARENT_SCOPE) set(CMAKE_${lang}_COMPILER_ARCHITECTURE_ID "${CMAKE_${lang}_COMPILER_ARCHITECTURE_ID}" PARENT_SCOPE) @@ -242,7 +246,7 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} set(id_platform ${CMAKE_VS_PLATFORM_NAME}) set(id_lang "${lang}") set(id_PostBuildEvent_Command "") - if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "^[Ll][Ll][Vv][Mm](_v[0-9]+(_xp)?)?$") + if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "^([Ll][Ll][Vv][Mm](_v[0-9]+(_xp)?)?|[Cc][Ll][Aa][Nn][Gg][Cc][Ll])$") set(id_cl_var "ClangClExecutable") elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "v[0-9]+_clang_.*") set(id_cl clang.exe) @@ -318,6 +322,15 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} if(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION) set(id_WindowsTargetPlatformVersion "<WindowsTargetPlatformVersion>${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}</WindowsTargetPlatformVersion>") endif() + if(CMAKE_VS_PLATFORM_TOOLSET_VCTARGETS_CUSTOM_DIR) + set(id_ToolsetVCTargetsDir "<VCTargetsPath>${CMAKE_VS_PLATFORM_TOOLSET_VCTARGETS_CUSTOM_DIR}</VCTargetsPath>") + endif() + set(id_CustomGlobals "") + foreach(pair IN LISTS CMAKE_VS_GLOBALS) + if("${pair}" MATCHES "([^=]+)=(.*)$") + string(APPEND id_CustomGlobals "<${CMAKE_MATCH_1}>${CMAKE_MATCH_2}</${CMAKE_MATCH_1}>\n ") + endif() + endforeach() if(id_platform STREQUAL ARM64) set(id_WindowsSDKDesktopARMSupport "<WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>") elseif(id_platform STREQUAL ARM) @@ -353,6 +366,7 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} endif() set(cuda_tools "CUDA ${CMAKE_VS_PLATFORM_TOOLSET_CUDA}") set(id_compile "CudaCompile") + set(id_ItemDefinitionGroup_entry "<CudaCompile><AdditionalOptions>%(AdditionalOptions)-v</AdditionalOptions></CudaCompile>") set(id_PostBuildEvent_Command [[echo CMAKE_CUDA_COMPILER=$(CudaToolkitBinDir)\nvcc.exe]]) if(CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR) set(id_CudaToolkitCustomDir "<CudaToolkitCustomDir>${CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR}nvcc</CudaToolkitCustomDir>") @@ -363,7 +377,7 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} string(CONCAT id_Import_targets [[<Import Project="$(VCTargetsPath)\BuildCustomizations\]] "${cuda_tools}" [[.targets" />]]) endif() if(CMAKE_VS_PLATFORM_NAME STREQUAL x64) - set(id_ItemDefinitionGroup_entry "<CudaCompile><TargetMachinePlatform>64</TargetMachinePlatform></CudaCompile>") + set(id_ItemDefinitionGroup_entry "<CudaCompile><TargetMachinePlatform>64</TargetMachinePlatform><AdditionalOptions>%(AdditionalOptions)-v</AdditionalOptions></CudaCompile>") endif() set(id_Link_AdditionalDependencies "<AdditionalDependencies>cudart.lib</AdditionalDependencies>") endif() @@ -534,6 +548,12 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} ERROR_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT RESULT_VARIABLE CMAKE_${lang}_COMPILER_ID_RESULT ) + if("${CMAKE_${lang}_COMPILER_ID_OUTPUT}" MATCHES "exec: [^\n]*\\((/[^,\n]*/cpp),CMakeFortranCompilerId.F") + set(_cpp "${CMAKE_MATCH_1}") + if(EXISTS "${_cpp}") + set(CMAKE_${lang}_COMPILER_ID_CPP "${_cpp}" PARENT_SCOPE) + endif() + endif() endif() # Check the result of compilation. diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake index 5ddd64f..e850541 100644 --- a/Modules/CMakeDetermineFortranCompiler.cmake +++ b/Modules/CMakeDetermineFortranCompiler.cmake @@ -271,6 +271,11 @@ include(CMakeFindBinUtils) include(Compiler/${CMAKE_Fortran_COMPILER_ID}-FindBinUtils OPTIONAL) unset(_CMAKE_PROCESSING_LANGUAGE) +if(CMAKE_Fortran_XL_CPP) + set(_SET_CMAKE_Fortran_XL_CPP + "set(CMAKE_Fortran_XL_CPP \"${CMAKE_Fortran_XL_CPP}\")") +endif() + if(CMAKE_Fortran_COMPILER_ARCHITECTURE_ID) set(_SET_CMAKE_Fortran_COMPILER_ARCHITECTURE_ID "set(CMAKE_Fortran_COMPILER_ARCHITECTURE_ID ${CMAKE_Fortran_COMPILER_ARCHITECTURE_ID})") diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake index dc208c6..f3ec4da 100644 --- a/Modules/CMakeDetermineSystem.cmake +++ b/Modules/CMakeDetermineSystem.cmake @@ -43,7 +43,7 @@ if(CMAKE_HOST_UNIX) else() exec_program(${CMAKE_UNAME} ARGS -r OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION) endif() - if(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|CYGWIN.*|Darwin|^GNU$") + if(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|CYGWIN.*|Darwin|^GNU$|Android") exec_program(${CMAKE_UNAME} ARGS -m OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR RETURN_VALUE val) if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin" AND diff --git a/Modules/CMakeFortranCompiler.cmake.in b/Modules/CMakeFortranCompiler.cmake.in index ae7b73a..34f44aa 100644 --- a/Modules/CMakeFortranCompiler.cmake.in +++ b/Modules/CMakeFortranCompiler.cmake.in @@ -6,6 +6,7 @@ set(CMAKE_Fortran_COMPILER_WRAPPER "@CMAKE_Fortran_COMPILER_WRAPPER@") set(CMAKE_Fortran_PLATFORM_ID "@CMAKE_Fortran_PLATFORM_ID@") set(CMAKE_Fortran_SIMULATE_ID "@CMAKE_Fortran_SIMULATE_ID@") set(CMAKE_Fortran_SIMULATE_VERSION "@CMAKE_Fortran_SIMULATE_VERSION@") +@_SET_CMAKE_Fortran_XL_CPP@ @_SET_CMAKE_Fortran_COMPILER_ARCHITECTURE_ID@ @SET_MSVC_Fortran_ARCHITECTURE_ID@ set(CMAKE_AR "@CMAKE_AR@") diff --git a/Modules/CMakeFortranInformation.cmake b/Modules/CMakeFortranInformation.cmake index ffa6a24..e80716b 100644 --- a/Modules/CMakeFortranInformation.cmake +++ b/Modules/CMakeFortranInformation.cmake @@ -163,6 +163,11 @@ set(CMAKE_Fortran_FLAGS_INIT "$ENV{FFLAGS} ${CMAKE_Fortran_FLAGS_INIT}") cmake_initialize_per_config_variable(CMAKE_Fortran_FLAGS "Flags used by the Fortran compiler") +if(NOT CMAKE_Fortran_COMPILER_LAUNCHER AND DEFINED ENV{CMAKE_Fortran_COMPILER_LAUNCHER}) + set(CMAKE_Fortran_COMPILER_LAUNCHER "$ENV{CMAKE_Fortran_COMPILER_LAUNCHER}" + CACHE STRING "Compiler launcher for Fortran.") +endif() + include(CMakeCommonLanguageInclude) # now define the following rule variables diff --git a/Modules/CMakeGenericSystem.cmake b/Modules/CMakeGenericSystem.cmake index 77d8cfd..7efe5c4 100644 --- a/Modules/CMakeGenericSystem.cmake +++ b/Modules/CMakeGenericSystem.cmake @@ -51,16 +51,16 @@ if(CMAKE_GENERATOR MATCHES "Make") set_property(GLOBAL PROPERTY TARGET_MESSAGES ${CMAKE_TARGET_MESSAGES}) endif() if(CMAKE_GENERATOR MATCHES "Unix Makefiles") - set(CMAKE_EXPORT_COMPILE_COMMANDS OFF CACHE BOOL - "Enable/Disable output of compile commands during generation." + set(CMAKE_EXPORT_COMPILE_COMMANDS "$ENV{CMAKE_EXPORT_COMPILE_COMMANDS}" + CACHE BOOL "Enable/Disable output of compile commands during generation." ) mark_as_advanced(CMAKE_EXPORT_COMPILE_COMMANDS) endif() endif() if(CMAKE_GENERATOR MATCHES "Ninja") - set(CMAKE_EXPORT_COMPILE_COMMANDS OFF CACHE BOOL - "Enable/Disable output of compile commands during generation." + set(CMAKE_EXPORT_COMPILE_COMMANDS "$ENV{CMAKE_EXPORT_COMPILE_COMMANDS}" + CACHE BOOL "Enable/Disable output of compile commands during generation." ) mark_as_advanced(CMAKE_EXPORT_COMPILE_COMMANDS) endif() diff --git a/Modules/CMakeGraphVizOptions.cmake b/Modules/CMakeGraphVizOptions.cmake index 1911e73..be4a3be 100644 --- a/Modules/CMakeGraphVizOptions.cmake +++ b/Modules/CMakeGraphVizOptions.cmake @@ -5,119 +5,145 @@ CMakeGraphVizOptions -------------------- -The builtin graphviz support of CMake. +The builtin Graphviz support of CMake. -Variables specific to the graphviz support -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Generating Graphviz files +^^^^^^^^^^^^^^^^^^^^^^^^^ -CMake -can generate `graphviz <http://www.graphviz.org/>`_ files, showing the dependencies between the -targets in a project and also external libraries which are linked -against. When CMake is run with the ``--graphviz=foo.dot`` option, it will -produce: +CMake can generate `Graphviz <https://www.graphviz.org/>`_ files showing the +dependencies between the targets in a project, as well as external libraries +which are linked against. -* a ``foo.dot`` file showing all dependencies in the project -* a ``foo.dot.<target>`` file for each target, file showing on which other targets the respective target depends -* a ``foo.dot.<target>.dependers`` file, showing which other targets depend on the respective target +When running CMake with the ``--graphviz=foo.dot`` option, it produces: -The different dependency types ``PUBLIC``, ``PRIVATE`` and ``INTERFACE`` -are represented as solid, dashed and dotted edges. +* a ``foo.dot`` file, showing all dependencies in the project +* a ``foo.dot.<target>`` file for each target, showing on which other targets + it depends +* a ``foo.dot.<target>.dependers`` file for each target, showing which other + targets depend on it -This can result in huge graphs. Using the file -``CMakeGraphVizOptions.cmake`` the look and content of the generated -graphs can be influenced. This file is searched first in -:variable:`CMAKE_BINARY_DIR` and then in :variable:`CMAKE_SOURCE_DIR`. If found, it is -read and the variables set in it are used to adjust options for the -generated graphviz files. +Those .dot files can be converted to images using the *dot* command from the +Graphviz package: -.. variable:: GRAPHVIZ_GRAPH_TYPE +.. code-block:: shell - The graph type. + dot -Tpng -o foo.png foo.dot - * Mandatory : NO - * Default : "digraph" +The different dependency types ``PUBLIC``, ``INTERFACE`` and ``PRIVATE`` +are represented as solid, dashed and dotted edges. - Valid graph types are: +Variables specific to the Graphviz support +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - * "graph" : Nodes are joined with lines - * "digraph" : Nodes are joined with arrows showing direction - * "strict graph" : Like "graph" but max one line between each node - * "strict digraph" : Like "graph" but max one line between each node in each direction +The resulting graphs can be huge. The look and content of the generated graphs +can be controlled using the file ``CMakeGraphVizOptions.cmake``. This file is +first searched in :variable:`CMAKE_BINARY_DIR`, and then in +:variable:`CMAKE_SOURCE_DIR`. If found, the variables set in it are used to +adjust options for the generated Graphviz files. .. variable:: GRAPHVIZ_GRAPH_NAME The graph name. - * Mandatory : NO - * Default : "GG" + * Mandatory: NO + * Default: value of :variable:`CMAKE_PROJECT_NAME` .. variable:: GRAPHVIZ_GRAPH_HEADER - The header written at the top of the graphviz file. + The header written at the top of the Graphviz files. - * Mandatory : NO - * Default : "node [n fontsize = "12"];" + * Mandatory: NO + * Default: "node [ fontsize = "12" ];" .. variable:: GRAPHVIZ_NODE_PREFIX - The prefix for each node in the graphviz file. + The prefix for each node in the Graphviz files. - * Mandatory : NO - * Default : "node" + * Mandatory: NO + * Default: "node" .. variable:: GRAPHVIZ_EXECUTABLES - Set this to FALSE to exclude executables from the generated graphs. + Set to FALSE to exclude executables from the generated graphs. - * Mandatory : NO - * Default : TRUE + * Mandatory: NO + * Default: TRUE .. variable:: GRAPHVIZ_STATIC_LIBS - Set this to FALSE to exclude static libraries from the generated graphs. + Set to FALSE to exclude static libraries from the generated graphs. - * Mandatory : NO - * Default : TRUE + * Mandatory: NO + * Default: TRUE .. variable:: GRAPHVIZ_SHARED_LIBS - Set this to FALSE to exclude shared libraries from the generated graphs. + Set to FALSE to exclude shared libraries from the generated graphs. - * Mandatory : NO - * Default : TRUE + * Mandatory: NO + * Default: TRUE .. variable:: GRAPHVIZ_MODULE_LIBS - Set this to FALSE to exclude module libraries from the generated graphs. + Set to FALSE to exclude module libraries from the generated graphs. + + * Mandatory: NO + * Default: TRUE + +.. variable:: GRAPHVIZ_INTERFACE_LIBS + + Set to FALSE to exclude interface libraries from the generated graphs. + + * Mandatory: NO + * Default: TRUE - * Mandatory : NO - * Default : TRUE +.. variable:: GRAPHVIZ_OBJECT_LIBS + + Set to FALSE to exclude object libraries from the generated graphs. + + * Mandatory: NO + * Default: TRUE + +.. variable:: GRAPHVIZ_UNKNOWN_LIBS + + Set to FALSE to exclude unknown libraries from the generated graphs. + + * Mandatory: NO + * Default: TRUE .. variable:: GRAPHVIZ_EXTERNAL_LIBS - Set this to FALSE to exclude external libraries from the generated graphs. + Set to FALSE to exclude external libraries from the generated graphs. + + * Mandatory: NO + * Default: TRUE + +.. variable:: GRAPHVIZ_CUSTOM_TARGETS + + Set to TRUE to include custom targets in the generated graphs. - * Mandatory : NO - * Default : TRUE + * Mandatory: NO + * Default: FALSE .. variable:: GRAPHVIZ_IGNORE_TARGETS - A list of regular expressions for ignoring targets. + A list of regular expressions for names of targets to exclude from the + generated graphs. - * Mandatory : NO - * Default : empty + * Mandatory: NO + * Default: empty .. variable:: GRAPHVIZ_GENERATE_PER_TARGET - Set this to FALSE to exclude per target graphs ``foo.dot.<target>``. + Set to FALSE to not generate per-target graphs ``foo.dot.<target>``. - * Mandatory : NO - * Default : TRUE + * Mandatory: NO + * Default: TRUE .. variable:: GRAPHVIZ_GENERATE_DEPENDERS - Set this to FALSE to exclude depender graphs ``foo.dot.<target>.dependers``. + Set to FALSE to not generate depender graphs ``foo.dot.<target>.dependers``. - * Mandatory : NO - * Default : TRUE + * Mandatory: NO + * Default: TRUE #]=======================================================================] diff --git a/Modules/CMakeMinGWFindMake.cmake b/Modules/CMakeMinGWFindMake.cmake index 523f00c..f026e9a 100644 --- a/Modules/CMakeMinGWFindMake.cmake +++ b/Modules/CMakeMinGWFindMake.cmake @@ -7,10 +7,5 @@ find_program(CMAKE_MAKE_PROGRAM mingw32-make.exe PATHS c:/MinGW/bin /MinGW/bin "[HKEY_CURRENT_USER\\Software\\CodeBlocks;Path]/MinGW/bin" ) -find_program(CMAKE_SH sh.exe ) -if(CMAKE_SH) - message(FATAL_ERROR "sh.exe was found in your PATH, here:\n${CMAKE_SH}\nFor MinGW make to work correctly sh.exe must NOT be in your path.\nRun cmake from a shell that does not have sh.exe in your PATH.\nIf you want to use a UNIX shell, then use MSYS Makefiles.\n") - set(CMAKE_MAKE_PROGRAM NOTFOUND) -endif() -mark_as_advanced(CMAKE_MAKE_PROGRAM CMAKE_SH) +mark_as_advanced(CMAKE_MAKE_PROGRAM) diff --git a/Modules/CMakeNinjaFindMake.cmake b/Modules/CMakeNinjaFindMake.cmake index 702af13..32f78da 100644 --- a/Modules/CMakeNinjaFindMake.cmake +++ b/Modules/CMakeNinjaFindMake.cmake @@ -4,5 +4,6 @@ find_program(CMAKE_MAKE_PROGRAM NAMES ninja-build ninja samu + NAMES_PER_DIR DOC "Program used to build from build.ninja files.") mark_as_advanced(CMAKE_MAKE_PROGRAM) diff --git a/Modules/CMakeOBJCInformation.cmake b/Modules/CMakeOBJCInformation.cmake index cb61cb8..15a3311 100644 --- a/Modules/CMakeOBJCInformation.cmake +++ b/Modules/CMakeOBJCInformation.cmake @@ -110,6 +110,11 @@ if(CMAKE_OBJC_STANDARD_LIBRARIES_INIT) mark_as_advanced(CMAKE_OBJC_STANDARD_LIBRARIES) endif() +if(NOT CMAKE_OBJC_COMPILER_LAUNCHER AND DEFINED ENV{CMAKE_OBJC_COMPILER_LAUNCHER}) + set(CMAKE_OBJC_COMPILER_LAUNCHER "$ENV{CMAKE_OBJC_COMPILER_LAUNCHER}" + CACHE STRING "Compiler launcher for OBJC.") +endif() + include(CMakeCommonLanguageInclude) # now define the following rule variables diff --git a/Modules/CMakeOBJCXXInformation.cmake b/Modules/CMakeOBJCXXInformation.cmake index 71ac26a..cb349d7 100644 --- a/Modules/CMakeOBJCXXInformation.cmake +++ b/Modules/CMakeOBJCXXInformation.cmake @@ -203,6 +203,11 @@ if(CMAKE_OBJCXX_STANDARD_LIBRARIES_INIT) mark_as_advanced(CMAKE_OBJCXX_STANDARD_LIBRARIES) endif() +if(NOT CMAKE_OBJCXX_COMPILER_LAUNCHER AND DEFINED ENV{CMAKE_OBJCXX_COMPILER_LAUNCHER}) + set(CMAKE_OBJCXX_COMPILER_LAUNCHER "$ENV{CMAKE_OBJCXX_COMPILER_LAUNCHER}" + CACHE STRING "Compiler launcher for OBJCXX.") +endif() + include(CMakeCommonLanguageInclude) # now define the following rules: diff --git a/Modules/CMakeSwiftInformation.cmake b/Modules/CMakeSwiftInformation.cmake index 2c54da0..672d3f8 100644 --- a/Modules/CMakeSwiftInformation.cmake +++ b/Modules/CMakeSwiftInformation.cmake @@ -72,10 +72,6 @@ if(NOT CMAKE_Swift_NUM_THREADS MATCHES "^[0-9]+$") cmake_host_system_information(RESULT CMAKE_Swift_NUM_THREADS QUERY NUMBER_OF_LOGICAL_CORES) endif() -if(CMAKE_SYSTEM_NAME STREQUAL Windows) - set(CMAKE_Swift_IMPLIB_LINKER_FLAGS "-Xlinker -implib:<TARGET_IMPLIB>") -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>") endif() diff --git a/Modules/CMakeTestCCompiler.cmake b/Modules/CMakeTestCCompiler.cmake index 7bf6fde..eadea89 100644 --- a/Modules/CMakeTestCCompiler.cmake +++ b/Modules/CMakeTestCCompiler.cmake @@ -27,7 +27,7 @@ unset(CMAKE_C_COMPILER_WORKS CACHE) # is set and cmake stops processing commands and will not generate # any makefiles or projects. if(NOT CMAKE_C_COMPILER_WORKS) - PrintTestCompilerStatus("C" "") + PrintTestCompilerStatus("C") __TestCompiler_setTryCompileTargetType() file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler.c "#ifdef __cplusplus\n" @@ -52,7 +52,7 @@ if(NOT CMAKE_C_COMPILER_WORKS) endif() if(NOT CMAKE_C_COMPILER_WORKS) - PrintTestCompilerStatus("C" " -- broken") + PrintTestCompilerResult(CHECK_FAIL "broken") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the C compiler works failed with " "the following output:\n${__CMAKE_C_COMPILER_OUTPUT}\n\n") @@ -63,7 +63,7 @@ if(NOT CMAKE_C_COMPILER_WORKS) "CMake will not be able to correctly generate this project.") else() if(C_TEST_WAS_RUN) - PrintTestCompilerStatus("C" " -- works") + PrintTestCompilerResult(CHECK_PASS "works") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the C compiler works passed with " "the following output:\n${__CMAKE_C_COMPILER_OUTPUT}\n\n") diff --git a/Modules/CMakeTestCSharpCompiler.cmake b/Modules/CMakeTestCSharpCompiler.cmake index 6715c30..1119a45 100644 --- a/Modules/CMakeTestCSharpCompiler.cmake +++ b/Modules/CMakeTestCSharpCompiler.cmake @@ -20,7 +20,9 @@ set(test_compile_file "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test # is set and cmake stops processing commands and will not generate # any makefiles or projects. if(NOT CMAKE_CSharp_COMPILER_WORKS) - PrintTestCompilerStatus("C#" "${CMAKE_CSharp_COMPILER}") + # 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 {" @@ -38,7 +40,7 @@ if(NOT CMAKE_CSharp_COMPILER_WORKS) endif() if(NOT CMAKE_CSharp_COMPILER_WORKS) - PrintTestCompilerStatus("C#" "${CMAKE_CSharp_COMPILER} -- broken") + PrintTestCompilerResult(CHECK_FAIL "broken") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the C# compiler works failed with " "the following output:\n${__CMAKE_CSharp_COMPILER_OUTPUT}\n\n") @@ -49,7 +51,7 @@ if(NOT CMAKE_CSharp_COMPILER_WORKS) "CMake will not be able to correctly generate this project.") else() if(CSharp_TEST_WAS_RUN) - PrintTestCompilerStatus("C#" "${CMAKE_CSharp_COMPILER} -- works") + PrintTestCompilerResult(CHECK_PASS "works") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the C# compiler works passed with " "the following output:\n${__CMAKE_CSharp_COMPILER_OUTPUT}\n\n") diff --git a/Modules/CMakeTestCUDACompiler.cmake b/Modules/CMakeTestCUDACompiler.cmake index f0454da..d80b55a 100644 --- a/Modules/CMakeTestCUDACompiler.cmake +++ b/Modules/CMakeTestCUDACompiler.cmake @@ -20,7 +20,7 @@ unset(CMAKE_CUDA_COMPILER_WORKS CACHE) # is set and cmake stops processing commands and will not generate # any makefiles or projects. if(NOT CMAKE_CUDA_COMPILER_WORKS) - PrintTestCompilerStatus("CUDA" "") + PrintTestCompilerStatus("CUDA") file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/main.cu "#ifndef __CUDACC__\n" "# error \"The CMAKE_CUDA_COMPILER is set to an invalid CUDA compiler\"\n" @@ -38,7 +38,7 @@ if(NOT CMAKE_CUDA_COMPILER_WORKS) endif() if(NOT CMAKE_CUDA_COMPILER_WORKS) - PrintTestCompilerStatus("CUDA" " -- broken") + PrintTestCompilerResult(CHECK_FAIL "broken") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the CUDA compiler works failed with " "the following output:\n${__CMAKE_CUDA_COMPILER_OUTPUT}\n\n") @@ -49,7 +49,7 @@ if(NOT CMAKE_CUDA_COMPILER_WORKS) "CMake will not be able to correctly generate this project.") else() if(CUDA_TEST_WAS_RUN) - PrintTestCompilerStatus("CUDA" " -- works") + PrintTestCompilerResult(CHECK_PASS "works") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the CUDA compiler works passed with " "the following output:\n${__CMAKE_CUDA_COMPILER_OUTPUT}\n\n") @@ -58,12 +58,26 @@ else() # Try to identify the ABI and configure it into CMakeCUDACompiler.cmake include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) CMAKE_DETERMINE_COMPILER_ABI(CUDA ${CMAKE_ROOT}/Modules/CMakeCUDACompilerABI.cu) + # Try to identify the compiler features + include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake) + CMAKE_DETERMINE_COMPILE_FEATURES(CUDA) if("x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC") set(CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES "${CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES}") set(CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES "${CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES}") endif() + # Remove the following libraries from CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES and + # CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES + # + # - cudart + # - cudart_static + # - cudadevrt + # + # These are controlled by CMAKE_CUDA_RUNTIME_LIBRARY + list(REMOVE_ITEM CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES cudart cudart_static cudadevrt) + list(REMOVE_ITEM CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES cudart cudart_static cudadevrt) + # Re-configure to save learned information. configure_file( ${CMAKE_ROOT}/Modules/CMakeCUDACompiler.cmake.in diff --git a/Modules/CMakeTestCXXCompiler.cmake b/Modules/CMakeTestCXXCompiler.cmake index 7e595b7..bd42153 100644 --- a/Modules/CMakeTestCXXCompiler.cmake +++ b/Modules/CMakeTestCXXCompiler.cmake @@ -27,7 +27,7 @@ unset(CMAKE_CXX_COMPILER_WORKS CACHE) # is set and cmake stops processing commands and will not generate # any makefiles or projects. if(NOT CMAKE_CXX_COMPILER_WORKS) - PrintTestCompilerStatus("CXX" "") + PrintTestCompilerStatus("CXX") __TestCompiler_setTryCompileTargetType() file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCXXCompiler.cxx "#ifndef __cplusplus\n" @@ -45,7 +45,7 @@ if(NOT CMAKE_CXX_COMPILER_WORKS) endif() if(NOT CMAKE_CXX_COMPILER_WORKS) - PrintTestCompilerStatus("CXX" " -- broken") + PrintTestCompilerResult(CHECK_FAIL "broken") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the CXX compiler works failed with " "the following output:\n${__CMAKE_CXX_COMPILER_OUTPUT}\n\n") @@ -56,7 +56,7 @@ if(NOT CMAKE_CXX_COMPILER_WORKS) "CMake will not be able to correctly generate this project.") else() if(CXX_TEST_WAS_RUN) - PrintTestCompilerStatus("CXX" " -- works") + PrintTestCompilerResult(CHECK_PASS "works") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the CXX compiler works passed with " "the following output:\n${__CMAKE_CXX_COMPILER_OUTPUT}\n\n") diff --git a/Modules/CMakeTestCompilerCommon.cmake b/Modules/CMakeTestCompilerCommon.cmake index 6ee5175..da7c007 100644 --- a/Modules/CMakeTestCompilerCommon.cmake +++ b/Modules/CMakeTestCompilerCommon.cmake @@ -2,8 +2,15 @@ # file Copyright.txt or https://cmake.org/licensing for details. -function(PrintTestCompilerStatus LANG MSG) - message(STATUS "Check for working ${LANG} compiler: ${CMAKE_${LANG}_COMPILER}${MSG}") +function(PrintTestCompilerStatus LANG) + # ARGN shouldn't be needed now, but it is there to preserve backward + # compatibility in case this function is called from project code or + # custom toolchains (they shouldn't, but we can easily support it) + message(CHECK_START "Check for working ${LANG} compiler: ${CMAKE_${LANG}_COMPILER}${ARGN}") +endfunction() + +function(PrintTestCompilerResult TYPE MSG) + message(${TYPE} "${MSG}") endfunction() # if required set the target type if not already explicitly set diff --git a/Modules/CMakeTestFortranCompiler.cmake b/Modules/CMakeTestFortranCompiler.cmake index e9860e9..7461f9c 100644 --- a/Modules/CMakeTestFortranCompiler.cmake +++ b/Modules/CMakeTestFortranCompiler.cmake @@ -21,7 +21,7 @@ unset(CMAKE_Fortran_COMPILER_WORKS CACHE) # is set and cmake stops processing commands and will not generate # any makefiles or projects. if(NOT CMAKE_Fortran_COMPILER_WORKS) - PrintTestCompilerStatus("Fortran" "") + PrintTestCompilerStatus("Fortran") file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f " PROGRAM TESTFortran PRINT *, 'Hello' @@ -37,7 +37,7 @@ if(NOT CMAKE_Fortran_COMPILER_WORKS) endif() if(NOT CMAKE_Fortran_COMPILER_WORKS) - PrintTestCompilerStatus("Fortran" " -- broken") + PrintTestCompilerResult(CHECK_FAIL "broken") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the Fortran compiler works failed with " "the following output:\n${OUTPUT}\n\n") @@ -48,7 +48,7 @@ if(NOT CMAKE_Fortran_COMPILER_WORKS) "CMake will not be able to correctly generate this project.") else() if(FORTRAN_TEST_WAS_RUN) - PrintTestCompilerStatus("Fortran" " -- works") + PrintTestCompilerResult(CHECK_PASS "works") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the Fortran compiler works passed with " "the following output:\n${OUTPUT}\n\n") @@ -60,7 +60,7 @@ else() # Test for Fortran 90 support by using an f90-specific construct. if(NOT DEFINED CMAKE_Fortran_COMPILER_SUPPORTS_F90) - message(STATUS "Checking whether ${CMAKE_Fortran_COMPILER} supports Fortran 90") + message(CHECK_START "Checking whether ${CMAKE_Fortran_COMPILER} supports Fortran 90") file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompilerF90.f90 " PROGRAM TESTFortran90 integer stop ; stop = 1 ; do while ( stop .eq. 0 ) ; end do @@ -70,13 +70,13 @@ else() ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompilerF90.f90 OUTPUT_VARIABLE OUTPUT) if(CMAKE_Fortran_COMPILER_SUPPORTS_F90) - message(STATUS "Checking whether ${CMAKE_Fortran_COMPILER} supports Fortran 90 -- yes") + message(CHECK_PASS "yes") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the Fortran compiler supports Fortran 90 passed with " "the following output:\n${OUTPUT}\n\n") set(CMAKE_Fortran_COMPILER_SUPPORTS_F90 1) else() - message(STATUS "Checking whether ${CMAKE_Fortran_COMPILER} supports Fortran 90 -- no") + message(CHECK_FAIL "no") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the Fortran compiler supports Fortran 90 failed with " "the following output:\n${OUTPUT}\n\n") diff --git a/Modules/CMakeTestOBJCCompiler.cmake b/Modules/CMakeTestOBJCCompiler.cmake index 0030683..bcc6fae 100644 --- a/Modules/CMakeTestOBJCCompiler.cmake +++ b/Modules/CMakeTestOBJCCompiler.cmake @@ -27,7 +27,7 @@ unset(CMAKE_OBJC_COMPILER_WORKS CACHE) # is set and cmake stops processing commands and will not generate # any makefiles or projects. if(NOT CMAKE_OBJC_COMPILER_WORKS) - PrintTestCompilerStatus("OBJC" "") + PrintTestCompilerStatus("OBJC") __TestCompiler_setTryCompileTargetType() file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testOBJCCompiler.m "#ifdef __cplusplus\n" @@ -49,7 +49,7 @@ if(NOT CMAKE_OBJC_COMPILER_WORKS) endif() if(NOT CMAKE_OBJC_COMPILER_WORKS) - PrintTestCompilerStatus("OBJC" " -- broken") + PrintTestCompilerResult(CHECK_FAIL "broken") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the Objective-C compiler works failed with " "the following output:\n${__CMAKE_OBJC_COMPILER_OUTPUT}\n\n") @@ -60,7 +60,7 @@ if(NOT CMAKE_OBJC_COMPILER_WORKS) "CMake will not be able to correctly generate this project.") else() if(OBJC_TEST_WAS_RUN) - PrintTestCompilerStatus("OBJC" " -- works") + PrintTestCompilerResult(CHECK_PASS "works") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the Objective-C compiler works passed with " "the following output:\n${__CMAKE_OBJC_COMPILER_OUTPUT}\n\n") diff --git a/Modules/CMakeTestOBJCXXCompiler.cmake b/Modules/CMakeTestOBJCXXCompiler.cmake index bcce2f1..83227d5 100644 --- a/Modules/CMakeTestOBJCXXCompiler.cmake +++ b/Modules/CMakeTestOBJCXXCompiler.cmake @@ -27,7 +27,7 @@ unset(CMAKE_OBJCXX_COMPILER_WORKS CACHE) # is set and cmake stops processing commands and will not generate # any makefiles or projects. if(NOT CMAKE_OBJCXX_COMPILER_WORKS) - PrintTestCompilerStatus("OBJCXX" "") + PrintTestCompilerStatus("OBJCXX") __TestCompiler_setTryCompileTargetType() file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testOBJCXXCompiler.mm "#ifndef __cplusplus\n" @@ -48,7 +48,7 @@ if(NOT CMAKE_OBJCXX_COMPILER_WORKS) endif() if(NOT CMAKE_OBJCXX_COMPILER_WORKS) - PrintTestCompilerStatus("OBJCXX" " -- broken") + PrintTestCompilerResult(CHECK_FAIL "broken") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the Objective-C++ compiler works failed with " "the following output:\n${__CMAKE_OBJCXX_COMPILER_OUTPUT}\n\n") @@ -59,7 +59,7 @@ if(NOT CMAKE_OBJCXX_COMPILER_WORKS) "CMake will not be able to correctly generate this project.") else() if(OBJCXX_TEST_WAS_RUN) - PrintTestCompilerStatus("OBJCXX" " -- works") + PrintTestCompilerResult(CHECK_PASS "works") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the Objective-C++ compiler works passed with " "the following output:\n${__CMAKE_OBJCXX_COMPILER_OUTPUT}\n\n") diff --git a/Modules/CMakeTestSwiftCompiler.cmake b/Modules/CMakeTestSwiftCompiler.cmake index 841aee6..3e4ff95 100644 --- a/Modules/CMakeTestSwiftCompiler.cmake +++ b/Modules/CMakeTestSwiftCompiler.cmake @@ -20,7 +20,7 @@ unset(CMAKE_Swift_COMPILER_WORKS CACHE) # is set and cmake stops processing commands and will not generate # any makefiles or projects. if(NOT CMAKE_Swift_COMPILER_WORKS) - PrintTestCompilerStatus("Swift" "") + PrintTestCompilerStatus("Swift") file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/main.swift "print(\"CMake\")\n") try_compile(CMAKE_Swift_COMPILER_WORKS ${CMAKE_BINARY_DIR} @@ -33,7 +33,7 @@ if(NOT CMAKE_Swift_COMPILER_WORKS) endif() if(NOT CMAKE_Swift_COMPILER_WORKS) - PrintTestCompilerStatus("Swift" " -- broken") + PrintTestCompilerResult(CHECK_FAIL "broken") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the Swift compiler works failed with " "the following output:\n${__CMAKE_Swift_COMPILER_OUTPUT}\n\n") @@ -44,7 +44,7 @@ if(NOT CMAKE_Swift_COMPILER_WORKS) "CMake will not be able to correctly generate this project.") else() if(Swift_TEST_WAS_RUN) - PrintTestCompilerStatus("Swift" " -- works") + PrintTestCompilerResult(CHECK_PASS "works") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the Swift compiler works passed with " "the following output:\n${__CMAKE_Swift_COMPILER_OUTPUT}\n\n") diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index a1cc71d..684edae 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -458,12 +458,13 @@ if(NOT DEFINED CPACK_PACKAGE_VERSION) endif() _cpack_set_default(CPACK_PACKAGE_VENDOR "Humanity") +set(CPACK_DEFAULT_PACKAGE_DESCRIPTION_SUMMARY "${CMAKE_PROJECT_NAME} built using CMake") if(CMAKE_PROJECT_DESCRIPTION) _cpack_set_default(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${CMAKE_PROJECT_DESCRIPTION}") else() _cpack_set_default(CPACK_PACKAGE_DESCRIPTION_SUMMARY - "${CMAKE_PROJECT_NAME} built using CMake") + "${CPACK_DEFAULT_PACKAGE_DESCRIPTION_SUMMARY}") endif() if(CMAKE_PROJECT_HOMEPAGE_URL) _cpack_set_default(CPACK_PACKAGE_HOMEPAGE_URL @@ -562,11 +563,19 @@ if(NOT CPACK_GENERATOR) if(APPLE) option(CPACK_BINARY_BUNDLE "Enable to build OSX bundles" OFF) option(CPACK_BINARY_DRAGNDROP "Enable to build OSX Drag And Drop package" OFF) - option(CPACK_BINARY_OSXX11 "Enable to build OSX X11 packages" OFF) - option(CPACK_BINARY_PACKAGEMAKER "Enable to build PackageMaker packages" OFF) + option(CPACK_BINARY_OSXX11 "Enable to build OSX X11 packages (deprecated)" OFF) + option(CPACK_BINARY_PACKAGEMAKER "Enable to build PackageMaker packages (deprecated)" OFF) option(CPACK_BINARY_PRODUCTBUILD "Enable to build productbuild packages" OFF) + mark_as_advanced( + CPACK_BINARY_BUNDLE + CPACK_BINARY_DRAGNDROP + CPACK_BINARY_OSXX11 + CPACK_BINARY_PACKAGEMAKER + CPACK_BINARY_PRODUCTBUILD + ) else() option(CPACK_BINARY_TZ "Enable to build TZ packages" ON) + mark_as_advanced(CPACK_BINARY_TZ) endif() option(CPACK_BINARY_DEB "Enable to build Debian packages" OFF) option(CPACK_BINARY_FREEBSD "Enable to build FreeBSD packages" OFF) @@ -576,6 +585,16 @@ if(NOT CPACK_GENERATOR) option(CPACK_BINARY_TBZ2 "Enable to build TBZ2 packages" OFF) option(CPACK_BINARY_TGZ "Enable to build TGZ packages" ON) option(CPACK_BINARY_TXZ "Enable to build TXZ packages" OFF) + mark_as_advanced( + CPACK_BINARY_DEB + CPACK_BINARY_FREEBSD + CPACK_BINARY_NSIS + CPACK_BINARY_RPM + CPACK_BINARY_STGZ + CPACK_BINARY_TBZ2 + CPACK_BINARY_TGZ + CPACK_BINARY_TXZ + ) endif() else() option(CPACK_BINARY_7Z "Enable to build 7-Zip packages" OFF) @@ -583,8 +602,16 @@ if(NOT CPACK_GENERATOR) option(CPACK_BINARY_NUGET "Enable to build NuGet packages" OFF) option(CPACK_BINARY_WIX "Enable to build WiX packages" OFF) option(CPACK_BINARY_ZIP "Enable to build ZIP packages" OFF) + mark_as_advanced( + CPACK_BINARY_7Z + CPACK_BINARY_NSIS + CPACK_BINARY_NUGET + CPACK_BINARY_WIX + CPACK_BINARY_ZIP + ) endif() option(CPACK_BINARY_IFW "Enable to build IFW packages" OFF) + mark_as_advanced(CPACK_BINARY_IFW) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_7Z 7Z) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_BUNDLE Bundle) @@ -614,6 +641,7 @@ if(NOT CPACK_SOURCE_GENERATOR) if(UNIX) if(CYGWIN) option(CPACK_SOURCE_CYGWIN "Enable to build Cygwin source packages" ON) + mark_as_advanced(CPACK_SOURCE_CYGWIN) else() option(CPACK_SOURCE_RPM "Enable to build RPM source packages" OFF) option(CPACK_SOURCE_TBZ2 "Enable to build TBZ2 source packages" ON) @@ -621,10 +649,22 @@ if(NOT CPACK_SOURCE_GENERATOR) option(CPACK_SOURCE_TXZ "Enable to build TXZ source packages" ON) option(CPACK_SOURCE_TZ "Enable to build TZ source packages" ON) option(CPACK_SOURCE_ZIP "Enable to build ZIP source packages" OFF) + mark_as_advanced( + CPACK_SOURCE_RPM + CPACK_SOURCE_TBZ2 + CPACK_SOURCE_TGZ + CPACK_SOURCE_TXZ + CPACK_SOURCE_TZ + CPACK_SOURCE_ZIP + ) endif() else() option(CPACK_SOURCE_7Z "Enable to build 7-Zip source packages" ON) option(CPACK_SOURCE_ZIP "Enable to build ZIP source packages" ON) + mark_as_advanced( + CPACK_SOURCE_7Z + CPACK_SOURCE_ZIP + ) endif() cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_7Z 7Z) @@ -637,38 +677,6 @@ if(NOT CPACK_SOURCE_GENERATOR) cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_ZIP ZIP) endif() -# mark the above options as advanced -mark_as_advanced( - CPACK_BINARY_7Z - CPACK_BINARY_BUNDLE - CPACK_BINARY_CYGWIN - CPACK_BINARY_DEB - CPACK_BINARY_DRAGNDROP - CPACK_BINARY_FREEBSD - CPACK_BINARY_IFW - CPACK_BINARY_NSIS - CPACK_BINARY_NUGET - CPACK_BINARY_OSXX11 - CPACK_BINARY_PACKAGEMAKER - CPACK_BINARY_PRODUCTBUILD - CPACK_BINARY_RPM - CPACK_BINARY_STGZ - CPACK_BINARY_TBZ2 - CPACK_BINARY_TGZ - CPACK_BINARY_TXZ - CPACK_BINARY_TZ - CPACK_BINARY_WIX - CPACK_BINARY_ZIP - CPACK_SOURCE_7Z - CPACK_SOURCE_CYGWIN - CPACK_SOURCE_RPM - CPACK_SOURCE_TBZ2 - CPACK_SOURCE_TGZ - CPACK_SOURCE_TXZ - CPACK_SOURCE_TZ - CPACK_SOURCE_ZIP - ) - # Set some other variables _cpack_set_default(CPACK_INSTALL_CMAKE_PROJECTS "${CMAKE_BINARY_DIR};${CMAKE_PROJECT_NAME};ALL;/") @@ -683,6 +691,8 @@ endif() # value of CPACK_NSIS_PACKAGE_NAME instead # of CPACK_PACKAGE_INSTALL_DIRECTORY _cpack_set_default(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}") +# Specify the name of the Uninstall file in NSIS +_cpack_set_default(CPACK_NSIS_UNINSTALL_NAME "Uninstall") if(CPACK_NSIS_DISPLAY_NAME_SET) _cpack_set_default(CPACK_NSIS_PACKAGE_NAME "${CPACK_NSIS_DISPLAY_NAME}") diff --git a/Modules/CTest.cmake b/Modules/CTest.cmake index 3a111ca..8109108 100644 --- a/Modules/CTest.cmake +++ b/Modules/CTest.cmake @@ -174,7 +174,7 @@ if(BUILD_TESTING) "How many times to retry timed-out CTest submissions.") find_program(MEMORYCHECK_COMMAND - NAMES purify valgrind boundscheck + NAMES purify valgrind boundscheck drmemory PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Rational Software\\Purify\\Setup;InstallFolder]" DOC "Path to the memory checking command, used for memory error detection." @@ -243,7 +243,6 @@ if(BUILD_TESTING) mark_as_advanced( BZRCOMMAND - BZR_UPDATE_OPTIONS COVERAGE_COMMAND COVERAGE_EXTRA_FLAGS CTEST_SUBMIT_RETRY_DELAY @@ -257,13 +256,10 @@ if(BUILD_TESTING) MAKECOMMAND MEMORYCHECK_COMMAND MEMORYCHECK_SUPPRESSIONS_FILE - PURIFYCOMMAND - SCPCOMMAND SLURM_SBATCH_COMMAND SLURM_SRUN_COMMAND SITE SVNCOMMAND - SVN_UPDATE_OPTIONS ) if(NOT RUN_FROM_DART) set(RUN_FROM_CTEST_OR_DART 1) diff --git a/Modules/CheckCCompilerFlag.cmake b/Modules/CheckCCompilerFlag.cmake index a3e2da3..6d65313 100644 --- a/Modules/CheckCCompilerFlag.cmake +++ b/Modules/CheckCCompilerFlag.cmake @@ -36,28 +36,23 @@ include_guard(GLOBAL) include(CheckCSourceCompiles) include(CMakeCheckCompilerFlagCommonPatterns) -macro (CHECK_C_COMPILER_FLAG _FLAG _RESULT) - set(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}") - set(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}") - - # Normalize locale during test compilation. - set(_CheckCCompilerFlag_LOCALE_VARS LC_ALL LC_MESSAGES LANG) - foreach(v ${_CheckCCompilerFlag_LOCALE_VARS}) - set(_CheckCCompilerFlag_SAVED_${v} "$ENV{${v}}") +function(check_c_compiler_flag _flag _var) + set(CMAKE_REQUIRED_DEFINITIONS "${_flag}") + + # Normalize locale during test compilation. + set(_locale_vars LC_ALL LC_MESSAGES LANG) + foreach(v IN LISTS _locale_vars) + set(_locale_vars_saved_${v} "$ENV{${v}}") set(ENV{${v}} C) endforeach() - CHECK_COMPILER_FLAG_COMMON_PATTERNS(_CheckCCompilerFlag_COMMON_PATTERNS) - CHECK_C_SOURCE_COMPILES("int main(void) { return 0; }" ${_RESULT} + check_compiler_flag_common_patterns(_common_patterns) + check_c_source_compiles("int main(void) { return 0; }" ${_var} # Some compilers do not fail with a bad flag FAIL_REGEX "command line option .* is valid for .* but not for C" # GNU - ${_CheckCCompilerFlag_COMMON_PATTERNS} + ${_common_patterns} ) - foreach(v ${_CheckCCompilerFlag_LOCALE_VARS}) - set(ENV{${v}} ${_CheckCCompilerFlag_SAVED_${v}}) - unset(_CheckCCompilerFlag_SAVED_${v}) + foreach(v IN LISTS _locale_vars) + set(ENV{${v}} ${_locale_vars_saved_${v}}) endforeach() - unset(_CheckCCompilerFlag_LOCALE_VARS) - unset(_CheckCCompilerFlag_COMMON_PATTERNS) - - set (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}") -endmacro () + set(${_var} "${${_var}}" PARENT_SCOPE) +endfunction() diff --git a/Modules/CheckCSourceCompiles.cmake b/Modules/CheckCSourceCompiles.cmake index 77ba0cc..67fc993 100644 --- a/Modules/CheckCSourceCompiles.cmake +++ b/Modules/CheckCSourceCompiles.cmake @@ -104,7 +104,7 @@ macro(CHECK_C_SOURCE_COMPILES SOURCE VAR) "${SOURCE}\n") if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Performing Test ${VAR}") + message(CHECK_START "Performing Test ${VAR}") endif() try_compile(${VAR} ${CMAKE_BINARY_DIR} @@ -125,7 +125,7 @@ macro(CHECK_C_SOURCE_COMPILES SOURCE VAR) if(${VAR}) set(${VAR} 1 CACHE INTERNAL "Test ${VAR}") if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Performing Test ${VAR} - Success") + message(CHECK_PASS "Success") endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Performing C SOURCE FILE Test ${VAR} succeeded with the following output:\n" @@ -133,7 +133,7 @@ macro(CHECK_C_SOURCE_COMPILES SOURCE VAR) "Source file was:\n${SOURCE}\n") else() if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Performing Test ${VAR} - Failed") + message(CHECK_FAIL "Failed") endif() set(${VAR} "" CACHE INTERNAL "Test ${VAR}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log diff --git a/Modules/CheckCSourceRuns.cmake b/Modules/CheckCSourceRuns.cmake index eba70f2..7d116db 100644 --- a/Modules/CheckCSourceRuns.cmake +++ b/Modules/CheckCSourceRuns.cmake @@ -92,7 +92,7 @@ macro(CHECK_C_SOURCE_RUNS SOURCE VAR) "${SOURCE}\n") if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Performing Test ${VAR}") + message(CHECK_START "Performing Test ${VAR}") endif() try_run(${VAR}_EXITCODE ${VAR}_COMPILED ${CMAKE_BINARY_DIR} @@ -113,7 +113,7 @@ macro(CHECK_C_SOURCE_RUNS SOURCE VAR) if("${${VAR}_EXITCODE}" EQUAL 0) set(${VAR} 1 CACHE INTERNAL "Test ${VAR}") if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Performing Test ${VAR} - Success") + message(CHECK_PASS "Success") endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Performing C SOURCE FILE Test ${VAR} succeeded with the following compile output:\n" @@ -130,7 +130,7 @@ macro(CHECK_C_SOURCE_RUNS SOURCE VAR) endif() if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Performing Test ${VAR} - Failed") + message(CHECK_FAIL "Failed") endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Performing C SOURCE FILE Test ${VAR} failed with the following compile output:\n" diff --git a/Modules/CheckCXXCompilerFlag.cmake b/Modules/CheckCXXCompilerFlag.cmake index 5729843..5e07c25 100644 --- a/Modules/CheckCXXCompilerFlag.cmake +++ b/Modules/CheckCXXCompilerFlag.cmake @@ -36,28 +36,23 @@ include_guard(GLOBAL) include(CheckCXXSourceCompiles) include(CMakeCheckCompilerFlagCommonPatterns) -macro (CHECK_CXX_COMPILER_FLAG _FLAG _RESULT) - set(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}") - set(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}") +function(check_cxx_compiler_flag _flag _var) + set(CMAKE_REQUIRED_DEFINITIONS "${_flag}") # Normalize locale during test compilation. - set(_CheckCXXCompilerFlag_LOCALE_VARS LC_ALL LC_MESSAGES LANG) - foreach(v ${_CheckCXXCompilerFlag_LOCALE_VARS}) - set(_CheckCXXCompilerFlag_SAVED_${v} "$ENV{${v}}") + set(_locale_vars LC_ALL LC_MESSAGES LANG) + foreach(v IN LISTS _locale_vars) + set(_locale_vars_saved_${v} "$ENV{${v}}") set(ENV{${v}} C) endforeach() - CHECK_COMPILER_FLAG_COMMON_PATTERNS(_CheckCXXCompilerFlag_COMMON_PATTERNS) - CHECK_CXX_SOURCE_COMPILES("int main() { return 0; }" ${_RESULT} + check_compiler_flag_common_patterns(_common_patterns) + check_cxx_source_compiles("int main() { return 0; }" ${_var} # Some compilers do not fail with a bad flag FAIL_REGEX "command line option .* is valid for .* but not for C\\\\+\\\\+" # GNU - ${_CheckCXXCompilerFlag_COMMON_PATTERNS} + ${_common_patterns} ) - foreach(v ${_CheckCXXCompilerFlag_LOCALE_VARS}) - set(ENV{${v}} ${_CheckCXXCompilerFlag_SAVED_${v}}) - unset(_CheckCXXCompilerFlag_SAVED_${v}) + foreach(v IN LISTS _locale_vars) + set(ENV{${v}} ${_locale_vars_saved_${v}}) endforeach() - unset(_CheckCXXCompilerFlag_LOCALE_VARS) - unset(_CheckCXXCompilerFlag_COMMON_PATTERNS) - - set (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}") -endmacro () + set(${_var} "${${_var}}" PARENT_SCOPE) +endfunction() diff --git a/Modules/CheckCXXSourceCompiles.cmake b/Modules/CheckCXXSourceCompiles.cmake index cc457a5..c693d32 100644 --- a/Modules/CheckCXXSourceCompiles.cmake +++ b/Modules/CheckCXXSourceCompiles.cmake @@ -105,7 +105,7 @@ macro(CHECK_CXX_SOURCE_COMPILES SOURCE VAR) "${SOURCE}\n") if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Performing Test ${VAR}") + message(CHECK_START "Performing Test ${VAR}") endif() try_compile(${VAR} ${CMAKE_BINARY_DIR} @@ -126,7 +126,7 @@ macro(CHECK_CXX_SOURCE_COMPILES SOURCE VAR) if(${VAR}) set(${VAR} 1 CACHE INTERNAL "Test ${VAR}") if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Performing Test ${VAR} - Success") + message(CHECK_PASS "Success") endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Performing C++ SOURCE FILE Test ${VAR} succeeded with the following output:\n" @@ -134,7 +134,7 @@ macro(CHECK_CXX_SOURCE_COMPILES SOURCE VAR) "Source file was:\n${SOURCE}\n") else() if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Performing Test ${VAR} - Failed") + message(CHECK_FAIL "Failed") endif() set(${VAR} "" CACHE INTERNAL "Test ${VAR}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log diff --git a/Modules/CheckCXXSourceRuns.cmake b/Modules/CheckCXXSourceRuns.cmake index 5e3f195..408e183 100644 --- a/Modules/CheckCXXSourceRuns.cmake +++ b/Modules/CheckCXXSourceRuns.cmake @@ -92,7 +92,7 @@ macro(CHECK_CXX_SOURCE_RUNS SOURCE VAR) "${SOURCE}\n") if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Performing Test ${VAR}") + message(CHECK_START "Performing Test ${VAR}") endif() try_run(${VAR}_EXITCODE ${VAR}_COMPILED ${CMAKE_BINARY_DIR} @@ -114,7 +114,7 @@ macro(CHECK_CXX_SOURCE_RUNS SOURCE VAR) if("${${VAR}_EXITCODE}" EQUAL 0) set(${VAR} 1 CACHE INTERNAL "Test ${VAR}") if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Performing Test ${VAR} - Success") + message(CHECK_PASS "Success") endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Performing C++ SOURCE FILE Test ${VAR} succeeded with the following output:\n" @@ -131,7 +131,7 @@ macro(CHECK_CXX_SOURCE_RUNS SOURCE VAR) endif() if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Performing Test ${VAR} - Failed") + message(CHECK_FAIL "Failed") endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Performing C++ SOURCE FILE Test ${VAR} failed with the following output:\n" diff --git a/Modules/CheckFortranFunctionExists.cmake b/Modules/CheckFortranFunctionExists.cmake index 7ca205a..d06203f 100644 --- a/Modules/CheckFortranFunctionExists.cmake +++ b/Modules/CheckFortranFunctionExists.cmake @@ -38,7 +38,7 @@ include_guard(GLOBAL) macro(CHECK_FORTRAN_FUNCTION_EXISTS FUNCTION VARIABLE) if(NOT DEFINED ${VARIABLE}) - message(STATUS "Looking for Fortran ${FUNCTION}") + message(CHECK_START "Looking for Fortran ${FUNCTION}") if(CMAKE_REQUIRED_LINK_OPTIONS) set(CHECK_FUNCTION_EXISTS_ADD_LINK_OPTIONS LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS}) @@ -61,21 +61,20 @@ macro(CHECK_FORTRAN_FUNCTION_EXISTS FUNCTION VARIABLE) " ) try_compile(${VARIABLE} - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f - ${CHECK_FUNCTION_EXISTS_ADD_LINK_OPTIONS} - ${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES} - OUTPUT_VARIABLE OUTPUT + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f + ${CHECK_FUNCTION_EXISTS_ADD_LINK_OPTIONS} + ${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES} + OUTPUT_VARIABLE OUTPUT ) -# message(STATUS "${OUTPUT}") if(${VARIABLE}) set(${VARIABLE} 1 CACHE INTERNAL "Have Fortran function ${FUNCTION}") - message(STATUS "Looking for Fortran ${FUNCTION} - found") + message(CHECK_PASS "found") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the Fortran ${FUNCTION} exists passed with the following output:\n" "${OUTPUT}\n\n") else() - message(STATUS "Looking for Fortran ${FUNCTION} - not found") + message(CHECK_FAIL "not found") set(${VARIABLE} "" CACHE INTERNAL "Have Fortran function ${FUNCTION}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the Fortran ${FUNCTION} exists failed with the following output:\n" diff --git a/Modules/CheckFortranSourceCompiles.cmake b/Modules/CheckFortranSourceCompiles.cmake index f94b254..f0fde8d 100644 --- a/Modules/CheckFortranSourceCompiles.cmake +++ b/Modules/CheckFortranSourceCompiles.cmake @@ -127,7 +127,7 @@ macro(CHECK_Fortran_SOURCE_COMPILES SOURCE VAR) "${SOURCE}\n") if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Performing Test ${VAR}") + message(CHECK_START "Performing Test ${VAR}") endif() try_compile(${VAR} ${CMAKE_BINARY_DIR} @@ -148,7 +148,7 @@ macro(CHECK_Fortran_SOURCE_COMPILES SOURCE VAR) if(${VAR}) set(${VAR} 1 CACHE INTERNAL "Test ${VAR}") if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Performing Test ${VAR} - Success") + message(CHECK_PASS "Success") endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Performing Fortran SOURCE FILE Test ${VAR} succeeded with the following output:\n" @@ -156,7 +156,7 @@ macro(CHECK_Fortran_SOURCE_COMPILES SOURCE VAR) "Source file was:\n${SOURCE}\n") else() if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Performing Test ${VAR} - Failed") + message(CHECK_FAIL "Failed") endif() set(${VAR} "" CACHE INTERNAL "Test ${VAR}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log diff --git a/Modules/CheckFortranSourceRuns.cmake b/Modules/CheckFortranSourceRuns.cmake index a80c13d..a3e5d5d 100644 --- a/Modules/CheckFortranSourceRuns.cmake +++ b/Modules/CheckFortranSourceRuns.cmake @@ -122,7 +122,7 @@ macro(CHECK_Fortran_SOURCE_RUNS SOURCE VAR) "${SOURCE}\n") if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Performing Test ${VAR}") + message(CHECK_START "Performing Test ${VAR}") endif() try_run(${VAR}_EXITCODE ${VAR}_COMPILED ${CMAKE_BINARY_DIR} @@ -144,7 +144,7 @@ macro(CHECK_Fortran_SOURCE_RUNS SOURCE VAR) if("${${VAR}_EXITCODE}" EQUAL 0) set(${VAR} 1 CACHE INTERNAL "Test ${VAR}") if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Performing Test ${VAR} - Success") + message(CHECK_PASS "Success") endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Performing Fortran SOURCE FILE Test ${VAR} succeeded with the following output:\n" @@ -161,7 +161,7 @@ macro(CHECK_Fortran_SOURCE_RUNS SOURCE VAR) endif() if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Performing Test ${VAR} - Failed") + message(CHECK_FAIL "Failed") endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Performing Fortran SOURCE FILE Test ${VAR} failed with the following output:\n" diff --git a/Modules/CheckFunctionExists.cmake b/Modules/CheckFunctionExists.cmake index c39144f..136da89 100644 --- a/Modules/CheckFunctionExists.cmake +++ b/Modules/CheckFunctionExists.cmake @@ -57,7 +57,7 @@ macro(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE) set(MACRO_CHECK_FUNCTION_DEFINITIONS "-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}") if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Looking for ${FUNCTION}") + message(CHECK_START "Looking for ${FUNCTION}") endif() if(CMAKE_REQUIRED_LINK_OPTIONS) set(CHECK_FUNCTION_EXISTS_ADD_LINK_OPTIONS @@ -101,14 +101,14 @@ macro(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE) if(${VARIABLE}) set(${VARIABLE} 1 CACHE INTERNAL "Have function ${FUNCTION}") if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Looking for ${FUNCTION} - found") + message(CHECK_PASS "found") endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the function ${FUNCTION} exists passed with the following output:\n" "${OUTPUT}\n\n") else() if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Looking for ${FUNCTION} - not found") + message(CHECK_FAIL "not found") endif() set(${VARIABLE} "" CACHE INTERNAL "Have function ${FUNCTION}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log diff --git a/Modules/CheckIncludeFile.cmake b/Modules/CheckIncludeFile.cmake index d7b9481..3a10473 100644 --- a/Modules/CheckIncludeFile.cmake +++ b/Modules/CheckIncludeFile.cmake @@ -55,7 +55,7 @@ macro(CHECK_INCLUDE_FILE INCLUDE VARIABLE) configure_file(${CMAKE_ROOT}/Modules/CheckIncludeFile.c.in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.c) if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Looking for ${INCLUDE}") + message(CHECK_START "Looking for ${INCLUDE}") endif() if(${ARGC} EQUAL 3) set(CMAKE_C_FLAGS_SAVE ${CMAKE_C_FLAGS}) @@ -109,7 +109,7 @@ macro(CHECK_INCLUDE_FILE INCLUDE VARIABLE) if(${VARIABLE}) if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Looking for ${INCLUDE} - found") + message(CHECK_PASS "found") endif() set(${VARIABLE} 1 CACHE INTERNAL "Have include ${INCLUDE}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log @@ -118,7 +118,7 @@ macro(CHECK_INCLUDE_FILE INCLUDE VARIABLE) "${OUTPUT}\n\n") else() if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Looking for ${INCLUDE} - not found") + message(CHECK_FAIL "not found") endif() set(${VARIABLE} "" CACHE INTERNAL "Have include ${INCLUDE}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log diff --git a/Modules/CheckIncludeFileCXX.cmake b/Modules/CheckIncludeFileCXX.cmake index de5a83b..496550f 100644 --- a/Modules/CheckIncludeFileCXX.cmake +++ b/Modules/CheckIncludeFileCXX.cmake @@ -54,7 +54,7 @@ macro(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE) configure_file(${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx) if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Looking for C++ include ${INCLUDE}") + message(CHECK_START "Looking for C++ include ${INCLUDE}") endif() if(${ARGC} EQUAL 3) set(CMAKE_CXX_FLAGS_SAVE ${CMAKE_CXX_FLAGS}) @@ -108,7 +108,7 @@ macro(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE) if(${VARIABLE}) if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Looking for C++ include ${INCLUDE} - found") + message(CHECK_PASS "found") endif() set(${VARIABLE} 1 CACHE INTERNAL "Have include ${INCLUDE}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log @@ -117,7 +117,7 @@ macro(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE) "${OUTPUT}\n\n") else() if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Looking for C++ include ${INCLUDE} - not found") + message(CHECK_FAIL "not found") endif() set(${VARIABLE} "" CACHE INTERNAL "Have include ${INCLUDE}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log diff --git a/Modules/CheckIncludeFiles.cmake b/Modules/CheckIncludeFiles.cmake index f52ab55..8e10cd6 100644 --- a/Modules/CheckIncludeFiles.cmake +++ b/Modules/CheckIncludeFiles.cmake @@ -131,7 +131,7 @@ macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE) endif() if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Looking for ${_description}") + message(CHECK_START "Looking for ${_description}") endif() try_compile(${VARIABLE} ${CMAKE_BINARY_DIR} @@ -147,7 +147,7 @@ macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE) unset(_CIF_LINK_LIBRARIES) if(${VARIABLE}) if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Looking for ${_description} - found") + message(CHECK_PASS "found") endif() set(${VARIABLE} 1 CACHE INTERNAL "Have include ${INCLUDE}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log @@ -156,7 +156,7 @@ macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE) "${OUTPUT}\n\n") else() if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Looking for ${_description} - not found") + message(CHECK_FAIL "not found") endif() set(${VARIABLE} "" CACHE INTERNAL "Have includes ${INCLUDE}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log diff --git a/Modules/CheckLanguage.cmake b/Modules/CheckLanguage.cmake index a1a3a7a..997cc8d 100644 --- a/Modules/CheckLanguage.cmake +++ b/Modules/CheckLanguage.cmake @@ -39,7 +39,7 @@ include_guard(GLOBAL) macro(check_language lang) if(NOT DEFINED CMAKE_${lang}_COMPILER) set(_desc "Looking for a ${lang} compiler") - message(STATUS ${_desc}) + message(CHECK_START "${_desc}") file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Check${lang}) set(extra_compiler_variables) @@ -63,12 +63,18 @@ file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\" else() set(_D_CMAKE_GENERATOR_INSTANCE "") endif() + if(CMAKE_GENERATOR MATCHES "^(Xcode$|Green Hills MULTI$|Visual Studio)") + set(_D_CMAKE_MAKE_PROGRAM "") + else() + set(_D_CMAKE_MAKE_PROGRAM "-DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_MAKE_PROGRAM}") + endif() execute_process( WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Check${lang} COMMAND ${CMAKE_COMMAND} . -G ${CMAKE_GENERATOR} -A "${CMAKE_GENERATOR_PLATFORM}" -T "${CMAKE_GENERATOR_TOOLSET}" ${_D_CMAKE_GENERATOR_INSTANCE} + ${_D_CMAKE_MAKE_PROGRAM} OUTPUT_VARIABLE output ERROR_VARIABLE output RESULT_VARIABLE result @@ -78,13 +84,15 @@ file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\" file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "${_desc} passed with the following output:\n" "${output}\n") + set(_CHECK_COMPILER_STATUS CHECK_PASS) else() set(CMAKE_${lang}_COMPILER NOTFOUND) + set(_CHECK_COMPILER_STATUS CHECK_FAIL) file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "${_desc} failed with the following output:\n" "${output}\n") endif() - message(STATUS "${_desc} - ${CMAKE_${lang}_COMPILER}") + message(${_CHECK_COMPILER_STATUS} "${CMAKE_${lang}_COMPILER}") set(CMAKE_${lang}_COMPILER "${CMAKE_${lang}_COMPILER}" CACHE FILEPATH "${lang} compiler") mark_as_advanced(CMAKE_${lang}_COMPILER) diff --git a/Modules/CheckLibraryExists.cmake b/Modules/CheckLibraryExists.cmake index 6504df5..6470dfd 100644 --- a/Modules/CheckLibraryExists.cmake +++ b/Modules/CheckLibraryExists.cmake @@ -42,7 +42,7 @@ macro(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE) set(MACRO_CHECK_LIBRARY_EXISTS_DEFINITION "-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}") if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Looking for ${FUNCTION} in ${LIBRARY}") + message(CHECK_START "Looking for ${FUNCTION} in ${LIBRARY}") endif() set(CHECK_LIBRARY_EXISTS_LINK_OPTIONS) if(CMAKE_REQUIRED_LINK_OPTIONS) @@ -78,7 +78,7 @@ macro(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE) if(${VARIABLE}) if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - found") + message(CHECK_PASS "found") endif() set(${VARIABLE} 1 CACHE INTERNAL "Have library ${LIBRARY}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log @@ -87,7 +87,7 @@ macro(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE) "${OUTPUT}\n\n") else() if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - not found") + message(CHECK_FAIL "not found") endif() set(${VARIABLE} "" CACHE INTERNAL "Have library ${LIBRARY}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log diff --git a/Modules/CheckOBJCSourceCompiles.cmake b/Modules/CheckOBJCSourceCompiles.cmake index a4676ad..601f1fa 100644 --- a/Modules/CheckOBJCSourceCompiles.cmake +++ b/Modules/CheckOBJCSourceCompiles.cmake @@ -104,7 +104,7 @@ macro(CHECK_OBJC_SOURCE_COMPILES SOURCE VAR) "${SOURCE}\n") if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Performing Test ${VAR}") + message(CHECK_START "Performing Test ${VAR}") endif() try_compile(${VAR} ${CMAKE_BINARY_DIR} @@ -125,7 +125,7 @@ macro(CHECK_OBJC_SOURCE_COMPILES SOURCE VAR) if(${VAR}) set(${VAR} 1 CACHE INTERNAL "Test ${VAR}") if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Performing Test ${VAR} - Success") + message(CHECK_PASS "Success") endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Performing Objective-C SOURCE FILE Test ${VAR} succeeded with the following output:\n" @@ -133,7 +133,7 @@ macro(CHECK_OBJC_SOURCE_COMPILES SOURCE VAR) "Source file was:\n${SOURCE}\n") else() if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Performing Test ${VAR} - Failed") + message(CHECK_FAIL "Failed") endif() set(${VAR} "" CACHE INTERNAL "Test ${VAR}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log diff --git a/Modules/CheckOBJCSourceRuns.cmake b/Modules/CheckOBJCSourceRuns.cmake index 00a1ebd..6684693 100644 --- a/Modules/CheckOBJCSourceRuns.cmake +++ b/Modules/CheckOBJCSourceRuns.cmake @@ -92,7 +92,7 @@ macro(CHECK_OBJC_SOURCE_RUNS SOURCE VAR) "${SOURCE}\n") if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Performing Test ${VAR}") + message(CHECK_START "Performing Test ${VAR}") endif() try_run(${VAR}_EXITCODE ${VAR}_COMPILED ${CMAKE_BINARY_DIR} @@ -113,7 +113,7 @@ macro(CHECK_OBJC_SOURCE_RUNS SOURCE VAR) if("${${VAR}_EXITCODE}" EQUAL 0) set(${VAR} 1 CACHE INTERNAL "Test ${VAR}") if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Performing Test ${VAR} - Success") + message(CHECK_PASS "Success") endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Performing Objective-C SOURCE FILE Test ${VAR} succeeded with the following compile output:\n" @@ -130,7 +130,7 @@ macro(CHECK_OBJC_SOURCE_RUNS SOURCE VAR) endif() if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Performing Test ${VAR} - Failed") + message(CHECK_FAIL "Failed") endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Performing Objective-C SOURCE FILE Test ${VAR} failed with the following compile output:\n" diff --git a/Modules/CheckOBJCXXSourceCompiles.cmake b/Modules/CheckOBJCXXSourceCompiles.cmake index 4c0fdd0..2ee79f4 100644 --- a/Modules/CheckOBJCXXSourceCompiles.cmake +++ b/Modules/CheckOBJCXXSourceCompiles.cmake @@ -105,7 +105,7 @@ macro(CHECK_OBJCXX_SOURCE_COMPILES SOURCE VAR) "${SOURCE}\n") if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Performing Test ${VAR}") + message(CHECK_START "Performing Test ${VAR}") endif() try_compile(${VAR} ${CMAKE_BINARY_DIR} @@ -126,7 +126,7 @@ macro(CHECK_OBJCXX_SOURCE_COMPILES SOURCE VAR) if(${VAR}) set(${VAR} 1 CACHE INTERNAL "Test ${VAR}") if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Performing Test ${VAR} - Success") + message(CHECK_PASS "Success") endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Performing Objective-C++ SOURCE FILE Test ${VAR} succeeded with the following output:\n" @@ -134,7 +134,7 @@ macro(CHECK_OBJCXX_SOURCE_COMPILES SOURCE VAR) "Source file was:\n${SOURCE}\n") else() if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Performing Test ${VAR} - Failed") + message(CHECK_FAIL "Failed") endif() set(${VAR} "" CACHE INTERNAL "Test ${VAR}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log diff --git a/Modules/CheckOBJCXXSourceRuns.cmake b/Modules/CheckOBJCXXSourceRuns.cmake index a3d5923..7f7e04f 100644 --- a/Modules/CheckOBJCXXSourceRuns.cmake +++ b/Modules/CheckOBJCXXSourceRuns.cmake @@ -92,7 +92,7 @@ macro(CHECK_OBJCXX_SOURCE_RUNS SOURCE VAR) "${SOURCE}\n") if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Performing Test ${VAR}") + message(CHECK_START "Performing Test ${VAR}") endif() try_run(${VAR}_EXITCODE ${VAR}_COMPILED ${CMAKE_BINARY_DIR} @@ -114,7 +114,7 @@ macro(CHECK_OBJCXX_SOURCE_RUNS SOURCE VAR) if("${${VAR}_EXITCODE}" EQUAL 0) set(${VAR} 1 CACHE INTERNAL "Test ${VAR}") if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Performing Test ${VAR} - Success") + message(CHECK_PASS "Success") endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Performing Objective-C++ SOURCE FILE Test ${VAR} succeeded with the following output:\n" @@ -131,7 +131,7 @@ macro(CHECK_OBJCXX_SOURCE_RUNS SOURCE VAR) endif() if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Performing Test ${VAR} - Failed") + message(CHECK_FAIL "Failed") endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Performing Objective-C++ SOURCE FILE Test ${VAR} failed with the following output:\n" diff --git a/Modules/CheckPrototypeDefinition.cmake b/Modules/CheckPrototypeDefinition.cmake index a7b020c..8b06403 100644 --- a/Modules/CheckPrototypeDefinition.cmake +++ b/Modules/CheckPrototypeDefinition.cmake @@ -54,6 +54,9 @@ include_guard(GLOBAL) function(check_prototype_definition _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIABLE) if (NOT DEFINED ${_VARIABLE}) + if(NOT CMAKE_REQUIRED_QUIET) + message(CHECK_START "Checking prototype ${_FUNCTION} for ${_VARIABLE}") + endif() set(CHECK_PROTOTYPE_DEFINITION_CONTENT "/* */\n") set(CHECK_PROTOTYPE_DEFINITION_FLAGS ${CMAKE_REQUIRED_FLAGS}) @@ -103,14 +106,14 @@ function(check_prototype_definition _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIAB if (${_VARIABLE}) set(${_VARIABLE} 1 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}") if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - True") + message(CHECK_PASS "True") endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} passed with the following output:\n" "${OUTPUT}\n\n") else () if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - False") + message(CHECK_FAIL "False") endif() set(${_VARIABLE} 0 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log diff --git a/Modules/CheckSymbolExists.cmake b/Modules/CheckSymbolExists.cmake index 1053383..4f202c4 100644 --- a/Modules/CheckSymbolExists.cmake +++ b/Modules/CheckSymbolExists.cmake @@ -126,7 +126,7 @@ int main(int argc, char** argv) "${SOURCEFILE}" @ONLY) if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Looking for ${SYMBOL}") + message(CHECK_START "Looking for ${SYMBOL}") endif() try_compile(${VARIABLE} ${CMAKE_BINARY_DIR} @@ -140,7 +140,7 @@ int main(int argc, char** argv) OUTPUT_VARIABLE OUTPUT) if(${VARIABLE}) if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Looking for ${SYMBOL} - found") + message(CHECK_PASS "found") endif() set(${VARIABLE} 1 CACHE INTERNAL "Have symbol ${SYMBOL}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log @@ -150,7 +150,7 @@ int main(int argc, char** argv) "${CMAKE_CONFIGURABLE_FILE_CONTENT}\n") else() if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Looking for ${SYMBOL} - not found") + message(CHECK_FAIL "not found") endif() set(${VARIABLE} "" CACHE INTERNAL "Have symbol ${SYMBOL}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log diff --git a/Modules/CheckTypeSize.cmake b/Modules/CheckTypeSize.cmake index 3727373..2b07b7c 100644 --- a/Modules/CheckTypeSize.cmake +++ b/Modules/CheckTypeSize.cmake @@ -86,7 +86,7 @@ cmake_policy(SET CMP0054 NEW) # Helper function. DO NOT CALL DIRECTLY. function(__check_type_size_impl type var map builtin language) if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Check size of ${type}") + message(CHECK_START "Check size of ${type}") endif() # Include header files. @@ -173,7 +173,7 @@ function(__check_type_size_impl type var map builtin language) endif() if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Check size of ${type} - done") + message(CHECK_PASS "done") endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining size of ${type} passed with the following output:\n${output}\n\n") @@ -181,7 +181,7 @@ function(__check_type_size_impl type var map builtin language) else() # The check failed to compile. if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Check size of ${type} - failed") + message(CHECK_FAIL "failed") endif() file(READ ${src} content) file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log diff --git a/Modules/CheckVariableExists.cmake b/Modules/CheckVariableExists.cmake index f4953a3..8a93535 100644 --- a/Modules/CheckVariableExists.cmake +++ b/Modules/CheckVariableExists.cmake @@ -42,7 +42,7 @@ macro(CHECK_VARIABLE_EXISTS VAR VARIABLE) set(MACRO_CHECK_VARIABLE_DEFINITIONS "-DCHECK_VARIABLE_EXISTS=${VAR} ${CMAKE_REQUIRED_FLAGS}") if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Looking for ${VAR}") + message(CHECK_START "Looking for ${VAR}") endif() if(CMAKE_REQUIRED_LINK_OPTIONS) set(CHECK_VARIABLE_EXISTS_ADD_LINK_OPTIONS @@ -67,7 +67,7 @@ macro(CHECK_VARIABLE_EXISTS VAR VARIABLE) if(${VARIABLE}) set(${VARIABLE} 1 CACHE INTERNAL "Have variable ${VAR}") if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Looking for ${VAR} - found") + message(CHECK_PASS "found") endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the variable ${VAR} exists passed with the following output:\n" @@ -75,7 +75,7 @@ macro(CHECK_VARIABLE_EXISTS VAR VARIABLE) else() set(${VARIABLE} "" CACHE INTERNAL "Have variable ${VAR}") if(NOT CMAKE_REQUIRED_QUIET) - message(STATUS "Looking for ${VAR} - not found") + message(CHECK_FAIL "not found") endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the variable ${VAR} exists failed with the following output:\n" diff --git a/Modules/Compiler/CMakeCommonCompilerMacros.cmake b/Modules/Compiler/CMakeCommonCompilerMacros.cmake index 96537f8..409b65a 100644 --- a/Modules/Compiler/CMakeCommonCompilerMacros.cmake +++ b/Modules/Compiler/CMakeCommonCompilerMacros.cmake @@ -134,3 +134,47 @@ macro(cmake_record_cxx_compile_features) unset(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT) endif() endmacro() + +macro(cmake_record_cuda_compile_features) + set(_result 0) + if(_result EQUAL 0 AND DEFINED CMAKE_CUDA20_STANDARD_COMPILE_OPTION) + if(CMAKE_CUDA20_STANDARD__HAS_FULL_SUPPORT) + _has_compiler_features_cuda(20) + else() + _record_compiler_features_cuda(20) + endif() + unset(CMAKE_CUDA20_STANDARD__HAS_FULL_SUPPORT) + endif() + if(_result EQUAL 0 AND DEFINED CMAKE_CUDA17_STANDARD_COMPILE_OPTION) + if(CMAKE_CUDA17_STANDARD__HAS_FULL_SUPPORT) + _has_compiler_features_cuda(17) + else() + _record_compiler_features_cuda(17) + endif() + unset(CMAKE_CUDA17_STANDARD__HAS_FULL_SUPPORT) + endif() + if(_result EQUAL 0 AND DEFINED CMAKE_CUDA14_STANDARD_COMPILE_OPTION) + if(CMAKE_CUDA14_STANDARD__HAS_FULL_SUPPORT) + _has_compiler_features_cuda(14) + else() + _record_compiler_features_cuda(14) + endif() + unset(CMAKE_CUDA14_STANDARD__HAS_FULL_SUPPORT) + endif() + if(_result EQUAL 0 AND DEFINED CMAKE_CUDA11_STANDARD_COMPILE_OPTION) + if(CMAKE_CUDA11_STANDARD__HAS_FULL_SUPPORT) + _has_compiler_features_cuda(11) + else() + _record_compiler_features_cuda(11) + endif() + unset(CMAKE_CUDA11_STANDARD__HAS_FULL_SUPPORT) + endif() + if(_result EQUAL 0 AND DEFINED CMAKE_CUDA03_STANDARD_COMPILE_OPTION) + if(CMAKE_CUDA03_STANDARD__HAS_FULL_SUPPORT) + _has_compiler_features_cuda(03) + else() + _record_compiler_features_cuda(03) + endif() + unset(CMAKE_CUDA03_STANDARD__HAS_FULL_SUPPORT) + endif() +endmacro() diff --git a/Modules/Compiler/Clang-C.cmake b/Modules/Compiler/Clang-C.cmake index 0448965..7c4a263 100644 --- a/Modules/Compiler/Clang-C.cmake +++ b/Modules/Compiler/Clang-C.cmake @@ -6,6 +6,10 @@ if(APPLE AND NOT appleClangPolicy STREQUAL NEW) return() endif() +if("x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC") + set(CMAKE_C_CLANG_TIDY_DRIVER_MODE "cl") +endif() + if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4) if(NOT "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC") set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90") diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake index 61709f8..cb240f9 100644 --- a/Modules/Compiler/Clang-CXX.cmake +++ b/Modules/Compiler/Clang-CXX.cmake @@ -10,6 +10,9 @@ if(APPLE AND NOT appleClangPolicy STREQUAL NEW) return() endif() +if("x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC") + set(CMAKE_CXX_CLANG_TIDY_DRIVER_MODE "cl") +endif() if("x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU") if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2.1) diff --git a/Modules/Compiler/Intel-C.cmake b/Modules/Compiler/Intel-C.cmake index e9e59a2..ec3bfd8 100644 --- a/Modules/Compiler/Intel-C.cmake +++ b/Modules/Compiler/Intel-C.cmake @@ -9,6 +9,8 @@ set(CMAKE_DEPFILE_FLAGS_C "-MD -MT <OBJECT> -MF <DEPFILE>") if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC") + set(CMAKE_C_CLANG_TIDY_DRIVER_MODE "cl") + if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 16.0.0) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-Qstd=c11") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-Qstd=c11") diff --git a/Modules/Compiler/Intel-CXX.cmake b/Modules/Compiler/Intel-CXX.cmake index b630a6b..1ed1b08 100644 --- a/Modules/Compiler/Intel-CXX.cmake +++ b/Modules/Compiler/Intel-CXX.cmake @@ -9,6 +9,8 @@ set(CMAKE_DEPFILE_FLAGS_CXX "-MD -MT <OBJECT> -MF <DEPFILE>") if("x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") + set(CMAKE_CXX_CLANG_TIDY_DRIVER_MODE "cl") + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0.0) set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-Qstd=c++17") set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-Qstd=c++17") diff --git a/Modules/Compiler/MSVC-C.cmake b/Modules/Compiler/MSVC-C.cmake index 20787a3..bca9764 100644 --- a/Modules/Compiler/MSVC-C.cmake +++ b/Modules/Compiler/MSVC-C.cmake @@ -11,6 +11,8 @@ set(CMAKE_C11_EXTENSION_COMPILE_OPTION "") # There is no meaningful default for this set(CMAKE_C_STANDARD_DEFAULT "") +set(CMAKE_C_CLANG_TIDY_DRIVER_MODE "cl") + # There are no C compiler modes so we hard-code the known compiler supported # features. Override the default macro for this special case. Pretend that # all language standards are available so that at least compilation diff --git a/Modules/Compiler/MSVC-CXX.cmake b/Modules/Compiler/MSVC-CXX.cmake index 915295d..1dfc760 100644 --- a/Modules/Compiler/MSVC-CXX.cmake +++ b/Modules/Compiler/MSVC-CXX.cmake @@ -3,6 +3,8 @@ include(Compiler/CMakeCommonCompilerMacros) +set(CMAKE_CXX_CLANG_TIDY_DRIVER_MODE "cl") + if ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.0.24215.1 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.10) OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.10.25017) diff --git a/Modules/Compiler/NAG-Fortran.cmake b/Modules/Compiler/NAG-Fortran.cmake index edc56fd..2111c65 100644 --- a/Modules/Compiler/NAG-Fortran.cmake +++ b/Modules/Compiler/NAG-Fortran.cmake @@ -1,6 +1,6 @@ # Help CMAKE_PARSE_IMPLICIT_LINK_INFO detect NAG Fortran object files. if(NOT CMAKE_Fortran_COMPILER_WORKS AND NOT CMAKE_Fortran_COMPILER_FORCED) - message(STATUS "Detecting NAG Fortran directory") + message(CHECK_START "Detecting NAG Fortran directory") # Run with -dryrun to see sample "link" line. execute_process( COMMAND ${CMAKE_Fortran_COMPILER} dummy.o -dryrun @@ -20,11 +20,11 @@ if(NOT CMAKE_Fortran_COMPILER_WORKS AND NOT CMAKE_Fortran_COMPILER_FORCED) " directory: ${_nag_dir}\n" " regex: ${CMAKE_Fortran_IMPLICIT_OBJECT_REGEX}\n" "from output:\n${_dryrun}\n\n") - message(STATUS "Detecting NAG Fortran directory - ${_nag_dir}") + message(CHECK_PASS "${_nag_dir}") else() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Detecting NAG Fortran directory with -dryrun failed:\n${_dryrun}\n\n") - message(STATUS "Detecting NAG Fortran directory - failed") + message(CHECK_FAIL "failed") endif() endif() diff --git a/Modules/Compiler/NVIDIA-CUDA.cmake b/Modules/Compiler/NVIDIA-CUDA.cmake index b59deda..a786fb9 100644 --- a/Modules/Compiler/NVIDIA-CUDA.cmake +++ b/Modules/Compiler/NVIDIA-CUDA.cmake @@ -1,7 +1,32 @@ +include(Compiler/CMakeCommonCompilerMacros) + set(CMAKE_CUDA_COMPILER_HAS_DEVICE_LINK_PHASE True) set(CMAKE_CUDA_VERBOSE_FLAG "-v") set(CMAKE_CUDA_VERBOSE_COMPILE_FLAG "-Xcompiler=-v") +if (CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 10.2.89) + # The -forward-unknown-to-host-compiler flag was only + # added to nvcc in 10.2 so before that we had no good + # way to invoke the CUDA compiler and propagate unknown + # flags such as -pthread to the host compiler + set(_CMAKE_CUDA_EXTRA_FLAGS "-forward-unknown-to-host-compiler") +else() + set(_CMAKE_CUDA_EXTRA_FLAGS "") +endif() + +if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "8.0.0") + set(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS "-Wno-deprecated-gpu-targets") +else() + set(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS "") +endif() + +if (CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 10.2.89) + # The -MD flag was only added to nvcc in 10.2 so + # before that we had to invoke the compiler twice + # to get header dependency information + set(CMAKE_DEPFILE_FLAGS_CUDA "-MD -MT <OBJECT> -MF <DEPFILE>") +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) @@ -18,18 +43,32 @@ endif() set(CMAKE_SHARED_LIBRARY_CREATE_CUDA_FLAGS -shared) set(CMAKE_INCLUDE_SYSTEM_FLAG_CUDA -isystem=) +set(CMAKE_CUDA_RUNTIME_LIBRARY_DEFAULT "STATIC") +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 "") + if("x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC") - set(CMAKE_CUDA_STANDARD_DEFAULT "") + set(CMAKE_CUDA03_STANDARD_COMPILE_OPTION "") + set(CMAKE_CUDA03_EXTENSION_COMPILE_OPTION "") + + set(CMAKE_CUDA11_STANDARD_COMPILE_OPTION "") + set(CMAKE_CUDA11_EXTENSION_COMPILE_OPTION "") + + if (NOT CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 9.0) + set(CMAKE_CUDA14_STANDARD_COMPILE_OPTION "") + set(CMAKE_CUDA14_EXTENSION_COMPILE_OPTION "") + endif() else() - set(CMAKE_CUDA_STANDARD_DEFAULT 98) - set(CMAKE_CUDA98_STANDARD_COMPILE_OPTION "") - set(CMAKE_CUDA98_EXTENSION_COMPILE_OPTION "") + set(CMAKE_CUDA03_STANDARD_COMPILE_OPTION "") + set(CMAKE_CUDA03_EXTENSION_COMPILE_OPTION "") + set(CMAKE_CUDA11_STANDARD_COMPILE_OPTION "-std=c++11") set(CMAKE_CUDA11_EXTENSION_COMPILE_OPTION "-std=c++11") if (NOT CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 9.0) - set(CMAKE_CUDA98_STANDARD_COMPILE_OPTION "-std=c++03") - set(CMAKE_CUDA98_EXTENSION_COMPILE_OPTION "-std=c++03") + set(CMAKE_CUDA03_STANDARD_COMPILE_OPTION "-std=c++03") + set(CMAKE_CUDA03_EXTENSION_COMPILE_OPTION "-std=c++03") set(CMAKE_CUDA14_STANDARD_COMPILE_OPTION "-std=c++14") set(CMAKE_CUDA14_EXTENSION_COMPILE_OPTION "-std=c++14") endif() @@ -46,3 +85,5 @@ if (CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "9.0") set(CMAKE_CUDA_RESPONSE_FILE_LINK_FLAG "--options-file ") set(CMAKE_CUDA_RESPONSE_FILE_FLAG "--options-file ") endif() + +__compiler_check_default_language_standard(CUDA 6.0 03) diff --git a/Modules/Compiler/QCC.cmake b/Modules/Compiler/QCC.cmake index 9df8269..10e1389 100644 --- a/Modules/Compiler/QCC.cmake +++ b/Modules/Compiler/QCC.cmake @@ -10,6 +10,9 @@ macro(__compiler_qcc lang) # http://www.qnx.com/developers/docs/6.4.0/neutrino/utilities/q/qcc.html#examples set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "-V") + set(CMAKE_PREFIX_LIBRARY_ARCHITECTURE "ON") + + set(CMAKE_${lang}_COMPILE_OPTIONS_SYSROOT "-Wc,-isysroot,") set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-Wp,-isystem,") set(CMAKE_DEPFILE_FLAGS_${lang} "-Wp,-MD,<DEPFILE> -Wp,-MT,<OBJECT> -Wp,-MF,<DEPFILE>") diff --git a/Modules/Compiler/XL-Fortran.cmake b/Modules/Compiler/XL-Fortran.cmake index c4fb097..1683dff 100644 --- a/Modules/Compiler/XL-Fortran.cmake +++ b/Modules/Compiler/XL-Fortran.cmake @@ -18,3 +18,7 @@ string(APPEND CMAKE_Fortran_FLAGS_INIT " -qthreaded -qhalt=e") # xlf: 1501-214 (W) command option E reserved for future use - ignored set(CMAKE_Fortran_CREATE_PREPROCESSED_SOURCE) set(CMAKE_Fortran_CREATE_ASSEMBLY_SOURCE) + +set(CMAKE_Fortran_PREPROCESS_SOURCE + "<CMAKE_Fortran_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -qpreprocess -qnoobject -qsuppress=1517-020 -tF -B \"${CMAKE_CURRENT_LIST_DIR}/XL-Fortran/\" -WF,--cpp,\"${CMAKE_Fortran_XL_CPP}\",--out,<PREPROCESSED_SOURCE> <SOURCE>" + ) diff --git a/Modules/Compiler/XL-Fortran/cpp b/Modules/Compiler/XL-Fortran/cpp new file mode 100755 index 0000000..1fd62c2 --- /dev/null +++ b/Modules/Compiler/XL-Fortran/cpp @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +# Source file. +src="$(printf %q "$1")" +shift + +# Output file the compiler expects. +out="$(printf %q "$1")" +shift + +# Create the file the compiler expects. It will check syntax. +>"$out" + +cpp='cpp' +opts='' +while test "$#" != 0; do + case "$1" in + # Extract the option for the path to cpp. + --cpp) shift; cpp="$(printf %q "$1")" ;; + # Extract the option for our own output file. + --out) shift; out="$(printf %q "$1")" ;; + # Collect the rest of the command line. + *) opts="$opts $(printf %q "$1")" ;; + esac + shift +done + +# Execute the real preprocessor tool. +eval "exec $cpp $src $out $opts" diff --git a/Modules/CompilerId/VS-10.vcxproj.in b/Modules/CompilerId/VS-10.vcxproj.in index d742274..b48a332 100644 --- a/Modules/CompilerId/VS-10.vcxproj.in +++ b/Modules/CompilerId/VS-10.vcxproj.in @@ -15,6 +15,8 @@ @id_WindowsTargetPlatformVersion@ @id_WindowsSDKDesktopARMSupport@ @id_CudaToolkitCustomDir@ + @id_ToolsetVCTargetsDir@ + @id_CustomGlobals@ </PropertyGroup> @id_toolset_version_props@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> diff --git a/Modules/DartConfiguration.tcl.in b/Modules/DartConfiguration.tcl.in index e4513b3..086ba07 100644 --- a/Modules/DartConfiguration.tcl.in +++ b/Modules/DartConfiguration.tcl.in @@ -69,6 +69,8 @@ CompilerVersion: @CMAKE_CXX_COMPILER_VERSION@ PurifyCommand: @PURIFYCOMMAND@ ValgrindCommand: @VALGRIND_COMMAND@ ValgrindCommandOptions: @VALGRIND_COMMAND_OPTIONS@ +DrMemoryCommand: @DRMEMORY_COMMAND@ +DrMemoryCommandOptions: @DRMEMORY_COMMAND_OPTIONS@ MemoryCheckType: @MEMORYCHECK_TYPE@ MemoryCheckSanitizerOptions: @MEMORYCHECK_SANITIZER_OPTIONS@ MemoryCheckCommand: @MEMORYCHECK_COMMAND@ diff --git a/Modules/DeployQt4.cmake b/Modules/DeployQt4.cmake index 4a18927..9aa4383 100644 --- a/Modules/DeployQt4.cmake +++ b/Modules/DeployQt4.cmake @@ -106,7 +106,6 @@ and plugin installation. See documentation of FIXUP_QT4_BUNDLE. # The functions defined in this file depend on the fixup_bundle function # (and others) found in BundleUtilities.cmake -set(DeployQt4_cmake_dir "${CMAKE_CURRENT_LIST_DIR}") set(DeployQt4_apple_plugins_dir "PlugIns") function(write_qt4_conf qt_conf_dir qt_conf_contents) @@ -392,7 +391,7 @@ function(install_qt4_executable executable) resolve_qt4_paths(libs "") install(CODE -"include(\"${DeployQt4_cmake_dir}/DeployQt4.cmake\") +"include(\"${CMAKE_CURRENT_FUNCTION_LIST_DIR}/DeployQt4.cmake\") set(BU_CHMOD_BUNDLE_ITEMS TRUE) FIXUP_QT4_EXECUTABLE(\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${executable}\" \"\" \"${libs}\" \"${dirs}\" \"${plugins_dir}\" \"${request_qt_conf}\")" ${component} diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 66061a1..db3716a 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -265,6 +265,11 @@ External Project Definition is set to ``NEW`` if this value is set to an empty string then no submodules are initialized or updated. + ``GIT_SUBMODULES_RECURSE <bool>`` + Specify whether git submodules (if any) should update recursively by + passing the ``--recursive`` flag to ``git submodule update``. + If not specified, the default is on. + ``GIT_SHALLOW <bool>`` When this option is enabled, the ``git clone`` operation will be given the ``--depth 1`` option. This performs a shallow clone, which avoids @@ -1065,7 +1070,7 @@ define_property(DIRECTORY PROPERTY "EP_UPDATE_DISCONNECTED" INHERITED "ExternalProject module." ) -function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag git_remote_name init_submodules git_submodules git_shallow git_progress git_config src_name work_dir gitclone_infofile gitclone_stampfile tls_verify) +function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag git_remote_name init_submodules git_submodules_recurse git_submodules git_shallow git_progress git_config src_name work_dir gitclone_infofile gitclone_stampfile tls_verify) if(NOT GIT_VERSION_STRING VERSION_LESS 1.8.5) # Use `git checkout <tree-ish> --` to avoid ambiguity with a local path. set(git_checkout_explicit-- "--") @@ -1115,7 +1120,7 @@ if(NOT \"${gitclone_infofile}\" IS_NEWER_THAN \"${gitclone_stampfile}\") endif() execute_process( - COMMAND \${CMAKE_COMMAND} -E remove_directory \"${source_dir}\" + COMMAND \${CMAKE_COMMAND} -E rm -rf \"${source_dir}\" RESULT_VARIABLE error_code ) if(error_code) @@ -1153,7 +1158,7 @@ endif() set(init_submodules ${init_submodules}) if(init_submodules) execute_process( - COMMAND \"${git_EXECUTABLE}\" ${git_options} submodule update --recursive --init ${git_submodules} + COMMAND \"${git_EXECUTABLE}\" ${git_options} submodule update ${git_submodules_recurse} --init ${git_submodules} WORKING_DIRECTORY \"${work_dir}/${src_name}\" RESULT_VARIABLE error_code ) @@ -1191,7 +1196,7 @@ if(NOT \"${hgclone_infofile}\" IS_NEWER_THAN \"${hgclone_stampfile}\") endif() execute_process( - COMMAND \${CMAKE_COMMAND} -E remove_directory \"${source_dir}\" + COMMAND \${CMAKE_COMMAND} -E rm -rf \"${source_dir}\" RESULT_VARIABLE error_code ) if(error_code) @@ -1394,7 +1399,7 @@ if(error_code OR is_remote_ref OR NOT (\"\${tag_sha}\" STREQUAL \"\${head_sha}\" set(init_submodules ${init_submodules}) if(init_submodules) execute_process( - COMMAND \"${git_EXECUTABLE}\" submodule update --recursive --init ${git_submodules} + COMMAND \"${git_EXECUTABLE}\" submodule update ${git_submodules_recurse} --init ${git_submodules} WORKING_DIRECTORY \"${work_dir}/${src_name}\" RESULT_VARIABLE error_code ) @@ -1772,6 +1777,11 @@ function(_ep_write_initial_cache target_name script_filename script_initial_cach # Replace location tags. _ep_replace_location_tags(${target_name} script_initial_cache) _ep_replace_location_tags(${target_name} script_filename) + # Replace list separators. + get_property(sep TARGET ${target_name} PROPERTY _EP_LIST_SEPARATOR) + if(sep AND script_initial_cache) + string(REPLACE "${sep}" ";" script_initial_cache "${script_initial_cache}") + endif() # Write out the initial cache file to the location specified. file(GENERATE OUTPUT "${script_filename}" CONTENT "${script_initial_cache}") endfunction() @@ -2421,9 +2431,21 @@ function(_ep_add_download_command name) message(FATAL_ERROR "error: could not find git for clone of ${name}") endif() + get_property(git_submodules_recurse_set TARGET ${name} PROPERTY _EP_GIT_SUBMODULES_RECURSE SET) + if(NOT git_submodules_recurse_set) + set(git_submodules_recurse "--recursive") + else() + get_property(git_submodules_recurse_value TARGET ${name} PROPERTY _EP_GIT_SUBMODULES_RECURSE) + if(git_submodules_recurse_value) + set(git_submodules_recurse "--recursive") + else() + set(git_submodules_recurse "") + endif() + endif() + # The git submodule update '--recursive' flag requires git >= v1.6.5 # - if(GIT_VERSION_STRING VERSION_LESS 1.6.5) + if(git_submodules_recurse AND GIT_VERSION_STRING VERSION_LESS 1.6.5) message(FATAL_ERROR "error: git version 1.6.5 or later required for 'git submodule update --recursive': GIT_VERSION_STRING='${GIT_VERSION_STRING}'") endif() @@ -2477,7 +2499,7 @@ function(_ep_add_download_command name) # The script will delete the source directory and then call git clone. # _ep_write_gitclone_script(${tmp_dir}/${name}-gitclone.cmake ${source_dir} - ${GIT_EXECUTABLE} ${git_repository} ${git_tag} ${git_remote_name} ${git_init_submodules} "${git_submodules}" "${git_shallow}" "${git_progress}" "${git_config}" ${src_name} ${work_dir} + ${GIT_EXECUTABLE} ${git_repository} ${git_tag} ${git_remote_name} ${git_init_submodules} "${git_submodules_recurse}" "${git_submodules}" "${git_shallow}" "${git_progress}" "${git_config}" ${src_name} ${work_dir} ${stamp_dir}/${name}-gitinfo.txt ${stamp_dir}/${name}-gitclone-lastrun.txt "${tls_verify}" ) set(comment "Performing download step (git clone) for '${name}'") @@ -2563,7 +2585,7 @@ function(_ep_add_download_command name) if(IS_DIRECTORY "${url}") get_filename_component(abs_dir "${url}" ABSOLUTE) set(comment "Performing download step (DIR copy) for '${name}'") - set(cmd ${CMAKE_COMMAND} -E remove_directory ${source_dir} + set(cmd ${CMAKE_COMMAND} -E rm -rf ${source_dir} COMMAND ${CMAKE_COMMAND} -E copy_directory ${abs_dir} ${source_dir}) else() get_property(no_extract TARGET "${name}" PROPERTY _EP_DOWNLOAD_NO_EXTRACT SET) diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake index 5716b01..f3e1b51 100644 --- a/Modules/FetchContent.cmake +++ b/Modules/FetchContent.cmake @@ -596,9 +596,6 @@ current working directory. #]=======================================================================] - -set(__FetchContent_privateDir "${CMAKE_CURRENT_LIST_DIR}/FetchContent") - #======================================================================= # Recording and retrieving content details for later population #======================================================================= @@ -888,7 +885,7 @@ function(__FetchContent_directPopulate contentName) # anything to be updated, so extra rebuilds of the project won't occur. # Make sure to pass through CMAKE_MAKE_PROGRAM in case the main project # has this set to something not findable on the PATH. - configure_file("${__FetchContent_privateDir}/CMakeLists.cmake.in" + configure_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/FetchContent/CMakeLists.cmake.in" "${ARG_SUBBUILD_DIR}/CMakeLists.txt") execute_process( COMMAND ${CMAKE_COMMAND} ${generatorOpts} . diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index d3acafc..9b6d09c 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -8,8 +8,9 @@ FindBLAS Find Basic Linear Algebra Subprograms (BLAS) library This module finds an installed Fortran library that implements the -BLAS linear-algebra interface (see http://www.netlib.org/blas/). The -list of libraries searched for is taken from the ``autoconf`` macro file, +BLAS linear-algebra interface (see http://www.netlib.org/blas/). + +The approach follows that taken for the ``autoconf`` macro file, ``acx_blas.m4`` (distributed at http://ac-archive.sourceforge.net/ac-archive/acx_blas.html). @@ -25,28 +26,29 @@ The following variables may be set to influence this module's behavior: If set, checks only the specified vendor, if not set checks all the possibilities. List of vendors valid in this module: - * Goto - * OpenBLAS - * FLAME - * ATLAS PhiPACK - * CXML - * DXML - * SunPerf - * SCSL - * SGIMATH - * IBMESSL - * Intel10_32 (intel mkl v10 32 bit) - * Intel10_64lp (intel mkl v10+ 64 bit, threaded code, lp64 model) - * Intel10_64lp_seq (intel mkl v10+ 64 bit, sequential code, lp64 model) - * Intel10_64ilp (intel mkl v10+ 64 bit, threaded code, ilp64 model) - * Intel10_64ilp_seq (intel mkl v10+ 64 bit, sequential code, ilp64 model) - * Intel (obsolete versions of mkl 32 and 64 bit) - * ACML - * ACML_MP - * ACML_GPU - * Apple - * NAS - * Generic + * ``Goto`` + * ``OpenBLAS`` + * ``FLAME`` + * ``ATLAS PhiPACK`` + * ``CXML`` + * ``DXML`` + * ``SunPerf`` + * ``SCSL`` + * ``SGIMATH`` + * ``IBMESSL`` + * ``Intel10_32`` (intel mkl v10 32 bit) + * ``Intel10_64lp`` (intel mkl v10+ 64 bit, threaded code, lp64 model) + * ``Intel10_64lp_seq`` (intel mkl v10+ 64 bit, sequential code, lp64 model) + * ``Intel10_64ilp`` (intel mkl v10+ 64 bit, threaded code, ilp64 model) + * ``Intel10_64ilp_seq`` (intel mkl v10+ 64 bit, sequential code, ilp64 model) + * ``Intel10_64_dyn`` (intel mkl v10+ 64 bit, single dynamic library) + * ``Intel`` (obsolete versions of mkl 32 and 64 bit) + * ``ACML`` + * ``ACML_MP`` + * ``ACML_GPU`` + * ``Apple`` + * ``NAS`` + * ``Generic`` ``BLA_F95`` if ``ON`` tries to find the BLAS95 interfaces @@ -75,7 +77,8 @@ This module defines the following variables: .. note:: - C or CXX must be enabled to use Intel Math Kernel Library (MKL) + C, CXX or Fortran must be enabled to detect a BLAS library. + C or CXX must be enabled to use Intel Math Kernel Library (MKL). For example, to use Intel MKL libraries and/or Intel compiler: @@ -87,22 +90,15 @@ This module defines the following variables: Hints ^^^^^ -Set ``MKLROOT`` environment variable to a directory that contains an MKL -installation. +Set the ``MKLROOT`` environment variable to a directory that contains an MKL +installation, or add the directory to the dynamic library loader environment +variable for your platform (``LIB``, ``DYLD_LIBRARY_PATH`` or +``LD_LIBRARY_PATH``). #]=======================================================================] -include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/CheckFortranFunctionExists.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -cmake_push_check_state() -set(CMAKE_REQUIRED_QUIET ${BLAS_FIND_QUIETLY}) - -set(_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) - # Check the language being used -if( NOT (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED OR CMAKE_Fortran_COMPILER_LOADED) ) +if(NOT (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED OR CMAKE_Fortran_COMPILER_LOADED)) if(BLAS_FIND_REQUIRED) message(FATAL_ERROR "FindBLAS requires Fortran, C, or C++ to be enabled.") else() @@ -111,6 +107,16 @@ if( NOT (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED OR CMAKE_Fortran_C endif() endif() +if(CMAKE_Fortran_COMPILER_LOADED) + include(${CMAKE_CURRENT_LIST_DIR}/CheckFortranFunctionExists.cmake) +else() + include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake) +endif() +include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +cmake_push_check_state() +set(CMAKE_REQUIRED_QUIET ${BLAS_FIND_QUIETLY}) + if(BLA_PREFER_PKGCONFIG) find_package(PkgConfig) pkg_check_modules(PKGC_BLAS blas) @@ -121,7 +127,23 @@ if(BLA_PREFER_PKGCONFIG) endif() endif() -macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread) +set(_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) +if(BLA_STATIC) + if(WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) + else() + set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + endif() +else() + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + # for ubuntu's libblas3gf and liblapack3gf packages + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf) + endif() +endif() + +# TODO: move this stuff to a separate module + +macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _addlibdir _subdirs) # This macro checks for the existence of the combination of fortran libraries # given by _list. If the combination is found, this macro checks (using the # Check_Fortran_Function_Exists macro) whether can link against that library @@ -132,59 +154,51 @@ macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread) # N.B. _prefix is the prefix applied to the names of all cached variables that # are generated internally and marked advanced by this macro. - - set(_libdir ${ARGN}) + # _addlibdir is a list of additional search paths. _subdirs is a list of path + # suffixes to be used by find_library(). set(_libraries_work TRUE) set(${LIBRARIES}) set(_combined_name) - if (NOT _libdir) - if (WIN32) - set(_libdir ENV LIB) - elseif (APPLE) - set(_libdir ENV DYLD_LIBRARY_PATH) - else () - set(_libdir ENV LD_LIBRARY_PATH) - endif () - endif () - - list(APPEND _libdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + + set(_extaddlibdir "${_addlibdir}") + if(WIN32) + list(APPEND _extaddlibdir ENV LIB) + elseif(APPLE) + list(APPEND _extaddlibdir ENV DYLD_LIBRARY_PATH) + else() + list(APPEND _extaddlibdir ENV LD_LIBRARY_PATH) + endif() + list(APPEND _extaddlibdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") foreach(_library ${_list}) - set(_combined_name ${_combined_name}_${_library}) - if(NOT "${_thread}" STREQUAL "") - set(_combined_name ${_combined_name}_thread) - endif() - if(_libraries_work) - if (BLA_STATIC) - if (WIN32) - set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) - endif () - if (APPLE) - set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) - else () - set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) - endif () - else () - if (CMAKE_SYSTEM_NAME STREQUAL "Linux") - # for ubuntu's libblas3gf and liblapack3gf packages - set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf) - endif () - endif () - find_library(${_prefix}_${_library}_LIBRARY - NAMES ${_library} - PATHS ${_libdir} + if(_library MATCHES "^-Wl,--(start|end)-group$") + # Respect linker flags like --start/end-group (required by MKL) + set(${LIBRARIES} ${${LIBRARIES}} "${_library}") + else() + set(_combined_name ${_combined_name}_${_library}) + if(NOT "${_threadlibs}" STREQUAL "") + set(_combined_name ${_combined_name}_threadlibs) + endif() + if(_libraries_work) + find_library(${_prefix}_${_library}_LIBRARY + NAMES ${_library} + PATHS ${_extaddlibdir} + PATH_SUFFIXES ${_subdirs} ) - mark_as_advanced(${_prefix}_${_library}_LIBRARY) - set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) - set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) + #message("DEBUG: find_library(${_library}) got ${${_prefix}_${_library}_LIBRARY}") + mark_as_advanced(${_prefix}_${_library}_LIBRARY) + set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) + set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) + endif() endif() endforeach() + if(_libraries_work) # Test this combination of libraries. - set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_thread}) - # message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}") - if (CMAKE_Fortran_COMPILER_LOADED) + set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_threadlibs}) + #message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}") + if(CMAKE_Fortran_COMPILER_LOADED) check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS) else() check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS) @@ -192,11 +206,12 @@ macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread) set(CMAKE_REQUIRED_LIBRARIES) set(_libraries_work ${${_prefix}${_combined_name}_WORKS}) endif() + if(_libraries_work) if("${_list}" STREQUAL "") set(${LIBRARIES} "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES") else() - set(${LIBRARIES} ${${LIBRARIES}} ${_thread}) # for static link + set(${LIBRARIES} ${${LIBRARIES}} ${_threadlibs}) endif() else() set(${LIBRARIES} FALSE) @@ -207,91 +222,96 @@ endmacro() set(BLAS_LINKER_FLAGS) set(BLAS_LIBRARIES) set(BLAS95_LIBRARIES) -if (NOT $ENV{BLA_VENDOR} STREQUAL "") +if(NOT $ENV{BLA_VENDOR} STREQUAL "") set(BLA_VENDOR $ENV{BLA_VENDOR}) -else () +else() if(NOT BLA_VENDOR) set(BLA_VENDOR "All") endif() -endif () +endif() -if (BLA_VENDOR STREQUAL "All") +# Implicitly linked BLAS libraries? +if(BLA_VENDOR STREQUAL "All") if(NOT BLAS_LIBRARIES) - # Implicitly linked BLAS libraries - check_fortran_libraries( + check_blas_libraries( BLAS_LIBRARIES BLAS sgemm "" "" "" + "" + "" ) endif() -endif () - -#BLAS in intel mkl 10+ library? (em64t 64bit) -if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") - if (NOT BLAS_LIBRARIES) +endif() - # System-specific settings - if (WIN32) - if (BLA_STATIC) - set(BLAS_mkl_DLL_SUFFIX "") - else() - set(BLAS_mkl_DLL_SUFFIX "_dll") - endif() - else() - # Switch to GNU Fortran support layer if needed (but not on Apple, where MKL does not provide it) - if(CMAKE_Fortran_COMPILER_LOADED AND CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT APPLE) - set(BLAS_mkl_INTFACE "gf") - set(BLAS_mkl_THREADING "gnu") - set(BLAS_mkl_OMP "gomp") +# BLAS in the Intel MKL 10+ library? +if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) + if(CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED) + # System-specific settings + if(WIN32) + if(BLA_STATIC) + set(BLAS_mkl_DLL_SUFFIX "") + else() + set(BLAS_mkl_DLL_SUFFIX "_dll") + endif() else() - set(BLAS_mkl_INTFACE "intel") - set(BLAS_mkl_THREADING "intel") - set(BLAS_mkl_OMP "iomp5") + if(BLA_STATIC) + set(BLAS_mkl_START_GROUP "-Wl,--start-group") + set(BLAS_mkl_END_GROUP "-Wl,--end-group") + else() + set(BLAS_mkl_START_GROUP "") + set(BLAS_mkl_END_GROUP "") + endif() + # Switch to GNU Fortran support layer if needed (but not on Apple, where MKL does not provide it) + if(CMAKE_Fortran_COMPILER_LOADED AND CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT APPLE) + set(BLAS_mkl_INTFACE "gf") + set(BLAS_mkl_THREADING "gnu") + set(BLAS_mkl_OMP "gomp") + else() + set(BLAS_mkl_INTFACE "intel") + set(BLAS_mkl_THREADING "intel") + set(BLAS_mkl_OMP "iomp5") + endif() + set(BLAS_mkl_LM "-lm") + set(BLAS_mkl_LDL "-ldl") endif() - set(BLAS_mkl_LM "-lm") - set(BLAS_mkl_LDL "-ldl") - endif() - - if (BLA_VENDOR MATCHES "_64ilp") - set(BLAS_mkl_ILP_MODE "ilp64") - else () - set(BLAS_mkl_ILP_MODE "lp64") - endif () - if (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED) if(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED) find_package(Threads) else() find_package(Threads REQUIRED) endif() + if(BLA_VENDOR MATCHES "_64ilp") + set(BLAS_mkl_ILP_MODE "ilp64") + else() + set(BLAS_mkl_ILP_MODE "lp64") + endif() + set(BLAS_SEARCH_LIBS "") if(BLA_F95) - set(BLAS_mkl_SEARCH_SYMBOL sgemm_f95) + set(BLAS_mkl_SEARCH_SYMBOL "sgemm_f95") set(_LIBRARIES BLAS95_LIBRARIES) - if (WIN32) + if(WIN32) # Find the main file (32-bit or 64-bit) set(BLAS_SEARCH_LIBS_WIN_MAIN "") - if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") + if(BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN "mkl_blas95${BLAS_mkl_DLL_SUFFIX} mkl_intel_c${BLAS_mkl_DLL_SUFFIX}") endif() - if (BLA_VENDOR MATCHES "^Intel10_64i?lp" OR BLA_VENDOR STREQUAL "All") + + if(BLA_VENDOR MATCHES "^Intel10_64i?lp" OR BLA_VENDOR STREQUAL "All") list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN "mkl_blas95_${BLAS_mkl_ILP_MODE}${BLAS_mkl_DLL_SUFFIX} mkl_intel_${BLAS_mkl_ILP_MODE}${BLAS_mkl_DLL_SUFFIX}") - endif () + endif() # Add threading/sequential libs set(BLAS_SEARCH_LIBS_WIN_THREAD "") - if (BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD - "mkl_sequential${BLAS_mkl_DLL_SUFFIX}") - endif() - if (NOT BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All") + if(BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR STREQUAL "All") # old version list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD "libguide40 mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") @@ -299,56 +319,60 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD "libiomp5md mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") endif() + if(BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD + "mkl_sequential${BLAS_mkl_DLL_SUFFIX}") + endif() # Cartesian product of the above - foreach (MAIN ${BLAS_SEARCH_LIBS_WIN_MAIN}) - foreach (THREAD ${BLAS_SEARCH_LIBS_WIN_THREAD}) + foreach(MAIN ${BLAS_SEARCH_LIBS_WIN_MAIN}) + foreach(THREAD ${BLAS_SEARCH_LIBS_WIN_THREAD}) list(APPEND BLAS_SEARCH_LIBS "${MAIN} ${THREAD} mkl_core${BLAS_mkl_DLL_SUFFIX}") endforeach() endforeach() - else () - if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") + else() + if(BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") # old version list(APPEND BLAS_SEARCH_LIBS "mkl_blas95 mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core guide") # mkl >= 10.3 list(APPEND BLAS_SEARCH_LIBS - "mkl_blas95 mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_OMP}") - endif () - if (BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR STREQUAL "All") + "${BLAS_mkl_START_GROUP} mkl_blas95 mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_END_GROUP} ${BLAS_mkl_OMP}") + endif() + if(BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR STREQUAL "All") # old version list(APPEND BLAS_SEARCH_LIBS "mkl_blas95 mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_THREADING}_thread mkl_core guide") # mkl >= 10.3 list(APPEND BLAS_SEARCH_LIBS - "mkl_blas95_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_OMP}") - endif () - if (BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$" OR BLA_VENDOR STREQUAL "All") + "${BLAS_mkl_START_GROUP} mkl_blas95_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_END_GROUP} ${BLAS_mkl_OMP}") + endif() + if(BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$" OR BLA_VENDOR STREQUAL "All") list(APPEND BLAS_SEARCH_LIBS - "mkl_blas95_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_sequential mkl_core") - endif () - endif () - else () + "${BLAS_mkl_START_GROUP} mkl_blas95_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_sequential mkl_core ${BLAS_mkl_END_GROUP}") + endif() + endif() + else() set(BLAS_mkl_SEARCH_SYMBOL sgemm) set(_LIBRARIES BLAS_LIBRARIES) - if (WIN32) + if(WIN32) # Find the main file (32-bit or 64-bit) set(BLAS_SEARCH_LIBS_WIN_MAIN "") - if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") + if(BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN "mkl_intel_c${BLAS_mkl_DLL_SUFFIX}") endif() - if (BLA_VENDOR MATCHES "^Intel10_64i?lp" OR BLA_VENDOR STREQUAL "All") + if(BLA_VENDOR MATCHES "^Intel10_64i?lp" OR BLA_VENDOR STREQUAL "All") list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN "mkl_intel_${BLAS_mkl_ILP_MODE}${BLAS_mkl_DLL_SUFFIX}") - endif () + endif() # Add threading/sequential libs set(BLAS_SEARCH_LIBS_WIN_THREAD "") - if (NOT BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All") + if(BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR STREQUAL "All") # old version list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD "libguide40 mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") @@ -356,96 +380,118 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD "libiomp5md mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") endif() - if (BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All") + if(BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$" OR BLA_VENDOR STREQUAL "All") list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD "mkl_sequential${BLAS_mkl_DLL_SUFFIX}") endif() # Cartesian product of the above - foreach (MAIN ${BLAS_SEARCH_LIBS_WIN_MAIN}) - foreach (THREAD ${BLAS_SEARCH_LIBS_WIN_THREAD}) + foreach(MAIN ${BLAS_SEARCH_LIBS_WIN_MAIN}) + foreach(THREAD ${BLAS_SEARCH_LIBS_WIN_THREAD}) list(APPEND BLAS_SEARCH_LIBS "${MAIN} ${THREAD} mkl_core${BLAS_mkl_DLL_SUFFIX}") endforeach() endforeach() - else () - if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") + else() + if(BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") # old version list(APPEND BLAS_SEARCH_LIBS "mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core guide") # mkl >= 10.3 list(APPEND BLAS_SEARCH_LIBS - "mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_OMP}") - endif () - if (BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR STREQUAL "All") + "${BLAS_mkl_START_GROUP} mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_END_GROUP} ${BLAS_mkl_OMP}") + endif() + if(BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR STREQUAL "All") # old version list(APPEND BLAS_SEARCH_LIBS "mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_THREADING}_thread mkl_core guide") # mkl >= 10.3 list(APPEND BLAS_SEARCH_LIBS - "mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_OMP}") - endif () - if (BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$" OR BLA_VENDOR STREQUAL "All") + "${BLAS_mkl_START_GROUP} mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_END_GROUP} ${BLAS_mkl_OMP}") + endif() + if(BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$" OR BLA_VENDOR STREQUAL "All") list(APPEND BLAS_SEARCH_LIBS - "mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_sequential mkl_core") - endif () + "${BLAS_mkl_START_GROUP} mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_sequential mkl_core ${BLAS_mkl_END_GROUP}") + endif() #older vesions of intel mkl libs - if (BLA_VENDOR STREQUAL "Intel" OR BLA_VENDOR STREQUAL "All") + if(BLA_VENDOR STREQUAL "Intel" OR BLA_VENDOR STREQUAL "All") list(APPEND BLAS_SEARCH_LIBS "mkl") list(APPEND BLAS_SEARCH_LIBS "mkl_ia32") list(APPEND BLAS_SEARCH_LIBS "mkl_em64t") - endif () - endif () - endif () - - if (DEFINED ENV{MKLROOT}) - if (BLA_VENDOR STREQUAL "Intel10_32") - set(_BLAS_MKLROOT_LIB_DIR "$ENV{MKLROOT}/lib/ia32") - elseif (BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$") - set(_BLAS_MKLROOT_LIB_DIR "$ENV{MKLROOT}/lib/intel64") - endif () - endif () - if (_BLAS_MKLROOT_LIB_DIR) - if (WIN32) - string(APPEND _BLAS_MKLROOT_LIB_DIR "_win") - elseif (APPLE) - string(APPEND _BLAS_MKLROOT_LIB_DIR "_mac") - else () - string(APPEND _BLAS_MKLROOT_LIB_DIR "_lin") - endif () - endif () - - foreach (IT ${BLAS_SEARCH_LIBS}) + endif() + endif() + endif() + + if(BLA_VENDOR MATCHES "^Intel10_64_dyn$" OR BLA_VENDOR STREQUAL "All") + # mkl >= 10.3 with single dynamic library + list(APPEND BLAS_SEARCH_LIBS + "mkl_rt") + endif() + + # MKL uses a multitude of partially platform-specific subdirectories: + if(BLA_VENDOR STREQUAL "Intel10_32") + set(BLAS_mkl_ARCH_NAME "ia32") + else() + set(BLAS_mkl_ARCH_NAME "intel64") + endif() + if(WIN32) + set(BLAS_mkl_OS_NAME "win") + elseif(APPLE) + set(BLAS_mkl_OS_NAME "mac") + else() + set(BLAS_mkl_OS_NAME "lin") + endif() + if(DEFINED ENV{MKLROOT}) + set(BLAS_mkl_MKLROOT "$ENV{MKLROOT}") + # If MKLROOT points to the subdirectory 'mkl', use the parent directory instead + # so we can better detect other relevant libraries in 'compiler' or 'tbb': + get_filename_component(BLAS_mkl_MKLROOT_LAST_DIR "${BLAS_mkl_MKLROOT}" NAME) + if(BLAS_mkl_MKLROOT_LAST_DIR STREQUAL "mkl") + get_filename_component(BLAS_mkl_MKLROOT "${BLAS_mkl_MKLROOT}" DIRECTORY) + endif() + endif() + set(BLAS_mkl_LIB_PATH_SUFFIXES + "compiler/lib" "compiler/lib/${BLAS_mkl_ARCH_NAME}_${BLAS_mkl_OS_NAME}" + "mkl/lib" "mkl/lib/${BLAS_mkl_ARCH_NAME}_${BLAS_mkl_OS_NAME}" + "lib/${BLAS_mkl_ARCH_NAME}_${BLAS_mkl_OS_NAME}") + + foreach(IT ${BLAS_SEARCH_LIBS}) string(REPLACE " " ";" SEARCH_LIBS ${IT}) - if (NOT ${_LIBRARIES}) - check_fortran_libraries( + if(NOT ${_LIBRARIES}) + check_blas_libraries( ${_LIBRARIES} BLAS ${BLAS_mkl_SEARCH_SYMBOL} "" "${SEARCH_LIBS}" "${CMAKE_THREAD_LIBS_INIT};${BLAS_mkl_LM};${BLAS_mkl_LDL}" - "${_BLAS_MKLROOT_LIB_DIR}" + "${BLAS_mkl_MKLROOT}" + "${BLAS_mkl_LIB_PATH_SUFFIXES}" ) - endif () - endforeach () - - endif () - unset(BLAS_mkl_ILP_MODE) - unset(BLAS_mkl_INTFACE) - unset(BLAS_mkl_THREADING) - unset(BLAS_mkl_OMP) - unset(BLAS_mkl_DLL_SUFFIX) - unset(BLAS_mkl_LM) - unset(BLAS_mkl_LDL) - endif () -endif () + endif() + endforeach() + + unset(BLAS_mkl_ILP_MODE) + unset(BLAS_mkl_INTFACE) + unset(BLAS_mkl_THREADING) + unset(BLAS_mkl_OMP) + unset(BLAS_mkl_DLL_SUFFIX) + unset(BLAS_mkl_LM) + unset(BLAS_mkl_LDL) + unset(BLAS_mkl_MKLROOT) + unset(BLAS_mkl_MKLROOT_LAST_DIR) + unset(BLAS_mkl_ARCH_NAME) + unset(BLAS_mkl_OS_NAME) + unset(BLAS_mkl_LIB_PATH_SUFFIXES) + endif() + endif() +endif() if(BLA_F95) find_package_handle_standard_args(BLAS REQUIRED_VARS BLAS95_LIBRARIES) @@ -455,30 +501,34 @@ if(BLA_F95) endif() endif() -if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") +# gotoblas? (http://www.tacc.utexas.edu/tacc-projects/gotoblas2) +if(BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") if(NOT BLAS_LIBRARIES) - # gotoblas (http://www.tacc.utexas.edu/tacc-projects/gotoblas2) - check_fortran_libraries( + check_blas_libraries( BLAS_LIBRARIES BLAS sgemm "" "goto2" "" + "" + "" ) endif() -endif () +endif() -if (BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All") +# OpenBLAS? (http://www.openblas.net) +if(BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All") if(NOT BLAS_LIBRARIES) - # OpenBLAS (http://www.openblas.net) - check_fortran_libraries( + check_blas_libraries( BLAS_LIBRARIES BLAS sgemm "" "openblas" "" + "" + "" ) endif() if(NOT BLAS_LIBRARIES AND (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED)) @@ -487,246 +537,265 @@ if (BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All") else() find_package(Threads REQUIRED) endif() - # OpenBLAS (http://www.openblas.net) - check_fortran_libraries( + check_blas_libraries( BLAS_LIBRARIES BLAS sgemm "" "openblas" "${CMAKE_THREAD_LIBS_INIT}" + "" + "" ) endif() -endif () +endif() -if (BLA_VENDOR STREQUAL "FLAME" OR BLA_VENDOR STREQUAL "All") +# FLAME's blis library? (https://github.com/flame/blis) +if(BLA_VENDOR STREQUAL "FLAME" OR BLA_VENDOR STREQUAL "All") if(NOT BLAS_LIBRARIES) - # FLAME's blis library (https://github.com/flame/blis) - check_fortran_libraries( + check_blas_libraries( BLAS_LIBRARIES BLAS sgemm "" "blis" "" + "" + "" ) endif() -endif () +endif() -if (BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All") +# BLAS in the ATLAS library? (http://math-atlas.sourceforge.net/) +if(BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All") if(NOT BLAS_LIBRARIES) - # BLAS in ATLAS library? (http://math-atlas.sourceforge.net/) - check_fortran_libraries( + check_blas_libraries( BLAS_LIBRARIES BLAS dgemm "" - "f77blas;atlas" + "blas;f77blas;atlas" + "" + "" "" ) endif() -endif () +endif() # BLAS in PhiPACK libraries? (requires generic BLAS lib, too) -if (BLA_VENDOR STREQUAL "PhiPACK" OR BLA_VENDOR STREQUAL "All") +if(BLA_VENDOR STREQUAL "PhiPACK" OR BLA_VENDOR STREQUAL "All") if(NOT BLAS_LIBRARIES) - check_fortran_libraries( + check_blas_libraries( BLAS_LIBRARIES BLAS sgemm "" "sgemm;dgemm;blas" "" + "" + "" ) endif() -endif () +endif() # BLAS in Alpha CXML library? -if (BLA_VENDOR STREQUAL "CXML" OR BLA_VENDOR STREQUAL "All") +if(BLA_VENDOR STREQUAL "CXML" OR BLA_VENDOR STREQUAL "All") if(NOT BLAS_LIBRARIES) - check_fortran_libraries( + check_blas_libraries( BLAS_LIBRARIES BLAS sgemm "" "cxml" "" + "" + "" ) endif() -endif () +endif() # BLAS in Alpha DXML library? (now called CXML, see above) -if (BLA_VENDOR STREQUAL "DXML" OR BLA_VENDOR STREQUAL "All") +if(BLA_VENDOR STREQUAL "DXML" OR BLA_VENDOR STREQUAL "All") if(NOT BLAS_LIBRARIES) - check_fortran_libraries( + check_blas_libraries( BLAS_LIBRARIES BLAS sgemm "" "dxml" "" + "" + "" ) endif() -endif () +endif() # BLAS in Sun Performance library? -if (BLA_VENDOR STREQUAL "SunPerf" OR BLA_VENDOR STREQUAL "All") +if(BLA_VENDOR STREQUAL "SunPerf" OR BLA_VENDOR STREQUAL "All") if(NOT BLAS_LIBRARIES) - check_fortran_libraries( + check_blas_libraries( BLAS_LIBRARIES BLAS sgemm "-xlic_lib=sunperf" "sunperf;sunmath" "" + "" + "" ) if(BLAS_LIBRARIES) set(BLAS_LINKER_FLAGS "-xlic_lib=sunperf") endif() endif() -endif () +endif() # BLAS in SCSL library? (SGI/Cray Scientific Library) -if (BLA_VENDOR STREQUAL "SCSL" OR BLA_VENDOR STREQUAL "All") +if(BLA_VENDOR STREQUAL "SCSL" OR BLA_VENDOR STREQUAL "All") if(NOT BLAS_LIBRARIES) - check_fortran_libraries( + check_blas_libraries( BLAS_LIBRARIES BLAS sgemm "" "scsl" "" + "" + "" ) endif() -endif () +endif() # BLAS in SGIMATH library? -if (BLA_VENDOR STREQUAL "SGIMATH" OR BLA_VENDOR STREQUAL "All") +if(BLA_VENDOR STREQUAL "SGIMATH" OR BLA_VENDOR STREQUAL "All") if(NOT BLAS_LIBRARIES) - check_fortran_libraries( + check_blas_libraries( BLAS_LIBRARIES BLAS sgemm "" "complib.sgimath" "" + "" + "" ) endif() -endif () +endif() # BLAS in IBM ESSL library? (requires generic BLAS lib, too) -if (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All") +if(BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All") if(NOT BLAS_LIBRARIES) - check_fortran_libraries( + check_blas_libraries( BLAS_LIBRARIES BLAS sgemm "" "essl;blas" "" + "" + "" ) endif() -endif () +endif() -#BLAS in acml library? -if (BLA_VENDOR MATCHES "ACML" OR BLA_VENDOR STREQUAL "All") - if( ((BLA_VENDOR STREQUAL "ACML") AND (NOT BLAS_ACML_LIB_DIRS)) OR +# BLAS in acml library? +if(BLA_VENDOR MATCHES "ACML" OR BLA_VENDOR STREQUAL "All") + if(((BLA_VENDOR STREQUAL "ACML") AND (NOT BLAS_ACML_LIB_DIRS)) OR ((BLA_VENDOR STREQUAL "ACML_MP") AND (NOT BLAS_ACML_MP_LIB_DIRS)) OR ((BLA_VENDOR STREQUAL "ACML_GPU") AND (NOT BLAS_ACML_GPU_LIB_DIRS)) ) # try to find acml in "standard" paths - if( WIN32 ) - file( GLOB _ACML_ROOT "C:/AMD/acml*/ACML-EULA.txt" ) + if(WIN32) + file(GLOB _ACML_ROOT "C:/AMD/acml*/ACML-EULA.txt") else() - file( GLOB _ACML_ROOT "/opt/acml*/ACML-EULA.txt" ) + file(GLOB _ACML_ROOT "/opt/acml*/ACML-EULA.txt") endif() - if( WIN32 ) - file( GLOB _ACML_GPU_ROOT "C:/AMD/acml*/GPGPUexamples" ) + if(WIN32) + file(GLOB _ACML_GPU_ROOT "C:/AMD/acml*/GPGPUexamples") else() - file( GLOB _ACML_GPU_ROOT "/opt/acml*/GPGPUexamples" ) + file(GLOB _ACML_GPU_ROOT "/opt/acml*/GPGPUexamples") endif() list(GET _ACML_ROOT 0 _ACML_ROOT) list(GET _ACML_GPU_ROOT 0 _ACML_GPU_ROOT) - if( _ACML_ROOT ) - get_filename_component( _ACML_ROOT ${_ACML_ROOT} PATH ) - if( SIZEOF_INTEGER EQUAL 8 ) - set( _ACML_PATH_SUFFIX "_int64" ) + if(_ACML_ROOT) + get_filename_component(_ACML_ROOT ${_ACML_ROOT} PATH) + if(SIZEOF_INTEGER EQUAL 8) + set(_ACML_PATH_SUFFIX "_int64") else() - set( _ACML_PATH_SUFFIX "" ) + set(_ACML_PATH_SUFFIX "") endif() - if( CMAKE_Fortran_COMPILER_ID STREQUAL "Intel" ) - set( _ACML_COMPILER32 "ifort32" ) - set( _ACML_COMPILER64 "ifort64" ) - elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "SunPro" ) - set( _ACML_COMPILER32 "sun32" ) - set( _ACML_COMPILER64 "sun64" ) - elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "PGI" ) - set( _ACML_COMPILER32 "pgi32" ) - if( WIN32 ) - set( _ACML_COMPILER64 "win64" ) + if(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") + set(_ACML_COMPILER32 "ifort32") + set(_ACML_COMPILER64 "ifort64") + elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "SunPro") + set(_ACML_COMPILER32 "sun32") + set(_ACML_COMPILER64 "sun64") + elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "PGI") + set(_ACML_COMPILER32 "pgi32") + if(WIN32) + set(_ACML_COMPILER64 "win64") else() - set( _ACML_COMPILER64 "pgi64" ) + set(_ACML_COMPILER64 "pgi64") endif() - elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "Open64" ) + elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Open64") # 32 bit builds not supported on Open64 but for code simplicity # We'll just use the same directory twice - set( _ACML_COMPILER32 "open64_64" ) - set( _ACML_COMPILER64 "open64_64" ) - elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "NAG" ) - set( _ACML_COMPILER32 "nag32" ) - set( _ACML_COMPILER64 "nag64" ) + set(_ACML_COMPILER32 "open64_64") + set(_ACML_COMPILER64 "open64_64") + elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "NAG") + set(_ACML_COMPILER32 "nag32") + set(_ACML_COMPILER64 "nag64") else() - set( _ACML_COMPILER32 "gfortran32" ) - set( _ACML_COMPILER64 "gfortran64" ) + set(_ACML_COMPILER32 "gfortran32") + set(_ACML_COMPILER64 "gfortran64") endif() - if( BLA_VENDOR STREQUAL "ACML_MP" ) + if(BLA_VENDOR STREQUAL "ACML_MP") set(_ACML_MP_LIB_DIRS "${_ACML_ROOT}/${_ACML_COMPILER32}_mp${_ACML_PATH_SUFFIX}/lib" - "${_ACML_ROOT}/${_ACML_COMPILER64}_mp${_ACML_PATH_SUFFIX}/lib" ) + "${_ACML_ROOT}/${_ACML_COMPILER64}_mp${_ACML_PATH_SUFFIX}/lib") else() set(_ACML_LIB_DIRS "${_ACML_ROOT}/${_ACML_COMPILER32}${_ACML_PATH_SUFFIX}/lib" - "${_ACML_ROOT}/${_ACML_COMPILER64}${_ACML_PATH_SUFFIX}/lib" ) + "${_ACML_ROOT}/${_ACML_COMPILER64}${_ACML_PATH_SUFFIX}/lib") endif() endif() elseif(BLAS_${BLA_VENDOR}_LIB_DIRS) set(_${BLA_VENDOR}_LIB_DIRS ${BLAS_${BLA_VENDOR}_LIB_DIRS}) endif() -if( BLA_VENDOR STREQUAL "ACML_MP" ) - foreach( BLAS_ACML_MP_LIB_DIRS ${_ACML_MP_LIB_DIRS}) - check_fortran_libraries ( +if(BLA_VENDOR STREQUAL "ACML_MP") + foreach(BLAS_ACML_MP_LIB_DIRS ${_ACML_MP_LIB_DIRS}) + check_blas_libraries( BLAS_LIBRARIES BLAS sgemm - "" "acml_mp;acml_mv" "" ${BLAS_ACML_MP_LIB_DIRS} + "" "acml_mp;acml_mv" "" ${BLAS_ACML_MP_LIB_DIRS} "" ) - if( BLAS_LIBRARIES ) + if(BLAS_LIBRARIES) break() endif() endforeach() -elseif( BLA_VENDOR STREQUAL "ACML_GPU" ) - foreach( BLAS_ACML_GPU_LIB_DIRS ${_ACML_GPU_LIB_DIRS}) - check_fortran_libraries ( +elseif(BLA_VENDOR STREQUAL "ACML_GPU") + foreach(BLAS_ACML_GPU_LIB_DIRS ${_ACML_GPU_LIB_DIRS}) + check_blas_libraries( BLAS_LIBRARIES BLAS sgemm - "" "acml;acml_mv;CALBLAS" "" ${BLAS_ACML_GPU_LIB_DIRS} + "" "acml;acml_mv;CALBLAS" "" ${BLAS_ACML_GPU_LIB_DIRS} "" ) - if( BLAS_LIBRARIES ) + if(BLAS_LIBRARIES) break() endif() endforeach() else() - foreach( BLAS_ACML_LIB_DIRS ${_ACML_LIB_DIRS} ) - check_fortran_libraries ( + foreach(BLAS_ACML_LIB_DIRS ${_ACML_LIB_DIRS}) + check_blas_libraries( BLAS_LIBRARIES BLAS sgemm - "" "acml;acml_mv" "" ${BLAS_ACML_LIB_DIRS} + "" "acml;acml_mv" "" ${BLAS_ACML_LIB_DIRS} "" ) - if( BLAS_LIBRARIES ) + if(BLAS_LIBRARIES) break() endif() endforeach() @@ -734,77 +803,90 @@ endif() # Either acml or acml_mp should be in LD_LIBRARY_PATH but not both if(NOT BLAS_LIBRARIES) - check_fortran_libraries( + check_blas_libraries( BLAS_LIBRARIES BLAS sgemm "" "acml;acml_mv" "" + "" + "" ) endif() if(NOT BLAS_LIBRARIES) - check_fortran_libraries( + check_blas_libraries( BLAS_LIBRARIES BLAS sgemm "" "acml_mp;acml_mv" "" + "" + "" ) endif() if(NOT BLAS_LIBRARIES) - check_fortran_libraries( + check_blas_libraries( BLAS_LIBRARIES BLAS sgemm "" "acml;acml_mv;CALBLAS" "" + "" + "" ) endif() -endif () # ACML +endif() # ACML # Apple BLAS library? -if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") +if(BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") if(NOT BLAS_LIBRARIES) - check_fortran_libraries( + check_blas_libraries( BLAS_LIBRARIES BLAS dgemm "" "Accelerate" "" + "" + "" ) endif() -endif () +endif() -if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") - if ( NOT BLAS_LIBRARIES ) - check_fortran_libraries( +# Apple NAS (vecLib) library? +if(BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) + check_blas_libraries( BLAS_LIBRARIES BLAS dgemm "" "vecLib" "" + "" + "" ) - endif () -endif () + endif() +endif() # Generic BLAS library? -if (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All") +if(BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All") if(NOT BLAS_LIBRARIES) - check_fortran_libraries( + check_blas_libraries( BLAS_LIBRARIES BLAS sgemm "" "blas" "" + "" + "" ) endif() -endif () +endif() if(NOT BLA_F95) find_package_handle_standard_args(BLAS REQUIRED_VARS BLAS_LIBRARIES) @@ -812,7 +894,7 @@ endif() # On compilers that implicitly link BLAS (such as ftn, cc, and CC on Cray HPC machines) # we used a placeholder for empty BLAS_LIBRARIES to get through our logic above. -if (BLAS_LIBRARIES STREQUAL "BLAS_LIBRARIES-PLACEHOLDER-FOR-EMPTY-LIBRARIES") +if(BLAS_LIBRARIES STREQUAL "BLAS_LIBRARIES-PLACEHOLDER-FOR-EMPTY-LIBRARIES") set(BLAS_LIBRARIES "") endif() diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 0e84fab..3c52466 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -248,6 +248,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) # Save project's policies cmake_policy(PUSH) cmake_policy(SET CMP0057 NEW) # if IN_LIST +cmake_policy(SET CMP0102 NEW) # if mark_as_advanced(non_cache_var) function(_boost_get_existing_target component target_var) set(names "${component}") @@ -441,7 +442,9 @@ if (NOT Boost_NO_BOOST_CMAKE) # Note that args are passed in the Boost_FIND_xxxxx variables, so there is no # need to delegate them to this find_package call. find_package(Boost QUIET NO_MODULE) - mark_as_advanced(Boost_DIR) + if (DEFINED Boost_DIR) + mark_as_advanced(Boost_DIR) + endif () # If we found a boost cmake package, then we're done. Print out what we found. # Otherwise let the rest of the module try to find it. @@ -1467,43 +1470,6 @@ _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_ADDITIONAL_VERSIONS") _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_NO_SYSTEM_PATHS") -# Supply Boost_LIB_DIAGNOSTIC_DEFINITIONS as a convenience target. It -# will only contain any interface definitions on WIN32, but is created -# on all platforms to keep end user code free from platform dependent -# code. Also provide convenience targets to disable autolinking and -# enable dynamic linking. -if(NOT TARGET Boost::diagnostic_definitions) - add_library(Boost::diagnostic_definitions INTERFACE IMPORTED) - add_library(Boost::disable_autolinking INTERFACE IMPORTED) - add_library(Boost::dynamic_linking INTERFACE IMPORTED) - set_target_properties(Boost::dynamic_linking PROPERTIES - INTERFACE_COMPILE_DEFINITIONS "BOOST_ALL_DYN_LINK") -endif() -if(WIN32) - # In windows, automatic linking is performed, so you do not have - # to specify the libraries. If you are linking to a dynamic - # runtime, then you can choose to link to either a static or a - # dynamic Boost library, the default is to do a static link. You - # can alter this for a specific library "whatever" by defining - # BOOST_WHATEVER_DYN_LINK to force Boost library "whatever" to be - # linked dynamically. Alternatively you can force all Boost - # libraries to dynamic link by defining BOOST_ALL_DYN_LINK. - - # This feature can be disabled for Boost library "whatever" by - # defining BOOST_WHATEVER_NO_LIB, or for all of Boost by defining - # BOOST_ALL_NO_LIB. - - # If you want to observe which libraries are being linked against - # then defining BOOST_LIB_DIAGNOSTIC will cause the auto-linking - # code to emit a #pragma message each time a library is selected - # for linking. - set(Boost_LIB_DIAGNOSTIC_DEFINITIONS "-DBOOST_LIB_DIAGNOSTIC") - set_target_properties(Boost::diagnostic_definitions PROPERTIES - INTERFACE_COMPILE_DEFINITIONS "BOOST_LIB_DIAGNOSTIC") - set_target_properties(Boost::disable_autolinking PROPERTIES - INTERFACE_COMPILE_DEFINITIONS "BOOST_ALL_NO_LIB") -endif() - cmake_policy(GET CMP0074 _Boost_CMP0074) if(NOT "x${_Boost_CMP0074}x" STREQUAL "xNEWx") _Boost_CHECK_SPELLING(Boost_ROOT) @@ -2296,6 +2262,43 @@ if(Boost_FOUND) endif() endif() endforeach() + + # Supply Boost_LIB_DIAGNOSTIC_DEFINITIONS as a convenience target. It + # will only contain any interface definitions on WIN32, but is created + # on all platforms to keep end user code free from platform dependent + # code. Also provide convenience targets to disable autolinking and + # enable dynamic linking. + if(NOT TARGET Boost::diagnostic_definitions) + add_library(Boost::diagnostic_definitions INTERFACE IMPORTED) + add_library(Boost::disable_autolinking INTERFACE IMPORTED) + add_library(Boost::dynamic_linking INTERFACE IMPORTED) + set_target_properties(Boost::dynamic_linking PROPERTIES + INTERFACE_COMPILE_DEFINITIONS "BOOST_ALL_DYN_LINK") + endif() + if(WIN32) + # In windows, automatic linking is performed, so you do not have + # to specify the libraries. If you are linking to a dynamic + # runtime, then you can choose to link to either a static or a + # dynamic Boost library, the default is to do a static link. You + # can alter this for a specific library "whatever" by defining + # BOOST_WHATEVER_DYN_LINK to force Boost library "whatever" to be + # linked dynamically. Alternatively you can force all Boost + # libraries to dynamic link by defining BOOST_ALL_DYN_LINK. + + # This feature can be disabled for Boost library "whatever" by + # defining BOOST_WHATEVER_NO_LIB, or for all of Boost by defining + # BOOST_ALL_NO_LIB. + + # If you want to observe which libraries are being linked against + # then defining BOOST_LIB_DIAGNOSTIC will cause the auto-linking + # code to emit a #pragma message each time a library is selected + # for linking. + set(Boost_LIB_DIAGNOSTIC_DEFINITIONS "-DBOOST_LIB_DIAGNOSTIC") + set_target_properties(Boost::diagnostic_definitions PROPERTIES + INTERFACE_COMPILE_DEFINITIONS "BOOST_LIB_DIAGNOSTIC") + set_target_properties(Boost::disable_autolinking PROPERTIES + INTERFACE_COMPILE_DEFINITIONS "BOOST_ALL_NO_LIB") + endif() endif() # ------------------------------------------------------------------------ diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index b6859aa..0e2f551 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -5,17 +5,22 @@ FindCUDA .. deprecated:: 3.10 Superseded by first-class support for the CUDA language in CMake. + Superseded by the :module:`FindCUDAToolkit` for CUDA toolkit libraries. Replacement ^^^^^^^^^^^ -It is no longer necessary to use this module or call ``find_package(CUDA)``. -Instead, list ``CUDA`` among the languages named in the top-level -call to the :command:`project` command, or call the +It is no longer necessary to use this module or call ``find_package(CUDA)`` +for compiling CUDA code. Instead, list ``CUDA`` among the languages named +in the top-level call to the :command:`project` command, or call the :command:`enable_language` command with ``CUDA``. Then one can add CUDA (``.cu``) sources to programs directly in calls to :command:`add_library` and :command:`add_executable`. +To find and use the CUDA toolkit libraries the :module:`FindCUDAToolkit` +module has superseded this module. It works whether or not the ``CUDA`` +language is enabled. + Documentation of Deprecated Usage ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -676,7 +681,7 @@ endif() # Search for the cuda distribution. if(NOT CUDA_TOOLKIT_ROOT_DIR AND NOT CMAKE_CROSSCOMPILING) # Search in the CUDA_BIN_PATH first. - find_path(CUDA_TOOLKIT_ROOT_DIR + find_program(CUDA_TOOLKIT_ROOT_DIR_NVCC NAMES nvcc nvcc.exe PATHS ENV CUDA_TOOLKIT_ROOT @@ -688,19 +693,22 @@ if(NOT CUDA_TOOLKIT_ROOT_DIR AND NOT CMAKE_CROSSCOMPILING) ) # Now search default paths - find_path(CUDA_TOOLKIT_ROOT_DIR + find_program(CUDA_TOOLKIT_ROOT_DIR_NVCC NAMES nvcc nvcc.exe PATHS /opt/cuda/bin PATH_SUFFIXES cuda/bin DOC "Toolkit location." ) - if (CUDA_TOOLKIT_ROOT_DIR) + if (CUDA_TOOLKIT_ROOT_DIR_NVCC) + get_filename_component(CUDA_TOOLKIT_ROOT_DIR_NVCC_PAR "${CUDA_TOOLKIT_ROOT_DIR_NVCC}" DIRECTORY) + get_filename_component(CUDA_TOOLKIT_ROOT_DIR "${CUDA_TOOLKIT_ROOT_DIR_NVCC_PAR}" DIRECTORY CACHE) string(REGEX REPLACE "[/\\\\]?bin[64]*[/\\\\]?$" "" CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT_DIR}) # We need to force this back into the cache. set(CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT_DIR} CACHE PATH "Toolkit location." FORCE) set(CUDA_TOOLKIT_TARGET_DIR ${CUDA_TOOLKIT_ROOT_DIR}) endif() + unset(CUDA_TOOLKIT_ROOT_DIR_NVCC CACHE) if (NOT EXISTS ${CUDA_TOOLKIT_ROOT_DIR}) if(CUDA_FIND_REQUIRED) @@ -921,7 +929,7 @@ set(CUDA_LIBRARIES) if(CUDA_BUILD_EMULATION AND CUDA_CUDARTEMU_LIBRARY) list(APPEND CUDA_LIBRARIES ${CUDA_CUDARTEMU_LIBRARY}) elseif(CUDA_USE_STATIC_CUDA_RUNTIME AND CUDA_cudart_static_LIBRARY) - list(APPEND CUDA_LIBRARIES ${CUDA_cudart_static_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) + list(APPEND CUDA_LIBRARIES ${CUDA_cudart_static_LIBRARY} Threads::Threads ${CMAKE_DL_LIBS}) if (CUDA_rt_LIBRARY) list(APPEND CUDA_LIBRARIES ${CUDA_rt_LIBRARY}) endif() @@ -2003,7 +2011,7 @@ macro(CUDA_BUILD_CLEAN_TARGET) string(TOUPPER ${cuda_clean_target_name} cuda_clean_target_name) endif() add_custom_target(${cuda_clean_target_name} - COMMAND ${CMAKE_COMMAND} -E remove ${CUDA_ADDITIONAL_CLEAN_FILES}) + COMMAND ${CMAKE_COMMAND} -E rm -f ${CUDA_ADDITIONAL_CLEAN_FILES}) # Clear out the variable, so the next time we configure it will be empty. # This is useful so that the files won't persist in the list after targets diff --git a/Modules/FindCUDA/run_nvcc.cmake b/Modules/FindCUDA/run_nvcc.cmake index af15d55..ba35433 100644 --- a/Modules/FindCUDA/run_nvcc.cmake +++ b/Modules/FindCUDA/run_nvcc.cmake @@ -174,7 +174,7 @@ endmacro() # Delete the target file cuda_execute_process( "Removing ${generated_file}" - COMMAND "${CMAKE_COMMAND}" -E remove "${generated_file}" + COMMAND "${CMAKE_COMMAND}" -E rm -f "${generated_file}" ) # For CUDA 2.3 and below, -G -M doesn't work, so remove the -G flag @@ -241,7 +241,7 @@ endif() # Delete the temporary file cuda_execute_process( "Removing ${cmake_dependency_file}.tmp and ${NVCC_generated_dependency_file}" - COMMAND "${CMAKE_COMMAND}" -E remove "${cmake_dependency_file}.tmp" "${NVCC_generated_dependency_file}" + COMMAND "${CMAKE_COMMAND}" -E rm -f "${cmake_dependency_file}.tmp" "${NVCC_generated_dependency_file}" ) if(CUDA_result) @@ -267,7 +267,7 @@ if(CUDA_result) # Since nvcc can sometimes leave half done files make sure that we delete the output file. cuda_execute_process( "Removing ${generated_file}" - COMMAND "${CMAKE_COMMAND}" -E remove "${generated_file}" + COMMAND "${CMAKE_COMMAND}" -E rm -f "${generated_file}" ) message(FATAL_ERROR "Error generating file ${generated_file}") else() diff --git a/Modules/FindCUDAToolkit.cmake b/Modules/FindCUDAToolkit.cmake new file mode 100644 index 0000000..62749ed --- /dev/null +++ b/Modules/FindCUDAToolkit.cmake @@ -0,0 +1,841 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindCUDAToolkit +--------------- + +This script locates the NVIDIA CUDA toolkit and the associated libraries, but +does not require the ``CUDA`` language be enabled for a given project. This +module does not search for the NVIDIA CUDA Samples. + +Search Behavior +^^^^^^^^^^^^^^^ + +Finding the CUDA Toolkit requires finding the ``nvcc`` executable, which is +searched for in the following order: + +1. If the ``CUDA`` language has been enabled we will use the directory + containing the compiler as the first search location for ``nvcc``. + +2. If the ``CUDAToolkit_ROOT`` cmake configuration variable (e.g., + ``-DCUDAToolkit_ROOT=/some/path``) *or* environment variable is defined, it + will be searched. If both an environment variable **and** a + configuration variable are specified, the *configuration* variable takes + precedence. + + The directory specified here must be such that the executable ``nvcc`` can be + found underneath the directory specified by ``CUDAToolkit_ROOT``. If + ``CUDAToolkit_ROOT`` is specified, but no ``nvcc`` is found underneath, this + package is marked as **not** found. No subsequent search attempts are + performed. + +3. If the CUDA_PATH environment variable is defined, it will be searched. + +4. The user's path is searched for ``nvcc`` using :command:`find_program`. If + this is found, no subsequent search attempts are performed. Users are + responsible for ensuring that the first ``nvcc`` to show up in the path is + the desired path in the event that multiple CUDA Toolkits are installed. + +5. On Unix systems, if the symbolic link ``/usr/local/cuda`` exists, this is + used. No subsequent search attempts are performed. No default symbolic link + location exists for the Windows platform. + +6. The platform specific default install locations are searched. If exactly one + candidate is found, this is used. The default CUDA Toolkit install locations + searched are: + + +-------------+-------------------------------------------------------------+ + | Platform | Search Pattern | + +=============+=============================================================+ + | macOS | ``/Developer/NVIDIA/CUDA-X.Y`` | + +-------------+-------------------------------------------------------------+ + | Other Unix | ``/usr/local/cuda-X.Y`` | + +-------------+-------------------------------------------------------------+ + | Windows | ``C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\vX.Y`` | + +-------------+-------------------------------------------------------------+ + + Where ``X.Y`` would be a specific version of the CUDA Toolkit, such as + ``/usr/local/cuda-9.0`` or + ``C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0`` + + .. note:: + + When multiple CUDA Toolkits are installed in the default location of a + system (e.g., both ``/usr/local/cuda-9.0`` and ``/usr/local/cuda-10.0`` + exist but the ``/usr/local/cuda`` symbolic link does **not** exist), this + package is marked as **not** found. + + There are too many factors involved in making an automatic decision in + the presence of multiple CUDA Toolkits being installed. In this + situation, users are encouraged to either (1) set ``CUDAToolkit_ROOT`` or + (2) ensure that the correct ``nvcc`` executable shows up in ``$PATH`` for + :command:`find_program` to find. + +Options +^^^^^^^ + +``VERSION`` + If specified, describes the version of the CUDA Toolkit to search for. + +``REQUIRED`` + If specified, configuration will error if a suitable CUDA Toolkit is not + found. + +``QUIET`` + If specified, the search for a suitable CUDA Toolkit will not produce any + messages. + +``EXACT`` + If specified, the CUDA Toolkit is considered found only if the exact + ``VERSION`` specified is recovered. + +Imported targets +^^^^^^^^^^^^^^^^ + +An :ref:`imported target <Imported targets>` named ``CUDA::toolkit`` is provided. + +This module defines :prop_tgt:`IMPORTED` targets for each +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:`cuFFT<cuda_toolkit_cuFFT>` +- :ref:`cuRAND<cuda_toolkit_cuRAND>` +- :ref:`cuSOLVER<cuda_toolkit_cuSOLVER>` +- :ref:`cuSPARSE<cuda_toolkit_cuSPARSE>` +- :ref:`NPP<cuda_toolkit_NPP>` +- :ref:`nvBLAS<cuda_toolkit_nvBLAS>` +- :ref:`nvGRAPH<cuda_toolkit_nvGRAPH>` +- :ref:`nvJPEG<cuda_toolkit_nvJPEG>` +- :ref:`nvidia-ML<cuda_toolkit_nvML>` +- :ref:`nvRTC<cuda_toolkit_nvRTC>` +- :ref:`nvToolsExt<cuda_toolkit_nvToolsExt>` +- :ref:`OpenCL<cuda_toolkit_opencl>` +- :ref:`cuLIBOS<cuda_toolkit_cuLIBOS>` + +.. _`cuda_toolkit_rt_lib`: + +CUDA Runtime Library +"""""""""""""""""""" + +The CUDA Runtime library (cudart) are what most applications will typically +need to link against to make any calls such as `cudaMalloc`, and `cudaFree`. + +Targets Created: + +- ``CUDA::cudart`` +- ``CUDA::cudart_static`` + +.. _`cuda_toolkit_driver_lib`: + +CUDA Driver Library +"""""""""""""""""""" + +The CUDA Driver library (cuda) are used by applications that use calls +such as `cuMemAlloc`, and `cuMemFree`. This is generally used by advanced + + +Targets Created: + +- ``CUDA::cuda_driver`` +- ``CUDA::cuda_driver`` + +.. _`cuda_toolkit_cuBLAS`: + +cuBLAS +"""""" + +The `cuBLAS <https://docs.nvidia.com/cuda/cublas/index.html>`_ library. + +Targets Created: + +- ``CUDA::cublas`` +- ``CUDA::cublas_static`` + +.. _`cuda_toolkit_cuFFT`: + +cuFFT +""""" + +The `cuFFT <https://docs.nvidia.com/cuda/cufft/index.html>`_ library. + +Targets Created: + +- ``CUDA::cufft`` +- ``CUDA::cufftw`` +- ``CUDA::cufft_static`` +- ``CUDA::cufftw_static`` + +cuRAND +"""""" + +The `cuRAND <https://docs.nvidia.com/cuda/curand/index.html>`_ library. + +Targets Created: + +- ``CUDA::curand`` +- ``CUDA::curand_static`` + +.. _`cuda_toolkit_cuSOLVER`: + +cuSOLVER +"""""""" + +The `cuSOLVER <https://docs.nvidia.com/cuda/cusolver/index.html>`_ library. + +Targets Created: + +- ``CUDA::cusolver`` +- ``CUDA::cusolver_static`` + +.. _`cuda_toolkit_cuSPARSE`: + +cuSPARSE +"""""""" + +The `cuSPARSE <https://docs.nvidia.com/cuda/cusparse/index.html>`_ library. + +Targets Created: + +- ``CUDA::cusparse`` +- ``CUDA::cusparse_static`` + +.. _`cuda_toolkit_NPP`: + +NPP +""" + +The `NPP <https://docs.nvidia.com/cuda/npp/index.html>`_ libraries. + +Targets Created: + +- `nppc`: + + - ``CUDA::nppc`` + - ``CUDA::nppc_static`` + +- `nppial`: Arithmetic and logical operation functions in `nppi_arithmetic_and_logical_operations.h` + + - ``CUDA::nppial`` + - ``CUDA::nppial_static`` + +- `nppicc`: Color conversion and sampling functions in `nppi_color_conversion.h` + + - ``CUDA::nppicc`` + - ``CUDA::nppicc_static`` + +- `nppicom`: JPEG compression and decompression functions in `nppi_compression_functions.h` + + - ``CUDA::nppicom`` + - ``CUDA::nppicom_static`` + +- `nppidei`: Data exchange and initialization functions in `nppi_data_exchange_and_initialization.h` + + - ``CUDA::nppidei`` + - ``CUDA::nppidei_static`` + +- `nppif`: Filtering and computer vision functions in `nppi_filter_functions.h` + + - ``CUDA::nppif`` + - ``CUDA::nppif_static`` + +- `nppig`: Geometry transformation functions found in `nppi_geometry_transforms.h` + + - ``CUDA::nppig`` + - ``CUDA::nppig_static`` + +- `nppim`: Morphological operation functions found in `nppi_morphological_operations.h` + + - ``CUDA::nppim`` + - ``CUDA::nppim_static`` + +- `nppist`: Statistics and linear transform in `nppi_statistics_functions.h` and `nppi_linear_transforms.h` + + - ``CUDA::nppist`` + - ``CUDA::nppist_static`` + +- `nppisu`: Memory support functions in `nppi_support_functions.h` + + - ``CUDA::nppisu`` + - ``CUDA::nppisu_static`` + +- `nppitc`: Threshold and compare operation functions in `nppi_threshold_and_compare_operations.h` + + - ``CUDA::nppitc`` + - ``CUDA::nppitc_static`` + +- `npps`: + + - ``CUDA::npps`` + - ``CUDA::npps_static`` + +.. _`cuda_toolkit_nvBLAS`: + +nvBLAS +"""""" + +The `nvBLAS <https://docs.nvidia.com/cuda/nvblas/index.html>`_ libraries. +This is a shared library only. + +Targets Created: + +- ``CUDA::nvblas`` + +.. _`cuda_toolkit_nvGRAPH`: + +nvGRAPH +""""""" + +The `nvGRAPH <https://docs.nvidia.com/cuda/nvgraph/index.html>`_ library. + +Targets Created: + +- ``CUDA::nvgraph`` +- ``CUDA::nvgraph_static`` + + +.. _`cuda_toolkit_nvJPEG`: + +nvJPEG +"""""" + +The `nvJPEG <https://docs.nvidia.com/cuda/nvjpeg/index.html>`_ library. +Introduced in CUDA 10. + +Targets Created: + +- ``CUDA::nvjpeg`` +- ``CUDA::nvjpeg_static`` + +.. _`cuda_toolkit_nvRTC`: + +nvRTC +""""" + +The `nvRTC <https://docs.nvidia.com/cuda/nvrtc/index.html>`_ (Runtime Compilation) library. +This is a shared library only. + +Targets Created: + +- ``CUDA::nvrtc`` + +.. _`cuda_toolkit_nvml`: + +nvidia-ML +""""""""" + +The `NVIDIA Management Library <https://developer.nvidia.com/nvidia-management-library-nvml>`_. +This is a shared library only. + +Targets Created: + +- ``CUDA::nvml`` + +.. _`cuda_toolkit_opencl`: + +.. _`cuda_toolkit_nvToolsExt`: + +nvToolsExt +"""""""""" + +The `NVIDIA Tools Extension <https://docs.nvidia.com/gameworks/content/gameworkslibrary/nvtx/nvidia_tools_extension_library_nvtx.htm>`_. +This is a shared library only. + +Targets Created: + +- ``CUDA::nvToolsExt`` + +OpenCL +"""""" + +The `NVIDIA OpenCL Library <https://developer.nvidia.com/opencl>`_. +This is a shared library only. + +Targets Created: + +- ``CUDA::OpenCL`` + +.. _`cuda_toolkit_cuLIBOS`: + +cuLIBOS +""""""" + +The cuLIBOS library is a backend thread abstraction layer library which is +static only. The ``CUDA::cublas_static``, ``CUDA::cusparse_static``, +``CUDA::cufft_static``, ``CUDA::curand_static``, and (when implemented) NPP +libraries all automatically have this dependency linked. + +Target Created: + +- ``CUDA::culibos`` + +**Note**: direct usage of this target by consumers should not be necessary. + +.. _`cuda_toolkit_cuRAND`: + + + +Result variables +^^^^^^^^^^^^^^^^ + +``CUDAToolkit_FOUND`` + A boolean specifying whether or not the CUDA Toolkit was found. + +``CUDAToolkit_VERSION`` + The exact version of the CUDA Toolkit found (as reported by + ``nvcc --version``). + +``CUDAToolkit_VERSION_MAJOR`` + The major version of the CUDA Toolkit. + +``CUDAToolkit_VERSION_MAJOR`` + The minor version of the CUDA Toolkit. + +``CUDAToolkit_VERSION_PATCH`` + The patch version of the CUDA Toolkit. + +``CUDAToolkit_BIN_DIR`` + The path to the CUDA Toolkit library directory that contains the CUDA + executable ``nvcc``. + +``CUDAToolkit_INCLUDE_DIRS`` + The path to the CUDA Toolkit ``include`` folder containing the header files + required to compile a project linking against CUDA. + +``CUDAToolkit_LIBRARY_DIR`` + The path to the CUDA Toolkit library directory that contains the CUDA + Runtime library ``cudart``. + +``CUDAToolkit_TARGET_DIR`` + The path to the CUDA Toolkit directory including the target architecture + when cross-compiling. When not cross-compiling this will be equivalant to + ``CUDAToolkit_ROOT_DIR``. + +``CUDAToolkit_NVCC_EXECUTABLE`` + The path to the NVIDIA CUDA compiler ``nvcc``. Note that this path may + **not** be the same as + :variable:`CMAKE_CUDA_COMPILER <CMAKE_<LANG>_COMPILER>`. ``nvcc`` must be + found to determine the CUDA Toolkit version as well as determining other + features of the Toolkit. This variable is set for the convenience of + modules that depend on this one. + + +#]=======================================================================] + +# NOTE: much of this was simply extracted from FindCUDA.cmake. + +# James Bigler, NVIDIA Corp (nvidia.com - jbigler) +# Abe Stephens, SCI Institute -- http://www.sci.utah.edu/~abe/FindCuda.html +# +# Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved. +# +# Copyright (c) 2007-2009 +# Scientific Computing and Imaging Institute, University of Utah +# +# This code is licensed under the MIT License. See the FindCUDA.cmake script +# for the text of the license. + +# The MIT License +# +# License for the specific language governing rights and limitations under +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# +############################################################################### + +if(CMAKE_CUDA_COMPILER_LOADED AND NOT CUDAToolkit_BIN_DIR) + get_filename_component(cuda_dir "${CMAKE_CUDA_COMPILER}" DIRECTORY) + # use the already detected cuda compiler + set(CUDAToolkit_BIN_DIR "${cuda_dir}" CACHE PATH "") + unset(cuda_dir) +endif() + +# Try language- or user-provided path first. +if(CUDAToolkit_BIN_DIR) + find_program(CUDAToolkit_NVCC_EXECUTABLE + NAMES nvcc nvcc.exe + PATHS ${CUDAToolkit_BIN_DIR} + NO_DEFAULT_PATH + ) +endif() + +# Search using CUDAToolkit_ROOT +find_program(CUDAToolkit_NVCC_EXECUTABLE + NAMES nvcc nvcc.exe + PATHS ENV CUDA_PATH + PATH_SUFFIXES bin +) + +# If the user specified CUDAToolkit_ROOT but nvcc could not be found, this is an error. +if (NOT CUDAToolkit_NVCC_EXECUTABLE AND (DEFINED CUDAToolkit_ROOT OR DEFINED ENV{CUDAToolkit_ROOT})) + # Declare error messages now, print later depending on find_package args. + set(fail_base "Could not find nvcc executable in path specified by") + set(cuda_root_fail "${fail_base} CUDAToolkit_ROOT=${CUDAToolkit_ROOT}") + set(env_cuda_root_fail "${fail_base} environment variable CUDAToolkit_ROOT=$ENV{CUDAToolkit_ROOT}") + + if (CUDAToolkit_FIND_REQUIRED) + if (DEFINED CUDAToolkit_ROOT) + message(FATAL_ERROR ${cuda_root_fail}) + elseif (DEFINED ENV{CUDAToolkit_ROOT}) + message(FATAL_ERROR ${env_cuda_root_fail}) + endif() + else() + if (NOT CUDAToolkit_FIND_QUIETLY) + if (DEFINED CUDAToolkit_ROOT) + message(STATUS ${cuda_root_fail}) + elseif (DEFINED ENV{CUDAToolkit_ROOT}) + message(STATUS ${env_cuda_root_fail}) + endif() + endif() + set(CUDAToolkit_FOUND FALSE) + unset(fail_base) + unset(cuda_root_fail) + unset(env_cuda_root_fail) + return() + endif() +endif() + +# CUDAToolkit_ROOT cmake / env variable not specified, try platform defaults. +# +# - Linux: /usr/local/cuda-X.Y +# - macOS: /Developer/NVIDIA/CUDA-X.Y +# - Windows: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\vX.Y +# +# We will also search the default symlink location /usr/local/cuda first since +# if CUDAToolkit_ROOT is not specified, it is assumed that the symlinked +# directory is the desired location. +if (NOT CUDAToolkit_NVCC_EXECUTABLE) + if (UNIX) + if (NOT APPLE) + set(platform_base "/usr/local/cuda-") + else() + set(platform_base "/Developer/NVIDIA/CUDA-") + endif() + else() + set(platform_base "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v") + endif() + + # Build out a descending list of possible cuda installations, e.g. + file(GLOB possible_paths "${platform_base}*") + # Iterate the glob results and create a descending list. + set(possible_versions) + foreach (p ${possible_paths}) + # Extract version number from end of string + string(REGEX MATCH "[0-9][0-9]?\\.[0-9]$" p_version ${p}) + if (IS_DIRECTORY ${p} AND p_version) + list(APPEND possible_versions ${p_version}) + endif() + endforeach() + + # Cannot use list(SORT) because that is alphabetical, we need numerical. + # NOTE: this is not an efficient sorting strategy. But even if a user had + # every possible version of CUDA installed, this wouldn't create any + # significant overhead. + set(versions) + foreach (v ${possible_versions}) + list(LENGTH versions num_versions) + # First version, nothing to compare with so just append. + if (num_versions EQUAL 0) + list(APPEND versions ${v}) + else() + # Loop through list. Insert at an index when comparison is + # VERSION_GREATER since we want a descending list. Duplicates will not + # happen since this came from a glob list of directories. + set(i 0) + set(early_terminate FALSE) + while (i LESS num_versions) + list(GET versions ${i} curr) + if (v VERSION_GREATER curr) + list(INSERT versions ${i} ${v}) + set(early_terminate TRUE) + break() + endif() + math(EXPR i "${i} + 1") + endwhile() + # If it did not get inserted, place it at the end. + if (NOT early_terminate) + list(APPEND versions ${v}) + endif() + endif() + endforeach() + + # With a descending list of versions, populate possible paths to search. + set(search_paths) + foreach (v ${versions}) + list(APPEND search_paths "${platform_base}${v}") + endforeach() + + # Force the global default /usr/local/cuda to the front on Unix. + if (UNIX) + list(INSERT search_paths 0 "/usr/local/cuda") + endif() + + # Now search for nvcc again using the platform default search paths. + find_program(CUDAToolkit_NVCC_EXECUTABLE + NAMES nvcc nvcc.exe + PATHS ${search_paths} + PATH_SUFFIXES bin + ) + + # We are done with these variables now, cleanup for caller. + unset(platform_base) + unset(possible_paths) + unset(possible_versions) + unset(versions) + unset(i) + unset(early_terminate) + unset(search_paths) + + if (NOT CUDAToolkit_NVCC_EXECUTABLE) + if (CUDAToolkit_FIND_REQUIRED) + message(FATAL_ERROR "Could not find nvcc, please set CUDAToolkit_ROOT.") + elseif(NOT CUDAToolkit_FIND_QUIETLY) + message(STATUS "Could not find nvcc, please set CUDAToolkit_ROOT.") + endif() + + set(CUDAToolkit_FOUND FALSE) + return() + endif() +endif() + +if(NOT CUDAToolkit_BIN_DIR AND CUDAToolkit_NVCC_EXECUTABLE) + get_filename_component(cuda_dir "${CUDAToolkit_NVCC_EXECUTABLE}" DIRECTORY) + set(CUDAToolkit_BIN_DIR "${cuda_dir}" CACHE PATH "" FORCE) + unset(cuda_dir) +endif() + +if(CUDAToolkit_NVCC_EXECUTABLE AND + CUDAToolkit_NVCC_EXECUTABLE STREQUAL CMAKE_CUDA_COMPILER) + # Need to set these based off the already computed CMAKE_CUDA_COMPILER_VERSION value + # This if statement will always match, but is used to provide variables for MATCH 1,2,3... + if(CMAKE_CUDA_COMPILER_VERSION MATCHES [=[([0-9]+)\.([0-9]+)\.([0-9]+)]=]) + set(CUDAToolkit_VERSION_MAJOR "${CMAKE_MATCH_1}") + set(CUDAToolkit_VERSION_MINOR "${CMAKE_MATCH_2}") + set(CUDAToolkit_VERSION_PATCH "${CMAKE_MATCH_3}") + set(CUDAToolkit_VERSION "${CMAKE_CUDA_COMPILER_VERSION}") + endif() +else() + # Compute the version by invoking nvcc + execute_process (COMMAND ${CUDAToolkit_NVCC_EXECUTABLE} "--version" OUTPUT_VARIABLE NVCC_OUT) + if(NVCC_OUT MATCHES [=[ V([0-9]+)\.([0-9]+)\.([0-9]+)]=]) + set(CUDAToolkit_VERSION_MAJOR "${CMAKE_MATCH_1}") + set(CUDAToolkit_VERSION_MINOR "${CMAKE_MATCH_2}") + set(CUDAToolkit_VERSION_PATCH "${CMAKE_MATCH_3}") + set(CUDAToolkit_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}") + endif() + unset(NVCC_OUT) +endif() + + +get_filename_component(CUDAToolkit_ROOT_DIR ${CUDAToolkit_BIN_DIR} DIRECTORY ABSOLUTE) + +# Handle cross compilation +if(CMAKE_CROSSCOMPILING) + if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a") + # Support for NVPACK + set (CUDAToolkit_TARGET_NAME "armv7-linux-androideabi") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm") + # Support for arm cross compilation + set(CUDAToolkit_TARGET_NAME "armv7-linux-gnueabihf") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") + # Support for aarch64 cross compilation + if (ANDROID_ARCH_NAME STREQUAL "arm64") + set(CUDAToolkit_TARGET_NAME "aarch64-linux-androideabi") + else() + set(CUDAToolkit_TARGET_NAME "aarch64-linux") + endif (ANDROID_ARCH_NAME STREQUAL "arm64") + elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + set(CUDAToolkit_TARGET_NAME "x86_64-linux") + endif() + + if (EXISTS "${CUDAToolkit_ROOT_DIR}/targets/${CUDAToolkit_TARGET_NAME}") + set(CUDAToolkit_TARGET_DIR "${CUDAToolkit_ROOT_DIR}/targets/${CUDAToolkit_TARGET_NAME}") + # add known CUDA target root path to the set of directories we search for programs, libraries and headers + list(PREPEND CMAKE_FIND_ROOT_PATH "${CUDAToolkit_TARGET_DIR}") + + # Mark that we need to pop the root search path changes after we have + # found all cuda libraries so that searches for our cross-compilation + # libraries work when another cuda sdk is in CMAKE_PREFIX_PATH or + # PATh + set(_CUDAToolkit_Pop_ROOT_PATH True) + endif() +else() + # Not cross compiling + set(CUDAToolkit_TARGET_DIR "${CUDAToolkit_ROOT_DIR}") + # Now that we have the real ROOT_DIR, find components inside it. + list(APPEND CMAKE_PREFIX_PATH ${CUDAToolkit_ROOT_DIR}) + + # Mark that we need to pop the prefix path changes after we have + # found the cudart library. + set(_CUDAToolkit_Pop_Prefix True) +endif() + + +# Find the include/ directory +find_path(CUDAToolkit_INCLUDE_DIR + NAMES cuda_runtime.h +) + +# And find the CUDA Runtime Library libcudart +find_library(CUDA_CUDART + NAMES cudart + PATH_SUFFIXES lib64 lib64/stubs lib/x64 +) +if (NOT CUDA_CUDART AND NOT CUDAToolkit_FIND_QUIETLY) + message(STATUS "Unable to find cudart library.") +endif() + +unset(CUDAToolkit_ROOT_DIR) +if(_CUDAToolkit_Pop_Prefix) + list(REMOVE_AT CMAKE_PREFIX_PATH -1) + unset(_CUDAToolkit_Pop_Prefix) +endif() + +#----------------------------------------------------------------------------- +# Perform version comparison and validate all required variables are set. +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +find_package_handle_standard_args(CUDAToolkit + REQUIRED_VARS + CUDAToolkit_INCLUDE_DIR + CUDA_CUDART + CUDAToolkit_NVCC_EXECUTABLE + VERSION_VAR + CUDAToolkit_VERSION +) + +#----------------------------------------------------------------------------- +# Construct result variables +if(CUDAToolkit_FOUND) + set(CUDAToolkit_INCLUDE_DIRS ${CUDAToolkit_INCLUDE_DIR}) + get_filename_component(CUDAToolkit_LIBRARY_DIR ${CUDA_CUDART} DIRECTORY ABSOLUTE) +endif() + +#----------------------------------------------------------------------------- +# Construct import targets +if(CUDAToolkit_FOUND) + + function(_CUDAToolkit_find_and_add_import_lib lib_name) + cmake_parse_arguments(arg "" "" "ALT;DEPS" ${ARGN}) + + set(search_names ${lib_name} ${arg_ALT}) + + find_library(CUDA_${lib_name}_LIBRARY + NAMES ${search_names} + HINTS ${CUDAToolkit_LIBRARY_DIR} + ENV CUDA_PATH + PATH_SUFFIXES nvidia/current lib64 lib64/stubs lib/x64 lib lib/stubs + ) + + if (NOT TARGET CUDA::${lib_name} AND CUDA_${lib_name}_LIBRARY) + add_library(CUDA::${lib_name} IMPORTED INTERFACE) + target_include_directories(CUDA::${lib_name} SYSTEM INTERFACE "${CUDAToolkit_INCLUDE_DIRS}") + target_link_libraries(CUDA::${lib_name} INTERFACE "${CUDA_${lib_name}_LIBRARY}") + foreach(dep ${arg_DEPS}) + if(TARGET CUDA::${dep}) + target_link_libraries(CUDA::${lib_name} INTERFACE CUDA::${dep}) + endif() + endforeach() + endif() + endfunction() + + if(NOT TARGET CUDA::toolkit) + add_library(CUDA::toolkit IMPORTED INTERFACE) + target_include_directories(CUDA::toolkit SYSTEM INTERFACE "${CUDAToolkit_INCLUDE_DIRS}") + target_link_directories(CUDA::toolkit INTERFACE "${CUDAToolkit_LIBRARY_DIR}") + endif() + + _CUDAToolkit_find_and_add_import_lib(cuda_driver ALT cuda) + + _CUDAToolkit_find_and_add_import_lib(cudart) + _CUDAToolkit_find_and_add_import_lib(cudart_static) + + # setup dependencies that are required for cudart_static when building + # on linux. These are generally only required when using the CUDA toolkit + # when CUDA language is disabled + if(NOT TARGET CUDA::cudart_static_deps + AND TARGET CUDA::cudart_static) + + add_library(CUDA::cudart_static_deps IMPORTED INTERFACE) + target_link_libraries(CUDA::cudart_static INTERFACE CUDA::cudart_static_deps) + + if(UNIX AND (CMAKE_C_COMPILER OR CMAKE_CXX_COMPILER)) + find_package(Threads REQUIRED) + target_link_libraries(CUDA::cudart_static_deps INTERFACE Threads::Threads ${CMAKE_DL_LIBS}) + endif() + + if(UNIX AND NOT APPLE) + # On Linux, you must link against librt when using the static cuda runtime. + find_library(CUDAToolkit_rt_LIBRARY rt) + if(NOT CUDAToolkit_rt_LIBRARY) + message(WARNING "Could not find librt library, needed by CUDA::cudart_static") + else() + target_link_libraries(CUDA::cudart_static_deps INTERFACE ${CUDAToolkit_rt_LIBRARY}) + endif() + endif() + endif() + + _CUDAToolkit_find_and_add_import_lib(culibos) # it's a static library + foreach (cuda_lib cublas cufft curand cusparse nppc nvjpeg) + _CUDAToolkit_find_and_add_import_lib(${cuda_lib}) + _CUDAToolkit_find_and_add_import_lib(${cuda_lib}_static DEPS culibos) + endforeach() + + # cuFFTW depends on cuFFT + _CUDAToolkit_find_and_add_import_lib(cufftw DEPS cufft) + _CUDAToolkit_find_and_add_import_lib(cufftw DEPS cufft_static) + + # cuSOLVER depends on cuBLAS, and cuSPARSE + _CUDAToolkit_find_and_add_import_lib(cusolver DEPS cublas cusparse) + _CUDAToolkit_find_and_add_import_lib(cusolver_static DEPS cublas_static cusparse_static culibos) + + # nvGRAPH depends on cuRAND, and cuSOLVER. + _CUDAToolkit_find_and_add_import_lib(nvgraph DEPS curand cusolver) + _CUDAToolkit_find_and_add_import_lib(nvgraph_static DEPS curand_static cusolver_static) + + # Process the majority of the NPP libraries. + foreach (cuda_lib nppial nppicc nppidei nppif nppig nppim nppist nppitc npps nppicom nppisu) + _CUDAToolkit_find_and_add_import_lib(${cuda_lib} DEPS nppc) + _CUDAToolkit_find_and_add_import_lib(${cuda_lib}_static DEPS nppc_static) + endforeach() + + _CUDAToolkit_find_and_add_import_lib(nvrtc DEPS cuda_driver) + + _CUDAToolkit_find_and_add_import_lib(nvml ALT nvidia-ml nvml) + + if(WIN32) + # nvtools can be installed outside the CUDA toolkit directory + # so prefer the NVTOOLSEXT_PATH windows only environment variable + # In addition on windows the most common name is nvToolsExt64_1 + find_library(CUDA_nvToolsExt_LIBRARY + NAMES nvToolsExt64_1 nvToolsExt64 nvToolsExt + PATHS ENV NVTOOLSEXT_PATH + ENV CUDA_PATH + PATH_SUFFIXES lib/x64 lib + ) + endif() + _CUDAToolkit_find_and_add_import_lib(nvToolsExt ALT nvToolsExt64) + + _CUDAToolkit_find_and_add_import_lib(OpenCL) +endif() + +if(_CUDAToolkit_Pop_ROOT_PATH) + list(REMOVE_AT CMAKE_FIND_ROOT_PATH 0) + unset(_CUDAToolkit_Pop_ROOT_PATH) +endif() diff --git a/Modules/FindCURL.cmake b/Modules/FindCURL.cmake index aeebc84..919babc 100644 --- a/Modules/FindCURL.cmake +++ b/Modules/FindCURL.cmake @@ -37,8 +37,35 @@ This module defines the following variables: ``CURL_VERSION_STRING`` The version of ``curl`` found. + +CURL CMake +^^^^^^^^^^ + +If CURL was built using the CMake buildsystem then it provides its own +``CURLConfig.cmake`` file for use with the :command:`find_package` command's +config mode. This module looks for this file and, if found, +returns its results with no further action. + +Set ``CURL_NO_CURL_CMAKE`` to ``ON`` to disable this search. + #]=======================================================================] +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) + +if(NOT CURL_NO_CURL_CMAKE) + # do a find package call to specifically look for the CMake version + # of curl + find_package(CURL QUIET NO_MODULE) + mark_as_advanced(CURL_DIR) + + # if we found the CURL cmake package then we are done, and + # can print what we found and return. + if(CURL_FOUND) + find_package_handle_standard_args(CURL HANDLE_COMPONENTS CONFIG_MODE) + return() + endif() +endif() + find_package(PkgConfig QUIET) if(PKG_CONFIG_FOUND) pkg_check_modules(PC_CURL QUIET libcurl) @@ -139,7 +166,6 @@ if(CURL_FIND_COMPONENTS) endforeach() endif() -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) find_package_handle_standard_args(CURL REQUIRED_VARS CURL_LIBRARY CURL_INCLUDE_DIR VERSION_VAR CURL_VERSION_STRING diff --git a/Modules/FindCurses.cmake b/Modules/FindCurses.cmake index e3e7273..ba56078 100644 --- a/Modules/FindCurses.cmake +++ b/Modules/FindCurses.cmake @@ -159,6 +159,10 @@ if(CURSES_USE_NCURSES) if(NOT CURSES_NCURSES_HAS_CBREAK) find_library(CURSES_EXTRA_LIBRARY "${CURSES_TINFO_LIBRARY_NAME}" HINTS "${_cursesLibDir}") find_library(CURSES_EXTRA_LIBRARY "${CURSES_TINFO_LIBRARY_NAME}" ) + + mark_as_advanced( + CURSES_EXTRA_LIBRARY + ) endif() else() get_filename_component(_cursesLibDir "${CURSES_CURSES_LIBRARY}" PATH) @@ -262,6 +266,5 @@ mark_as_advanced( CURSES_INCLUDE_PATH CURSES_CURSES_LIBRARY CURSES_NCURSES_LIBRARY - CURSES_EXTRA_LIBRARY CURSES_FORM_LIBRARY ) diff --git a/Modules/FindDCMTK.cmake b/Modules/FindDCMTK.cmake index d48de08..b2e00df 100644 --- a/Modules/FindDCMTK.cmake +++ b/Modules/FindDCMTK.cmake @@ -102,7 +102,7 @@ set(_SAVED_DCMTK_DIR ${DCMTK_DIR}) # Step1: Attempt to find a version of DCMTK providing a DCMTKConfig.cmake file. # if(NOT DCMTK_FIND_QUIETLY) - message(STATUS "Trying to find DCMTK expecting DCMTKConfig.cmake") + message(CHECK_START "Trying to find DCMTK expecting DCMTKConfig.cmake") endif() find_package(DCMTK QUIET NO_MODULE) if(DCMTK_FOUND @@ -110,12 +110,12 @@ if(DCMTK_FOUND AND NOT "x" STREQUAL "x${DCMTK_INCLUDE_DIRS}") if(NOT DCMTK_FIND_QUIETLY) - message(STATUS "Trying to find DCMTK expecting DCMTKConfig.cmake - ok") + message(CHECK_PASS "ok") endif() return() else() if(NOT DCMTK_FIND_QUIETLY) - message(STATUS "Trying to find DCMTK expecting DCMTKConfig.cmake - failed") + message(CHECK_FAIL "failed") endif() endif() diff --git a/Modules/FindFLEX.cmake b/Modules/FindFLEX.cmake index d22b7ec..90e5f86 100644 --- a/Modules/FindFLEX.cmake +++ b/Modules/FindFLEX.cmake @@ -142,8 +142,6 @@ if(FLEX_EXECUTABLE) #============================================================ # macro(FLEX_TARGET Name Input Output) - set(FLEX_TARGET_outputs "${Output}") - set(FLEX_EXECUTABLE_opts "") set(FLEX_TARGET_PARAM_OPTIONS) set(FLEX_TARGET_PARAM_ONE_VALUE_KEYWORDS @@ -165,31 +163,68 @@ if(FLEX_EXECUTABLE) if(NOT "${FLEX_TARGET_ARG_UNPARSED_ARGUMENTS}" STREQUAL "") message(SEND_ERROR ${FLEX_TARGET_usage}) else() + + cmake_policy(GET CMP0098 _flex_CMP0098 + PARENT_SCOPE # undocumented, do not use outside of CMake + ) + set(_flex_INPUT "${Input}") + if("x${_flex_CMP0098}x" STREQUAL "xNEWx") + set(_flex_WORKING_DIR "${CMAKE_CURRENT_BINARY_DIR}") + if(NOT IS_ABSOLUTE "${_flex_INPUT}") + set(_flex_INPUT "${CMAKE_CURRENT_SOURCE_DIR}/${_flex_INPUT}") + endif() + else() + set(_flex_WORKING_DIR "${CMAKE_CURRENT_SOURCE_DIR}") + endif() + unset(_flex_CMP0098) + + set(_flex_OUTPUT "${Output}") + if(NOT IS_ABSOLUTE ${_flex_OUTPUT}) + set(_flex_OUTPUT "${_flex_WORKING_DIR}/${_flex_OUTPUT}") + endif() + set(_flex_TARGET_OUTPUTS "${_flex_OUTPUT}") + + set(_flex_EXE_OPTS "") if(NOT "${FLEX_TARGET_ARG_COMPILE_FLAGS}" STREQUAL "") - set(FLEX_EXECUTABLE_opts "${FLEX_TARGET_ARG_COMPILE_FLAGS}") - separate_arguments(FLEX_EXECUTABLE_opts) + set(_flex_EXE_OPTS "${FLEX_TARGET_ARG_COMPILE_FLAGS}") + separate_arguments(_flex_EXE_OPTS) endif() + + set(_flex_OUTPUT_HEADER "") if(NOT "${FLEX_TARGET_ARG_DEFINES_FILE}" STREQUAL "") - list(APPEND FLEX_TARGET_outputs "${FLEX_TARGET_ARG_DEFINES_FILE}") - list(APPEND FLEX_EXECUTABLE_opts --header-file=${FLEX_TARGET_ARG_DEFINES_FILE}) + set(_flex_OUTPUT_HEADER "${FLEX_TARGET_ARG_DEFINES_FILE}") + if(IS_ABSOLUTE "${_flex_OUTPUT_HEADER}") + set(_flex_OUTPUT_HEADER_ABS "${_flex_OUTPUT_HEADER}") + else() + set(_flex_OUTPUT_HEADER_ABS "${_flex_WORKING_DIR}/${_flex_OUTPUT_HEADER}") + endif() + list(APPEND _flex_TARGET_OUTPUTS "${_flex_OUTPUT_HEADER_ABS}") + list(APPEND _flex_EXE_OPTS --header-file=${_flex_OUTPUT_HEADER_ABS}) endif() - add_custom_command(OUTPUT ${FLEX_TARGET_outputs} - COMMAND ${FLEX_EXECUTABLE} ${FLEX_EXECUTABLE_opts} -o${Output} ${Input} + get_filename_component(_flex_EXE_NAME_WE "${FLEX_EXECUTABLE}" NAME_WE) + add_custom_command(OUTPUT ${_flex_TARGET_OUTPUTS} + COMMAND ${FLEX_EXECUTABLE} ${_flex_EXE_OPTS} -o${_flex_OUTPUT} ${_flex_INPUT} VERBATIM - DEPENDS ${Input} - COMMENT "[FLEX][${Name}] Building scanner with flex ${FLEX_VERSION}" - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + DEPENDS ${_flex_INPUT} + COMMENT "[FLEX][${Name}] Building scanner with ${_flex_EXE_NAME_WE} ${FLEX_VERSION}" + WORKING_DIRECTORY ${_flex_WORKING_DIR}) set(FLEX_${Name}_DEFINED TRUE) - set(FLEX_${Name}_OUTPUTS ${Output}) - set(FLEX_${Name}_INPUT ${Input}) - set(FLEX_${Name}_COMPILE_FLAGS ${FLEX_EXECUTABLE_opts}) - if("${FLEX_TARGET_ARG_DEFINES_FILE}" STREQUAL "") - set(FLEX_${Name}_OUTPUT_HEADER "") - else() - set(FLEX_${Name}_OUTPUT_HEADER ${FLEX_TARGET_ARG_DEFINES_FILE}) - endif() + set(FLEX_${Name}_OUTPUTS ${_flex_TARGET_OUTPUTS}) + set(FLEX_${Name}_INPUT ${_flex_INPUT}) + set(FLEX_${Name}_COMPILE_FLAGS ${_flex_EXE_OPTS}) + set(FLEX_${Name}_OUTPUT_HEADER ${_flex_OUTPUT_HEADER}) + + unset(_flex_EXE_NAME_WE) + unset(_flex_EXE_OPTS) + unset(_flex_INPUT) + unset(_flex_OUTPUT) + unset(_flex_OUTPUT_HEADER) + unset(_flex_OUTPUT_HEADER_ABS) + unset(_flex_TARGET_OUTPUTS) + unset(_flex_WORKING_DIR) + endif() endmacro() #============================================================ diff --git a/Modules/FindGTK2.cmake b/Modules/FindGTK2.cmake index 83091f3..565763d 100644 --- a/Modules/FindGTK2.cmake +++ b/Modules/FindGTK2.cmake @@ -5,96 +5,83 @@ FindGTK2 -------- -Find the GTK2 widget libraries and several of its -other optional components like ``gtkmm``, ``glade``, and ``glademm``. - -NOTE: If you intend to use version checking, CMake 2.6.2 or later is - -:: - - required. - - +Find the GTK2 widget libraries and several of its other optional components +like ``gtkmm``, ``glade``, and ``glademm``. Specify one or more of the following components as you call this find module. See example below. -:: - - gtk - gtkmm - glade - glademm - +* ``gtk`` +* ``gtkmm`` +* ``glade`` +* ``glademm`` +Result Variables +^^^^^^^^^^^^^^^^ The following variables will be defined for your use -:: - - GTK2_FOUND - Were all of your specified components found? - GTK2_INCLUDE_DIRS - All include directories - GTK2_LIBRARIES - All libraries - GTK2_TARGETS - All imported targets - GTK2_DEFINITIONS - Additional compiler flags - - - -:: - - GTK2_VERSION - The version of GTK2 found (x.y.z) - GTK2_MAJOR_VERSION - The major version of GTK2 - GTK2_MINOR_VERSION - The minor version of GTK2 - GTK2_PATCH_VERSION - The patch version of GTK2 - - +``GTK2_FOUND`` + Were all of your specified components found? +``GTK2_INCLUDE_DIRS`` + All include directories +``GTK2_LIBRARIES`` + All libraries +``GTK2_TARGETS`` + All imported targets +``GTK2_DEFINITIONS`` + Additional compiler flags +``GTK2_VERSION`` + The version of GTK2 found (x.y.z) +``GTK2_MAJOR_VERSION`` + The major version of GTK2 +``GTK2_MINOR_VERSION`` + The minor version of GTK2 +``GTK2_PATCH_VERSION`` + The patch version of GTK2 + +Input Variables +^^^^^^^^^^^^^^^ Optional variables you can define prior to calling this module: -:: - - GTK2_DEBUG - Enables verbose debugging of the module - GTK2_ADDITIONAL_SUFFIXES - Allows defining additional directories to - search for include files - - - -================= Example Usage: - -:: - - Call find_package() once, here are some examples to pick from: - - +``GTK2_DEBUG`` + Enables verbose debugging of the module +``GTK2_ADDITIONAL_SUFFIXES`` + Allows defining additional directories to search for include files -:: +Example Usage +^^^^^^^^^^^^^ - Require GTK 2.6 or later - find_package(GTK2 2.6 REQUIRED gtk) +Call :command:`find_package` once. Here are some examples to pick from: +Require GTK 2.6 or later: +.. code-block:: cmake -:: + find_package(GTK2 2.6 REQUIRED gtk) - Require GTK 2.10 or later and Glade - find_package(GTK2 2.10 REQUIRED gtk glade) +Require GTK 2.10 or later and Glade: +.. code-block:: cmake + find_package(GTK2 2.10 REQUIRED gtk glade) -:: +Search for GTK/GTKMM 2.8 or later: - Search for GTK/GTKMM 2.8 or later - find_package(GTK2 2.8 COMPONENTS gtk gtkmm) +.. code-block:: cmake + find_package(GTK2 2.8 COMPONENTS gtk gtkmm) +Use the results: -:: +.. code-block:: cmake - if(GTK2_FOUND) - include_directories(${GTK2_INCLUDE_DIRS}) - add_executable(mygui mygui.cc) - target_link_libraries(mygui ${GTK2_LIBRARIES}) - endif() + if(GTK2_FOUND) + include_directories(${GTK2_INCLUDE_DIRS}) + add_executable(mygui mygui.cc) + target_link_libraries(mygui ${GTK2_LIBRARIES}) + endif() #]=======================================================================] # Version 1.6 (CMake 3.0) @@ -881,6 +868,7 @@ foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) set(GTK2_${_COMPONENT_UPPER}_FIND_QUIETLY ${GTK2_FIND_QUIETLY}) + set(FPHSA_NAME_MISMATCHED 1) if(_GTK2_component STREQUAL "gtk") FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK2_${_COMPONENT_UPPER} "Some or all of the gtk libraries were not found." GTK2_GTK_LIBRARY @@ -923,6 +911,7 @@ foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) GTK2_GLADEMMCONFIG_INCLUDE_DIR ) endif() + unset(FPHSA_NAME_MISMATCHED) if(NOT GTK2_${_COMPONENT_UPPER}_FOUND) set(_GTK2_did_we_find_everything false) diff --git a/Modules/FindGTest.cmake b/Modules/FindGTest.cmake index e015a98..53cab1a 100644 --- a/Modules/FindGTest.cmake +++ b/Modules/FindGTest.cmake @@ -240,4 +240,15 @@ if(GTEST_FOUND) __gtest_import_library(GTest::Main GTEST_MAIN_LIBRARY "RELEASE") __gtest_import_library(GTest::Main GTEST_MAIN_LIBRARY "DEBUG") endif() + + # Add targets mapping the same library names as defined in + # GTest's CMake package config. + if(NOT TARGET GTest::gtest) + add_library(GTest::gtest INTERFACE IMPORTED) + target_link_libraries(GTest::gtest INTERFACE GTest::GTest) + endif() + if(NOT TARGET GTest::gtest_main) + add_library(GTest::gtest_main INTERFACE IMPORTED) + target_link_libraries(GTest::gtest_main INTERFACE GTest::Main) + endif() endif() diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 3cb3653..c962976 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -7,10 +7,10 @@ FindLAPACK Find Linear Algebra PACKage (LAPACK) library -This module finds an installed fortran library that implements the +This module finds an installed Fortran library that implements the LAPACK linear-algebra interface (see http://www.netlib.org/lapack/). -The approach follows that taken for the autoconf macro file, +The approach follows that taken for the ``autoconf`` macro file, ``acx_lapack.m4`` (distributed at http://ac-archive.sourceforge.net/ac-archive/acx_lapack.html). @@ -26,21 +26,22 @@ The following variables may be set to influence this module's behavior: If set, checks only the specified vendor, if not set checks all the possibilities. List of vendors valid in this module: + * ``OpenBLAS`` + * ``FLAME`` * ``Intel10_32`` (intel mkl v10 32 bit) * ``Intel10_64lp`` (intel mkl v10+ 64 bit, threaded code, lp64 model) * ``Intel10_64lp_seq`` (intel mkl v10+ 64 bit, sequential code, lp64 model) * ``Intel10_64ilp`` (intel mkl v10+ 64 bit, threaded code, ilp64 model) * ``Intel10_64ilp_seq`` (intel mkl v10+ 64 bit, sequential code, ilp64 model) + * ``Intel10_64_dyn`` (intel mkl v10+ 64 bit, single dynamic library) * ``Intel`` (obsolete versions of mkl 32 and 64 bit) - * ``OpenBLAS`` - * ``FLAME`` * ``ACML`` * ``Apple`` * ``NAS`` * ``Generic`` ``BLA_F95`` - if ``ON`` tries to find BLAS95/LAPACK95 + if ``ON`` tries to find the BLAS95/LAPACK95 interfaces Result Variables ^^^^^^^^^^^^^^^^ @@ -50,7 +51,7 @@ This module defines the following variables: ``LAPACK_FOUND`` library implementing the LAPACK interface is found ``LAPACK_LINKER_FLAGS`` - uncached list of required linker flags (excluding -l and -L). + uncached list of required linker flags (excluding ``-l`` and ``-L``). ``LAPACK_LIBRARIES`` uncached list of libraries (using full path name) to link against to use LAPACK @@ -62,7 +63,8 @@ This module defines the following variables: .. note:: - C or CXX must be enabled to use Intel MKL + C, CXX or Fortran must be enabled to detect a BLAS/LAPACK library. + C or CXX must be enabled to use Intel Math Kernel Library (MKL). For example, to use Intel MKL libraries and/or Intel compiler: @@ -72,10 +74,8 @@ This module defines the following variables: find_package(LAPACK) #]=======================================================================] -set(_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) - # Check the language being used -if( NOT (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED OR CMAKE_Fortran_COMPILER_LOADED) ) +if(NOT (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED OR CMAKE_Fortran_COMPILER_LOADED)) if(LAPACK_FIND_REQUIRED) message(FATAL_ERROR "FindLAPACK requires Fortran, C, or C++ to be enabled.") else() @@ -84,11 +84,11 @@ if( NOT (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED OR CMAKE_Fortran_C endif() endif() -if (CMAKE_Fortran_COMPILER_LOADED) -include(${CMAKE_CURRENT_LIST_DIR}/CheckFortranFunctionExists.cmake) -else () -include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake) -endif () +if(CMAKE_Fortran_COMPILER_LOADED) + include(${CMAKE_CURRENT_LIST_DIR}/CheckFortranFunctionExists.cmake) +else() + include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake) +endif() include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) cmake_push_check_state() @@ -97,290 +97,344 @@ set(CMAKE_REQUIRED_QUIET ${LAPACK_FIND_QUIETLY}) set(LAPACK_FOUND FALSE) set(LAPACK95_FOUND FALSE) -# TODO: move this stuff to separate module - -macro(Check_Lapack_Libraries LIBRARIES _prefix _name _flags _list _blas _threads) -# This macro checks for the existence of the combination of fortran libraries -# given by _list. If the combination is found, this macro checks (using the -# Check_Fortran_Function_Exists macro) whether can link against that library -# combination using the name of a routine given by _name using the linker -# flags given by _flags. If the combination of libraries is found and passes -# the link test, LIBRARIES is set to the list of complete library paths that -# have been found. Otherwise, LIBRARIES is set to FALSE. - -# N.B. _prefix is the prefix applied to the names of all cached variables that -# are generated internally and marked advanced by this macro. - -set(_libraries_work TRUE) -set(${LIBRARIES}) -set(_combined_name) -if (NOT _libdir) - if (WIN32) - set(_libdir ENV LIB) - elseif (APPLE) - set(_libdir ENV DYLD_LIBRARY_PATH) - else () - set(_libdir ENV LD_LIBRARY_PATH) - endif () -endif () - -list(APPEND _libdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - -foreach(_library ${_list}) - set(_combined_name ${_combined_name}_${_library}) +set(_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) +if(BLA_STATIC) + if(WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) + else() + set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + endif() +else() + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + # for ubuntu's libblas3gf and liblapack3gf packages + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf) + endif() +endif() + +# TODO: move this stuff to a separate module + +macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _addlibdir _subdirs _blas) + # This macro checks for the existence of the combination of fortran libraries + # given by _list. If the combination is found, this macro checks (using the + # Check_Fortran_Function_Exists macro) whether can link against that library + # combination using the name of a routine given by _name using the linker + # flags given by _flags. If the combination of libraries is found and passes + # the link test, LIBRARIES is set to the list of complete library paths that + # have been found. Otherwise, LIBRARIES is set to FALSE. + + # N.B. _prefix is the prefix applied to the names of all cached variables that + # are generated internally and marked advanced by this macro. + # _addlibdir is a list of additional search paths. _subdirs is a list of path + # suffixes to be used by find_library(). + + set(_libraries_work TRUE) + set(${LIBRARIES}) + set(_combined_name) + + set(_extaddlibdir "${_addlibdir}") + if(WIN32) + list(APPEND _extaddlibdir ENV LIB) + elseif(APPLE) + list(APPEND _extaddlibdir ENV DYLD_LIBRARY_PATH) + else() + list(APPEND _extaddlibdir ENV LD_LIBRARY_PATH) + endif() + list(APPEND _extaddlibdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + + foreach(_library ${_list}) + if(_library MATCHES "^-Wl,--(start|end)-group$") + # Respect linker flags like --start/end-group (required by MKL) + set(${LIBRARIES} ${${LIBRARIES}} "${_library}") + else() + set(_combined_name ${_combined_name}_${_library}) + if(_libraries_work) + find_library(${_prefix}_${_library}_LIBRARY + NAMES ${_library} + PATHS ${_extaddlibdir} + PATH_SUFFIXES ${_subdirs} + ) + #message("DEBUG: find_library(${_library}) got ${${_prefix}_${_library}_LIBRARY}") + mark_as_advanced(${_prefix}_${_library}_LIBRARY) + set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) + set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) + endif() + endif() + endforeach() if(_libraries_work) - if (BLA_STATIC) - if (WIN32) - set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) - endif () - if (APPLE) - set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) - else () - set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) - endif () - else () - if (CMAKE_SYSTEM_NAME STREQUAL "Linux") - # for ubuntu's libblas3gf and liblapack3gf packages - set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf) - endif () - endif () - find_library(${_prefix}_${_library}_LIBRARY - NAMES ${_library} - PATHS ${_libdir} - ) - mark_as_advanced(${_prefix}_${_library}_LIBRARY) - set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) - set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) + # Test this combination of libraries. + set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blas} ${_threadlibs}) + #message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}") + if(CMAKE_Fortran_COMPILER_LOADED) + check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS) + else() + check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS) + endif() + set(CMAKE_REQUIRED_LIBRARIES) + set(_libraries_work ${${_prefix}${_combined_name}_WORKS}) endif() -endforeach() -if(_libraries_work) - # Test this combination of libraries. - if(UNIX AND BLA_STATIC) - set(CMAKE_REQUIRED_LIBRARIES ${_flags} "-Wl,--start-group" ${${LIBRARIES}} ${_blas} "-Wl,--end-group" ${_threads}) + if(_libraries_work) + if("${_list}${_blas}" STREQUAL "") + set(${LIBRARIES} "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES") + else() + set(${LIBRARIES} ${${LIBRARIES}} ${_blas} ${_threadlibs}) + endif() else() - set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blas} ${_threads}) + set(${LIBRARIES} FALSE) endif() -# message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}") - if (NOT CMAKE_Fortran_COMPILER_LOADED) - check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS) - else () - check_fortran_function_exists(${_name} ${_prefix}${_combined_name}_WORKS) - endif () - set(CMAKE_REQUIRED_LIBRARIES) - set(_libraries_work ${${_prefix}${_combined_name}_WORKS}) #message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}") -endif() - - if(_libraries_work) - if("${_list}${_blas}" STREQUAL "") - set(${LIBRARIES} "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES") - else() - set(${LIBRARIES} ${${LIBRARIES}} ${_blas} ${_threads}) - endif() - else() - set(${LIBRARIES} FALSE) - endif() - endmacro() - set(LAPACK_LINKER_FLAGS) set(LAPACK_LIBRARIES) set(LAPACK95_LIBRARIES) - if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) find_package(BLAS) else() find_package(BLAS REQUIRED) endif() - if(BLAS_FOUND) set(LAPACK_LINKER_FLAGS ${BLAS_LINKER_FLAGS}) - if (NOT $ENV{BLA_VENDOR} STREQUAL "") + if(NOT $ENV{BLA_VENDOR} STREQUAL "") set(BLA_VENDOR $ENV{BLA_VENDOR}) - else () + else() if(NOT BLA_VENDOR) set(BLA_VENDOR "All") endif() - endif () - -#intel lapack -if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - if (NOT WIN32) - set(LAPACK_mkl_LM "-lm") - set(LAPACK_mkl_LDL "-ldl") - endif () - if (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED) - if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) - find_PACKAGE(Threads) - else() - find_package(Threads REQUIRED) + endif() + + # LAPACK in the Intel MKL 10+ library? + if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") + if(NOT LAPACK_LIBRARIES) + if(CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED) + # System-specific settings + if(NOT WIN32) + set(LAPACK_mkl_LM "-lm") + set(LAPACK_mkl_LDL "-ldl") + endif() + + if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) + find_package(Threads) + else() + find_package(Threads REQUIRED) + endif() + + if(BLA_VENDOR MATCHES "_64ilp") + set(LAPACK_mkl_ILP_MODE "ilp64") + else() + set(LAPACK_mkl_ILP_MODE "lp64") + endif() + + set(LAPACK_SEARCH_LIBS "") + + if(BLA_F95) + set(LAPACK_mkl_SEARCH_SYMBOL "cheev_f95") + set(_LIBRARIES LAPACK95_LIBRARIES) + set(_BLAS_LIBRARIES ${BLAS95_LIBRARIES}) + + # old + list(APPEND LAPACK_SEARCH_LIBS + "mkl_lapack95") + # new >= 10.3 + list(APPEND LAPACK_SEARCH_LIBS + "mkl_intel_c") + list(APPEND LAPACK_SEARCH_LIBS + "mkl_lapack95_${LAPACK_mkl_ILP_MODE}") + else() + set(LAPACK_mkl_SEARCH_SYMBOL "cheev") + set(_LIBRARIES LAPACK_LIBRARIES) + set(_BLAS_LIBRARIES ${BLAS_LIBRARIES}) + + # old and new >= 10.3 + list(APPEND LAPACK_SEARCH_LIBS + "mkl_lapack") + endif() + + # MKL uses a multitude of partially platform-specific subdirectories: + if(BLA_VENDOR STREQUAL "Intel10_32") + set(LAPACK_mkl_ARCH_NAME "ia32") + else() + set(LAPACK_mkl_ARCH_NAME "intel64") + endif() + if(WIN32) + set(LAPACK_mkl_OS_NAME "win") + elseif(APPLE) + set(LAPACK_mkl_OS_NAME "mac") + else() + set(LAPACK_mkl_OS_NAME "lin") + endif() + if(DEFINED ENV{MKLROOT}) + set(LAPACK_mkl_MKLROOT "$ENV{MKLROOT}") + # If MKLROOT points to the subdirectory 'mkl', use the parent directory instead + # so we can better detect other relevant libraries in 'compiler' or 'tbb': + get_filename_component(LAPACK_mkl_MKLROOT_LAST_DIR "${LAPACK_mkl_MKLROOT}" NAME) + if(LAPACK_mkl_MKLROOT_LAST_DIR STREQUAL "mkl") + get_filename_component(LAPACK_mkl_MKLROOT "${LAPACK_mkl_MKLROOT}" DIRECTORY) + endif() + endif() + set(LAPACK_mkl_LIB_PATH_SUFFIXES + "compiler/lib" "compiler/lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}" + "mkl/lib" "mkl/lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}" + "lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}") + + # First try empty lapack libs + if(NOT ${_LIBRARIES}) + check_lapack_libraries( + ${_LIBRARIES} + LAPACK + ${LAPACK_mkl_SEARCH_SYMBOL} + "" + "" + "${CMAKE_THREAD_LIBS_INIT};${LAPACK_mkl_LM};${LAPACK_mkl_LDL}" + "${LAPACK_mkl_MKLROOT}" + "${LAPACK_mkl_LIB_PATH_SUFFIXES}" + "${_BLAS_LIBRARIES}" + ) + endif() + + # Then try the search libs + foreach(IT ${LAPACK_SEARCH_LIBS}) + string(REPLACE " " ";" SEARCH_LIBS ${IT}) + if(NOT ${_LIBRARIES}) + check_lapack_libraries( + ${_LIBRARIES} + LAPACK + ${LAPACK_mkl_SEARCH_SYMBOL} + "" + "${SEARCH_LIBS}" + "${CMAKE_THREAD_LIBS_INIT};${LAPACK_mkl_LM};${LAPACK_mkl_LDL}" + "${LAPACK_mkl_MKLROOT}" + "${LAPACK_mkl_LIB_PATH_SUFFIXES}" + "${_BLAS_LIBRARIES}" + ) + endif() + endforeach() + + unset(LAPACK_mkl_ILP_MODE) + unset(LAPACK_mkl_SEARCH_SYMBOL) + unset(LAPACK_mkl_LM) + unset(LAPACK_mkl_LDL) + unset(LAPACK_mkl_MKLROOT) + unset(LAPACK_mkl_ARCH_NAME) + unset(LAPACK_mkl_OS_NAME) + unset(LAPACK_mkl_LIB_PATH_SUFFIXES) + endif() endif() + endif() - if (BLA_VENDOR MATCHES "_64ilp") - set(LAPACK_mkl_ILP_MODE "ilp64") - else () - set(LAPACK_mkl_ILP_MODE "lp64") - endif () - - set(LAPACK_SEARCH_LIBS "") - - if (BLA_F95) - set(LAPACK_mkl_SEARCH_SYMBOL "cheev_f95") - set(_LIBRARIES LAPACK95_LIBRARIES) - set(_BLAS_LIBRARIES ${BLAS95_LIBRARIES}) - - # old - list(APPEND LAPACK_SEARCH_LIBS - "mkl_lapack95") - # new >= 10.3 - list(APPEND LAPACK_SEARCH_LIBS - "mkl_intel_c") - list(APPEND LAPACK_SEARCH_LIBS - "mkl_lapack95_${LAPACK_mkl_ILP_MODE}") - else() - set(LAPACK_mkl_SEARCH_SYMBOL "cheev") - set(_LIBRARIES LAPACK_LIBRARIES) - set(_BLAS_LIBRARIES ${BLAS_LIBRARIES}) + # gotoblas? (http://www.tacc.utexas.edu/tacc-projects/gotoblas2) + if(BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") + if(NOT LAPACK_LIBRARIES) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "goto2" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) + endif() + endif() - # old - list(APPEND LAPACK_SEARCH_LIBS - "mkl_lapack") + # OpenBLAS? (http://www.openblas.net) + if(BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All") + if(NOT LAPACK_LIBRARIES) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "openblas" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) endif() + endif() - # First try empty lapack libs - if (NOT ${_LIBRARIES}) + # FLAME's blis library? (https://github.com/flame/blis) + if(BLA_VENDOR STREQUAL "FLAME" OR BLA_VENDOR STREQUAL "All") + if(NOT LAPACK_LIBRARIES) check_lapack_libraries( - ${_LIBRARIES} + LAPACK_LIBRARIES LAPACK - ${LAPACK_mkl_SEARCH_SYMBOL} + cheev "" + "flame" "" - "${_BLAS_LIBRARIES}" "" - ) - endif () - # Then try the search libs - foreach (IT ${LAPACK_SEARCH_LIBS}) - if (NOT ${_LIBRARIES}) - check_lapack_libraries( - ${_LIBRARIES} - LAPACK - ${LAPACK_mkl_SEARCH_SYMBOL} - "" - "${IT}" - "${_BLAS_LIBRARIES}" - "${CMAKE_THREAD_LIBS_INIT};${LAPACK_mkl_LM};${LAPACK_mkl_LDL}" - ) - endif () - endforeach () - - unset(LAPACK_mkl_ILP_MODE) - unset(LAPACK_mkl_SEARCH_SYMBOL) - unset(LAPACK_mkl_LM) - unset(LAPACK_mkl_LDL) - endif () + "" + "${BLAS_LIBRARIES}" + ) + endif() + endif() + + # BLAS in acml library? + if(BLA_VENDOR MATCHES "ACML" OR BLA_VENDOR STREQUAL "All") + if(BLAS_LIBRARIES MATCHES ".+acml.+") + set(LAPACK_LIBRARIES ${BLAS_LIBRARIES}) + endif() + endif() + + # Apple LAPACK library? + if(BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") + if(NOT LAPACK_LIBRARIES) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "Accelerate" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) + endif() endif() -endif() -if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "goto2" - "${BLAS_LIBRARIES}" - "" - ) - endif() -endif () - -if (BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "openblas" - "${BLAS_LIBRARIES}" - "" - ) - endif() -endif () - -if (BLA_VENDOR STREQUAL "FLAME" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "flame" - "${BLAS_LIBRARIES}" - "" - ) - endif() -endif () - -#acml lapack -if (BLA_VENDOR MATCHES "ACML" OR BLA_VENDOR STREQUAL "All") - if (BLAS_LIBRARIES MATCHES ".+acml.+") - set (LAPACK_LIBRARIES ${BLAS_LIBRARIES}) - endif () -endif () - -# Apple LAPACK library? -if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "Accelerate" - "${BLAS_LIBRARIES}" - "" - ) + # Apple NAS (vecLib) library? + if(BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") + if(NOT LAPACK_LIBRARIES) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "vecLib" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) + endif() endif() -endif () -if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") - if ( NOT LAPACK_LIBRARIES ) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "vecLib" - "${BLAS_LIBRARIES}" - "" - ) - endif () -endif () -# Generic LAPACK library? -if (BLA_VENDOR STREQUAL "Generic" OR - BLA_VENDOR STREQUAL "ATLAS" OR - BLA_VENDOR STREQUAL "All") - if ( NOT LAPACK_LIBRARIES ) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "lapack" - "${BLAS_LIBRARIES}" - "" - ) - endif () -endif () + # Generic LAPACK library? + if(BLA_VENDOR STREQUAL "Generic" OR + BLA_VENDOR STREQUAL "ATLAS" OR + BLA_VENDOR STREQUAL "All") + if(NOT LAPACK_LIBRARIES) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "lapack" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) + endif() + endif() else() message(STATUS "LAPACK requires BLAS") endif() @@ -397,11 +451,11 @@ if(BLA_F95) else() if(LAPACK_FIND_REQUIRED) message(FATAL_ERROR - "A required library with LAPACK95 API not found. Please specify library location." + "A required library with LAPACK95 API not found. Please specify library location." ) else() message(STATUS - "A library with LAPACK95 API not found. Please specify library location." + "A library with LAPACK95 API not found. Please specify library location." ) endif() endif() @@ -421,11 +475,11 @@ else() else() if(LAPACK_FIND_REQUIRED) message(FATAL_ERROR - "A required library with LAPACK API not found. Please specify library location." + "A required library with LAPACK API not found. Please specify library location." ) else() message(STATUS - "A library with LAPACK API not found. Please specify library location." + "A library with LAPACK API not found. Please specify library location." ) endif() endif() @@ -434,7 +488,7 @@ endif() # On compilers that implicitly link LAPACK (such as ftn, cc, and CC on Cray HPC machines) # we used a placeholder for empty LAPACK_LIBRARIES to get through our logic above. -if (LAPACK_LIBRARIES STREQUAL "LAPACK_LIBRARIES-PLACEHOLDER-FOR-EMPTY-LIBRARIES") +if(LAPACK_LIBRARIES STREQUAL "LAPACK_LIBRARIES-PLACEHOLDER-FOR-EMPTY-LIBRARIES") set(LAPACK_LIBRARIES "") endif() diff --git a/Modules/FindLibArchive.cmake b/Modules/FindLibArchive.cmake index ef27b7d..ce3c8b8 100644 --- a/Modules/FindLibArchive.cmake +++ b/Modules/FindLibArchive.cmake @@ -16,18 +16,26 @@ The module defines the following variables: LibArchive_INCLUDE_DIRS - include search path LibArchive_LIBRARIES - libraries to link LibArchive_VERSION - libarchive 3-component version number + +The module defines the following ``IMPORTED`` targets: + +:: + + LibArchive::LibArchive - target for linking against libarchive #]=======================================================================] find_path(LibArchive_INCLUDE_DIR NAMES archive.h PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\LibArchive;InstallPath]/include" + DOC "libarchive include directory" ) find_library(LibArchive_LIBRARY NAMES archive libarchive PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\LibArchive;InstallPath]/lib" + DOC "libarchive library" ) mark_as_advanced(LibArchive_INCLUDE_DIR LibArchive_LIBRARY) @@ -58,4 +66,11 @@ unset(LIBARCHIVE_FOUND) if(LibArchive_FOUND) set(LibArchive_INCLUDE_DIRS ${LibArchive_INCLUDE_DIR}) set(LibArchive_LIBRARIES ${LibArchive_LIBRARY}) + + if (NOT TARGET LibArchive::LibArchive) + add_library(LibArchive::LibArchive UNKNOWN IMPORTED) + set_target_properties(LibArchive::LibArchive PROPERTIES + IMPORTED_LOCATION "${LibArchive_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${LibArchive_INCLUDE_DIR}") + endif () endif() diff --git a/Modules/FindLibXml2.cmake b/Modules/FindLibXml2.cmake index da8bfe0..f551dfe 100644 --- a/Modules/FindLibXml2.cmake +++ b/Modules/FindLibXml2.cmake @@ -10,8 +10,12 @@ Find the XML processing library (libxml2). IMPORTED Targets ^^^^^^^^^^^^^^^^ -This module defines :prop_tgt:`IMPORTED` target ``LibXml2::LibXml2``, if -libxml2 has been found. +The following :prop_tgt:`IMPORTED` targets may be defined: + +``LibXml2::LibXml2`` + If the libxml2 library has been found +``LibXml2::xmllint`` + If the xmllint command-line executable has been found Result variables ^^^^^^^^^^^^^^^^ @@ -48,7 +52,6 @@ The following cache variables may also be set: # in the find_path() and find_library() calls find_package(PkgConfig QUIET) PKG_CHECK_MODULES(PC_LIBXML QUIET libxml-2.0) -set(LIBXML2_DEFINITIONS ${PC_LIBXML_CFLAGS_OTHER}) find_path(LIBXML2_INCLUDE_DIR NAMES libxml/xpath.h HINTS @@ -74,9 +77,7 @@ find_program(LIBXML2_XMLLINT_EXECUTABLE xmllint) # for backwards compat. with KDE 4.0.x: set(XMLLINT_EXECUTABLE "${LIBXML2_XMLLINT_EXECUTABLE}") -if(PC_LIBXML_VERSION) - set(LIBXML2_VERSION_STRING ${PC_LIBXML_VERSION}) -elseif(LIBXML2_INCLUDE_DIR AND EXISTS "${LIBXML2_INCLUDE_DIR}/libxml/xmlversion.h") +if(LIBXML2_INCLUDE_DIR AND EXISTS "${LIBXML2_INCLUDE_DIR}/libxml/xmlversion.h") file(STRINGS "${LIBXML2_INCLUDE_DIR}/libxml/xmlversion.h" libxml2_version_str REGEX "^#define[\t ]+LIBXML_DOTTED_VERSION[\t ]+\".*\"") @@ -85,9 +86,20 @@ elseif(LIBXML2_INCLUDE_DIR AND EXISTS "${LIBXML2_INCLUDE_DIR}/libxml/xmlversion. unset(libxml2_version_str) endif() -set(LIBXML2_INCLUDE_DIRS ${LIBXML2_INCLUDE_DIR} ${PC_LIBXML_INCLUDE_DIRS}) +set(LIBXML2_INCLUDE_DIRS ${LIBXML2_INCLUDE_DIR}) set(LIBXML2_LIBRARIES ${LIBXML2_LIBRARY}) +# Did we find the same installation as pkg-config? +# If so, use additional information from it. +unset(LIBXML2_DEFINITIONS) +foreach(libxml2_pc_lib_dir IN LISTS PC_LIBXML_LIBDIR PC_LIBXML_LIBRARY_DIRS) + if (LIBXML2_LIBRARY MATCHES "^${libxml2_pc_lib_dir}") + list(APPEND LIBXML2_INCLUDE_DIRS ${PC_LIBXML_INCLUDE_DIRS}) + set(LIBXML2_DEFINITIONS ${PC_LIBXML_CFLAGS_OTHER}) + break() + endif() +endforeach() + include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 REQUIRED_VARS LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR @@ -98,5 +110,11 @@ mark_as_advanced(LIBXML2_INCLUDE_DIR LIBXML2_LIBRARY LIBXML2_XMLLINT_EXECUTABLE) if(LibXml2_FOUND AND NOT TARGET LibXml2::LibXml2) add_library(LibXml2::LibXml2 UNKNOWN IMPORTED) set_target_properties(LibXml2::LibXml2 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${LIBXML2_INCLUDE_DIRS}") + set_target_properties(LibXml2::LibXml2 PROPERTIES INTERFACE_COMPILE_OPTIONS "${LIBXML2_DEFINITIONS}") set_property(TARGET LibXml2::LibXml2 APPEND PROPERTY IMPORTED_LOCATION "${LIBXML2_LIBRARY}") endif() + +if(LIBXML2_XMLLINT_EXECUTABLE AND NOT TARGET LibXml2::xmllint) + add_executable(LibXml2::xmllint IMPORTED) + set_target_properties(LibXml2::xmllint PROPERTIES IMPORTED_LOCATION "${LIBXML2_XMLLINT_EXECUTABLE}") +endif() diff --git a/Modules/FindLua.cmake b/Modules/FindLua.cmake index caf9d69..0b0c970 100644 --- a/Modules/FindLua.cmake +++ b/Modules/FindLua.cmake @@ -211,6 +211,7 @@ if (LUA_LIBRARY) # include the math library for Unix if (UNIX AND NOT APPLE AND NOT BEOS) find_library(LUA_MATH_LIBRARY m) + mark_as_advanced(LUA_MATH_LIBRARY) set(LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}") # include dl library for statically-linked Lua library @@ -232,6 +233,6 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR VERSION_VAR LUA_VERSION_STRING) -mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARY LUA_MATH_LIBRARY) +mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARY) cmake_policy(POP) diff --git a/Modules/FindMFC.cmake b/Modules/FindMFC.cmake index e366619..b8ca71b 100644 --- a/Modules/FindMFC.cmake +++ b/Modules/FindMFC.cmake @@ -31,7 +31,7 @@ if(MFC_ATTEMPT_TRY_COMPILE) set(CHECK_INCLUDE_FILE_VAR "afxwin.h") configure_file(${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx) - message(STATUS "Looking for MFC") + 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} @@ -51,13 +51,13 @@ if(MFC_ATTEMPT_TRY_COMPILE) OUTPUT_VARIABLE OUTPUT) endif() if(MFC_HAVE_MFC) - message(STATUS "Looking for MFC - found") + message(CHECK_PASS "found") set(MFC_HAVE_MFC 1 CACHE INTERNAL "Have MFC?") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if MFC exists passed with the following output:\n" "${OUTPUT}\n\n") else() - message(STATUS "Looking for MFC - not found") + message(CHECK_FAIL "not found") set(MFC_HAVE_MFC 0 CACHE INTERNAL "Have MFC?") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if MFC exists failed with the following output:\n" diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index 2779032..3e42386 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -96,15 +96,27 @@ For running MPI programs, the module sets the following variables Variables for locating MPI ^^^^^^^^^^^^^^^^^^^^^^^^^^ -This module performs a three step search for an MPI implementation: +This module performs a four step search for an MPI implementation: -1. Check if the compiler has MPI support built-in. This is the case if the user passed a +1. Search for ``MPIEXEC_EXECUTABLE`` and, if found, use its base directory. +2. Check if the compiler has MPI support built-in. This is the case if the user passed a compiler wrapper as ``CMAKE_<LANG>_COMPILER`` or if they're on a Cray system. -2. Attempt to find an MPI compiler wrapper and determine the compiler information from it. -3. Try to find an MPI implementation that does not ship such a wrapper by guessing settings. +3. Attempt to find an MPI compiler wrapper and determine the compiler information from it. +4. Try to find an MPI implementation that does not ship such a wrapper by guessing settings. Currently, only Microsoft MPI and MPICH2 on Windows are supported. -For controlling the second step, the following variables may be set: +For controlling the ``MPIEXEC_EXECUTABLE`` step, the following variables may be set: + +``MPIEXEC_EXECUTABLE`` + Manually specify the location of ``mpiexec``. +``MPI_HOME`` + Specify the base directory of the MPI installation. +``ENV{MPI_HOME}`` + Environment variable to specify the base directory of the MPI installation. +``ENV{I_MPI_ROOT}`` + Environment variable to specify the base directory of the MPI installation. + +For controlling the compiler wrapper step, the following variables may be set: ``MPI_<lang>_COMPILER`` Search for the specified compiler wrapper and use it. @@ -1059,40 +1071,15 @@ macro(_MPI_assemble_libraries LANG) endif() endmacro() -macro(_MPI_assemble_include_dirs LANG) - if("${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}") - set(MPI_${LANG}_INCLUDE_DIRS "") - else() - set(MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS}") - if("${LANG}" MATCHES "(C|CXX)") - if(MPI_${LANG}_HEADER_DIR) - list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_HEADER_DIR}") - endif() - else() # Fortran - if(MPI_${LANG}_F77_HEADER_DIR) - list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_F77_HEADER_DIR}") - endif() - if(MPI_${LANG}_MODULE_DIR AND NOT "${MPI_${LANG}_MODULE_DIR}" IN_LIST MPI_${LANG}_INCLUDE_DIRS) - list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_MODULE_DIR}") - endif() - endif() - if(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) - foreach(MPI_ADDITIONAL_INC_DIR IN LISTS MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) - list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${MPI_ADDITIONAL_INC_DIR}_INCLUDE_DIR}") - endforeach() - endif() - endif() -endmacro() - -function(_MPI_split_include_dirs LANG) - if("${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}") - return() - endif() +macro(_MPI_split_include_dirs LANG) # Backwards compatibility: Search INCLUDE_PATH if given. if(MPI_${LANG}_INCLUDE_PATH) list(APPEND MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_${LANG}_INCLUDE_PATH}") endif() + # Preserve the include dirs before stripping out the components + set(MPI_${LANG}_INCLUDE_DIRS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS}) + # 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)") @@ -1103,6 +1090,7 @@ function(_MPI_split_include_dirs LANG) if(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) list(REMOVE_ITEM MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_${LANG}_HEADER_DIR}") endif() + # Fortran is more complicated here: An implementation could provide # any of the Fortran 77/90/2008 APIs for MPI. For example, MSMPI # only provides Fortran 77 and - if mpi.f90 is built - potentially @@ -1123,6 +1111,7 @@ function(_MPI_split_include_dirs LANG) endif() mark_as_advanced(MPI_${LANG}_F77_HEADER_DIR MPI_${LANG}_MODULE_DIR) endif() + # Remove duplicates and default system directories from the list. if(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) list(REMOVE_DUPLICATES MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) @@ -1130,8 +1119,9 @@ function(_MPI_split_include_dirs LANG) list(REMOVE_ITEM MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_IMPLICIT_INC_DIR}) endforeach() endif() + set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} CACHE STRING "MPI ${LANG} additional include directories" FORCE) -endfunction() +endmacro() macro(_MPI_create_imported_target LANG) if(NOT TARGET MPI::MPI_${LANG}) @@ -1391,6 +1381,7 @@ foreach(LANG IN ITEMS C CXX Fortran) endif() else() set(_MPI_FIND_${LANG} FALSE) + string(APPEND _MPI_FAIL_REASON "MPI component '${LANG}' was requested, but language ${LANG} is not enabled. ") endif() if(_MPI_FIND_${LANG}) if( ${LANG} STREQUAL CXX AND NOT MPICXX IN_LIST MPI_FIND_COMPONENTS ) @@ -1493,8 +1484,9 @@ foreach(LANG IN ITEMS C CXX Fortran) endif() endif() - _MPI_split_include_dirs(${LANG}) - _MPI_assemble_include_dirs(${LANG}) + if(NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}") + _MPI_split_include_dirs(${LANG}) + endif() _MPI_assemble_libraries(${LANG}) _MPI_adjust_compile_definitions(${LANG}) @@ -1663,7 +1655,8 @@ foreach(LANG IN ITEMS C CXX Fortran) list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_WORKS") endif() endif() - find_package_handle_standard_args(MPI_${LANG} REQUIRED_VARS ${MPI_${LANG}_REQUIRED_VARS} + find_package_handle_standard_args(MPI_${LANG} NAME_MISMATCHED + REQUIRED_VARS ${MPI_${LANG}_REQUIRED_VARS} VERSION_VAR MPI_${LANG}_VERSION) if(DEFINED MPI_${LANG}_VERSION) @@ -1688,6 +1681,7 @@ endif() find_package_handle_standard_args(MPI REQUIRED_VARS ${_MPI_REQ_VARS} VERSION_VAR ${_MPI_MIN_VERSION} + REASON_FAILURE_MESSAGE "${_MPI_FAIL_REASON}" HANDLE_COMPONENTS) #============================================================================= diff --git a/Modules/FindOpenACC.cmake b/Modules/FindOpenACC.cmake index 743e0e2..398dcf5 100644 --- a/Modules/FindOpenACC.cmake +++ b/Modules/FindOpenACC.cmake @@ -254,6 +254,7 @@ foreach (LANG IN ITEMS C CXX Fortran) _OPENACC_SET_VERSION_BY_SPEC_DATE("${LANG}") find_package_handle_standard_args(OpenACC_${LANG} + NAME_MISMATCHED REQUIRED_VARS OpenACC_${LANG}_FLAGS VERSION_VAR OpenACC_${LANG}_VERSION ) diff --git a/Modules/FindOpenGL.cmake b/Modules/FindOpenGL.cmake index 23bb001d..74392da 100644 --- a/Modules/FindOpenGL.cmake +++ b/Modules/FindOpenGL.cmake @@ -130,6 +130,8 @@ foreach(component ${OpenGL_FIND_COMPONENTS}) set(OPENGL_USE_${_COMPONENT} 1) endforeach() +set(_OpenGL_CACHE_VARS) + if (CYGWIN) find_path(OPENGL_INCLUDE_DIR GL/gl.h ) list(APPEND _OpenGL_REQUIRED_VARS OPENGL_INCLUDE_DIR) @@ -137,6 +139,11 @@ if (CYGWIN) find_library(OPENGL_gl_LIBRARY opengl32 ) find_library(OPENGL_glu_LIBRARY glu32 ) + list(APPEND _OpenGL_CACHE_VARS + OPENGL_INCLUDE_DIR + OPENGL_gl_LIBRARY + OPENGL_glu_LIBRARY + ) elseif (WIN32) if(BORLAND) @@ -147,6 +154,10 @@ elseif (WIN32) set (OPENGL_glu_LIBRARY glu32 CACHE STRING "GLU library for win32") endif() + list(APPEND _OpenGL_CACHE_VARS + OPENGL_gl_LIBRARY + OPENGL_glu_LIBRARY + ) elseif (APPLE) # The OpenGL.framework provides both gl and glu find_library(OPENGL_gl_LIBRARY OpenGL DOC "OpenGL library for OS X") @@ -155,6 +166,11 @@ elseif (APPLE) find_path(OPENGL_INCLUDE_DIR OpenGL/gl.h DOC "Include for OpenGL on OS X") list(APPEND _OpenGL_REQUIRED_VARS OPENGL_INCLUDE_DIR) + list(APPEND _OpenGL_CACHE_VARS + OPENGL_INCLUDE_DIR + OPENGL_gl_LIBRARY + OPENGL_glu_LIBRARY + ) else() if (CMAKE_SYSTEM_NAME MATCHES "HP-UX") # Handle HP-UX cases where we only want to find OpenGL in either hpux64 @@ -194,6 +210,12 @@ else() /usr/openwin/share/include /opt/graphics/OpenGL/include ) + list(APPEND _OpenGL_CACHE_VARS + OPENGL_INCLUDE_DIR + OPENGL_GLX_INCLUDE_DIR + OPENGL_EGL_INCLUDE_DIR + OPENGL_xmesa_INCLUDE_DIR + ) # Search for the GLVND libraries. We do this regardless of COMPONENTS; we'll # take into account the COMPONENTS logic later. @@ -222,6 +244,13 @@ else() /usr/shlib ) + list(APPEND _OpenGL_CACHE_VARS + OPENGL_opengl_LIBRARY + OPENGL_glx_LIBRARY + OPENGL_egl_LIBRARY + OPENGL_glu_LIBRARY + ) + set(_OpenGL_GL_POLICY_WARN 0) if(NOT DEFINED OpenGL_GL_PREFERENCE) set(OpenGL_GL_PREFERENCE "") @@ -268,6 +297,7 @@ else() ${_OPENGL_LIB_PATH} PATH_SUFFIXES libglvnd ) + list(APPEND _OpenGL_CACHE_VARS OPENGL_gl_LIBRARY) endif() if(_OpenGL_GL_POLICY_WARN AND OPENGL_gl_LIBRARY AND OPENGL_opengl_LIBRARY AND OPENGL_glx_LIBRARY) @@ -532,14 +562,5 @@ set(OPENGL_LIBRARY ${OPENGL_LIBRARIES}) # This deprecated setting is for backward compatibility with CMake1.4 set(OPENGL_INCLUDE_PATH ${OPENGL_INCLUDE_DIR}) -mark_as_advanced( - OPENGL_INCLUDE_DIR - OPENGL_xmesa_INCLUDE_DIR - OPENGL_egl_LIBRARY - OPENGL_glu_LIBRARY - OPENGL_glx_LIBRARY - OPENGL_gl_LIBRARY - OPENGL_opengl_LIBRARY - OPENGL_EGL_INCLUDE_DIR - OPENGL_GLX_INCLUDE_DIR -) +mark_as_advanced(${_OpenGL_CACHE_VARS}) +unset(_OpenGL_CACHE_VARS) diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake index 90d1c3e..26fed41 100644 --- a/Modules/FindOpenMP.cmake +++ b/Modules/FindOpenMP.cmake @@ -509,6 +509,7 @@ foreach(LANG IN LISTS OpenMP_FINDLIST) endif() find_package_handle_standard_args(OpenMP_${LANG} + NAME_MISMATCHED REQUIRED_VARS OpenMP_${LANG}_FLAGS ${_OPENMP_${LANG}_REQUIRED_LIB_VARS} VERSION_VAR OpenMP_${LANG}_VERSION ) diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index 478a592..af713d6 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -131,6 +131,7 @@ find_path(OPENSSL_INCLUDE_DIR ${_OPENSSL_ROOT_HINTS_AND_PATHS} HINTS ${_OPENSSL_INCLUDEDIR} + ${_OPENSSL_INCLUDE_DIRS} PATH_SUFFIXES include ) @@ -319,6 +320,7 @@ else() ${_OPENSSL_ROOT_HINTS_AND_PATHS} HINTS ${_OPENSSL_LIBDIR} + ${_OPENSSL_LIBRARY_DIRS} PATH_SUFFIXES lib ) @@ -330,6 +332,7 @@ else() ${_OPENSSL_ROOT_HINTS_AND_PATHS} HINTS ${_OPENSSL_LIBDIR} + ${_OPENSSL_LIBRARY_DIRS} PATH_SUFFIXES lib ) @@ -455,7 +458,7 @@ find_package_handle_standard_args(OpenSSL "Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR" ) -mark_as_advanced(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES) +mark_as_advanced(OPENSSL_INCLUDE_DIR) if(OPENSSL_FOUND) if(NOT TARGET OpenSSL::Crypto AND diff --git a/Modules/FindPNG.cmake b/Modules/FindPNG.cmake index bd400c7..f1fe89a 100644 --- a/Modules/FindPNG.cmake +++ b/Modules/FindPNG.cmake @@ -94,6 +94,10 @@ if(ZLIB_FOUND) set(PNG_INCLUDE_DIRS ${PNG_PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} ) set(PNG_INCLUDE_DIR ${PNG_INCLUDE_DIRS} ) # for backward compatibility set(PNG_LIBRARIES ${PNG_LIBRARY} ${ZLIB_LIBRARY}) + if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND + ("${PNG_LIBRARY}" MATCHES "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$")) + list(APPEND PNG_LIBRARIES m) + endif() if (CYGWIN) if(BUILD_SHARED_LIBS) @@ -110,6 +114,12 @@ if(ZLIB_FOUND) INTERFACE_COMPILE_DEFINITIONS "${_PNG_COMPILE_DEFINITIONS}" INTERFACE_INCLUDE_DIRECTORIES "${PNG_INCLUDE_DIRS}" INTERFACE_LINK_LIBRARIES ZLIB::ZLIB) + if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND + ("${PNG_LIBRARY}" MATCHES "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$")) + set_property(TARGET PNG::PNG APPEND PROPERTY + INTERFACE_LINK_LIBRARIES m) + endif() + if(EXISTS "${PNG_LIBRARY}") set_target_properties(PNG::PNG PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake index d824ee8..a078049 100644 --- a/Modules/FindPackageHandleStandardArgs.cmake +++ b/Modules/FindPackageHandleStandardArgs.cmake @@ -27,6 +27,7 @@ valid filepaths. [VERSION_VAR <version-var>] [HANDLE_COMPONENTS] [CONFIG_MODE] + [NAME_MISMATCHED] [REASON_FAILURE_MESSAGE <reason-failure-message>] [FAIL_MESSAGE <custom-failure-message>] ) @@ -90,6 +91,12 @@ valid filepaths. Specify a custom failure message instead of using the default generated message. Not recommended. + ``NAME_MISMATCHED`` + Indicate that the ``<PackageName>`` does not match + ``${CMAKE_FIND_PACKAGE_NAME}``. This is usually a mistake and raises a + warning, but it may be intentional for usage of the command for components + of a larger package. + Example for the simple signature: .. code-block:: cmake @@ -106,6 +113,17 @@ used or not. If it is found, success will be reported, including the content of the first ``<required-var>``. On repeated CMake runs, the same message will not be printed again. +.. note:: + + If ``<PackageName>`` does not match ``CMAKE_FIND_PACKAGE_NAME`` for the + calling module, a warning that there is a mismatch is given. The + ``FPHSA_NAME_MISMATCHED`` variable may be set to bypass the warning if using + the old signature and the ``NAME_MISMATCHED`` argument using the new + signature. To avoid forcing the caller to require newer versions of CMake for + usage, the variable's value will be used if defined when the + ``NAME_MISMATCHED`` argument is not passed for the new signature (but using + both is an error).. + Example for the full signature: .. code-block:: cmake @@ -190,15 +208,32 @@ endmacro() function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) -# Set up the arguments for `cmake_parse_arguments`. - set(options CONFIG_MODE HANDLE_COMPONENTS) + # Set up the arguments for `cmake_parse_arguments`. + set(options CONFIG_MODE HANDLE_COMPONENTS NAME_MISMATCHED) set(oneValueArgs FAIL_MESSAGE REASON_FAILURE_MESSAGE VERSION_VAR FOUND_VAR) set(multiValueArgs REQUIRED_VARS) -# Check whether we are in 'simple' or 'extended' mode: + # Check whether we are in 'simple' or 'extended' mode: set(_KEYWORDS_FOR_EXTENDED_MODE ${options} ${oneValueArgs} ${multiValueArgs} ) list(FIND _KEYWORDS_FOR_EXTENDED_MODE "${_FIRST_ARG}" INDEX) + unset(FPHSA_NAME_MISMATCHED_override) + if (DEFINED FPHSA_NAME_MISMATCHED) + # If the variable NAME_MISMATCHED variable is set, error if it is passed as + # an argument. The former is for old signatures, the latter is for new + # signatures. + list(FIND ARGN "NAME_MISMATCHED" name_mismatched_idx) + if (NOT name_mismatched_idx EQUAL "-1") + message(FATAL_ERROR + "The `NAME_MISMATCHED` argument may only be specified by the argument or " + "the variable, not both.") + endif () + + # But use the variable if it is not an argument to avoid forcing minimum + # CMake version bumps for calling modules. + set(FPHSA_NAME_MISMATCHED_override "${FPHSA_NAME_MISMATCHED}") + endif () + if(${INDEX} EQUAL -1) set(FPHSA_FAIL_MESSAGE ${_FIRST_ARG}) set(FPHSA_REQUIRED_VARS ${ARGN}) @@ -227,6 +262,21 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) endif() endif() + if (DEFINED FPHSA_NAME_MISMATCHED_override) + set(FPHSA_NAME_MISMATCHED "${FPHSA_NAME_MISMATCHED_override}") + endif () + + if (DEFINED CMAKE_FIND_PACKAGE_NAME + AND NOT FPHSA_NAME_MISMATCHED + AND NOT _NAME STREQUAL CMAKE_FIND_PACKAGE_NAME) + message(AUTHOR_WARNING + "The package name passed to `find_package_handle_standard_args` " + "(${_NAME}) does not match the name of the calling package " + "(${CMAKE_FIND_PACKAGE_NAME}). This can lead to problems in calling " + "code that expects `find_package` result variables (e.g., `_FOUND`) " + "to follow a certain pattern.") + endif () + # now that we collected all arguments, process them if("x${FPHSA_FAIL_MESSAGE}" STREQUAL "xDEFAULT_MSG") @@ -239,10 +289,12 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) string(TOLOWER ${_NAME} _NAME_LOWER) if(FPHSA_FOUND_VAR) - if(FPHSA_FOUND_VAR MATCHES "^${_NAME}_FOUND$" OR FPHSA_FOUND_VAR MATCHES "^${_NAME_UPPER}_FOUND$") + set(_FOUND_VAR_UPPER ${_NAME_UPPER}_FOUND) + set(_FOUND_VAR_MIXED ${_NAME}_FOUND) + if(FPHSA_FOUND_VAR STREQUAL _FOUND_VAR_MIXED OR FPHSA_FOUND_VAR STREQUAL _FOUND_VAR_UPPER) set(_FOUND_VAR ${FPHSA_FOUND_VAR}) else() - message(FATAL_ERROR "The argument for FOUND_VAR is \"${FPHSA_FOUND_VAR}\", but only \"${_NAME}_FOUND\" and \"${_NAME_UPPER}_FOUND\" are valid names.") + message(FATAL_ERROR "The argument for FOUND_VAR is \"${FPHSA_FOUND_VAR}\", but only \"${_FOUND_VAR_MIXED}\" and \"${_FOUND_VAR_UPPER}\" are valid names.") endif() else() set(_FOUND_VAR ${_NAME_UPPER}_FOUND) diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index 5162a44..f4b6ea1 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -337,7 +337,7 @@ macro(_pkg_set_path_internal) # remove empty values from the list list(REMOVE_ITEM _pkgconfig_path "") file(TO_NATIVE_PATH "${_pkgconfig_path}" _pkgconfig_path) - if(UNIX) + if(CMAKE_HOST_UNIX) string(REPLACE ";" ":" _pkgconfig_path "${_pkgconfig_path}") string(REPLACE "\\ " " " _pkgconfig_path "${_pkgconfig_path}") endif() diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake index 2d45965..f35978d 100644 --- a/Modules/FindProtobuf.cmake +++ b/Modules/FindProtobuf.cmake @@ -482,22 +482,24 @@ if(Protobuf_INCLUDE_DIR) "${_PROTOBUF_COMMON_HEADER} reveals protobuf ${Protobuf_VERSION}") endif() - # Check Protobuf compiler version to be aligned with libraries version - execute_process(COMMAND ${Protobuf_PROTOC_EXECUTABLE} --version - OUTPUT_VARIABLE _PROTOBUF_PROTOC_EXECUTABLE_VERSION) + if(Protobuf_PROTOC_EXECUTABLE) + # Check Protobuf compiler version to be aligned with libraries version + execute_process(COMMAND ${Protobuf_PROTOC_EXECUTABLE} --version + OUTPUT_VARIABLE _PROTOBUF_PROTOC_EXECUTABLE_VERSION) - if("${_PROTOBUF_PROTOC_EXECUTABLE_VERSION}" MATCHES "libprotoc ([0-9.]+)") - set(_PROTOBUF_PROTOC_EXECUTABLE_VERSION "${CMAKE_MATCH_1}") - endif() + if("${_PROTOBUF_PROTOC_EXECUTABLE_VERSION}" MATCHES "libprotoc ([0-9.]+)") + set(_PROTOBUF_PROTOC_EXECUTABLE_VERSION "${CMAKE_MATCH_1}") + endif() - if(Protobuf_DEBUG) - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "${Protobuf_PROTOC_EXECUTABLE} reveals version ${_PROTOBUF_PROTOC_EXECUTABLE_VERSION}") - endif() + if(Protobuf_DEBUG) + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "${Protobuf_PROTOC_EXECUTABLE} reveals version ${_PROTOBUF_PROTOC_EXECUTABLE_VERSION}") + endif() - if(NOT "${_PROTOBUF_PROTOC_EXECUTABLE_VERSION}" VERSION_EQUAL "${Protobuf_VERSION}") + if(NOT "${_PROTOBUF_PROTOC_EXECUTABLE_VERSION}" VERSION_EQUAL "${Protobuf_VERSION}") message(WARNING "Protobuf compiler version ${_PROTOBUF_PROTOC_EXECUTABLE_VERSION}" - " doesn't match library version ${Protobuf_VERSION}") + " doesn't match library version ${Protobuf_VERSION}") + endif() endif() if(Protobuf_LIBRARY) diff --git a/Modules/FindPython.cmake b/Modules/FindPython.cmake index 2bdfaf3..be272e1 100644 --- a/Modules/FindPython.cmake +++ b/Modules/FindPython.cmake @@ -93,6 +93,13 @@ This module will set the following variables in your project Information returned by ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=False)``. +``Python_SOABI`` + Extension suffix for modules. + + Information returned by + ``distutils.sysconfig.get_config_flag('SOABI')`` or computed from + ``distutils.sysconfig.get_config_flag('EXT_SUFFIX')`` or + ``python-config --extension-suffix``. ``Python_Compiler_FOUND`` System has the Python compiler. ``Python_COMPILER`` @@ -220,12 +227,12 @@ Hints variable will be used, if any. ``Python_FIND_VIRTUALENV`` - This variable defines the handling of virtual environments. It is meaningfull - only when a virtual environment is active (i.e. the ``activate`` script has - been evaluated). In this case, it takes precedence over - ``Python_FIND_REGISTRY`` and ``CMAKE_FIND_FRAMEWORK`` variables. - The ``Python_FIND_VIRTUALENV`` variable can be set to empty or one of the - following: + This variable defines the handling of virtual environments managed by + ``virtualenv`` or ``conda``. It is meaningful only when a virtual environment + is active (i.e. the ``activate`` script has been evaluated). In this case, it + takes precedence over ``Python_FIND_REGISTRY`` and ``CMAKE_FIND_FRAMEWORK`` + variables. The ``Python_FIND_VIRTUALENV`` variable can be set to empty or + one of the following: * ``FIRST``: The virtual environment is used before any other standard paths to look-up for the interpreter. This is the default. diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index 219a885..7483d72 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -247,12 +247,16 @@ endfunction() function (_PYTHON_GET_CONFIG_VAR _PYTHON_PGCV_VALUE NAME) unset (${_PYTHON_PGCV_VALUE} PARENT_SCOPE) - if (NOT NAME MATCHES "^(PREFIX|ABIFLAGS|CONFIGDIR|INCLUDES|LIBS)$") + if (NOT NAME MATCHES "^(PREFIX|ABIFLAGS|CONFIGDIR|INCLUDES|LIBS|SOABI)$") return() endif() if (_${_PYTHON_PREFIX}_CONFIG) - set (config_flag "--${NAME}") + if (NAME STREQUAL "SOABI") + set (config_flag "--extension-suffix") + else() + set (config_flag "--${NAME}") + endif() string (TOLOWER "${config_flag}" config_flag) execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" ${config_flag} RESULT_VARIABLE _result @@ -267,6 +271,9 @@ function (_PYTHON_GET_CONFIG_VAR _PYTHON_PGCV_VALUE NAME) string (REGEX MATCHALL "(-I|-iwithsysroot)[ ]*[^ ]+" _values "${_values}") string (REGEX REPLACE "(-I|-iwithsysroot)[ ]*" "" _values "${_values}") list (REMOVE_DUPLICATES _values) + elseif (NAME STREQUAL "SOABI") + # clean-up: remove prefix character and suffix + string (REGEX REPLACE "^[.-](.+)(${CMAKE_SHARED_LIBRARY_SUFFIX}|\.(so|pyd))$" "\\1" _values "${_values}") endif() endif() endif() @@ -292,6 +299,25 @@ function (_PYTHON_GET_CONFIG_VAR _PYTHON_PGCV_VALUE NAME) if (_result) unset (_values) endif() + elseif (NAME STREQUAL "SOABI") + execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; from distutils import sysconfig;sys.stdout.write(';'.join([sysconfig.get_config_var('SOABI') or '',sysconfig.get_config_var('EXT_SUFFIX') or '']))" + RESULT_VARIABLE _result + OUTPUT_VARIABLE _soabi + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (_result) + unset (_values) + else() + list (GET _soabi 0 _values) + if (NOT _values) + # try to compute SOABI from EXT_SUFFIX + list (GET _soabi 1 _values) + if (_values) + # clean-up: remove prefix character and suffix + string (REGEX REPLACE "^[.-](.+)(${CMAKE_SHARED_LIBRARY_SUFFIX}|\.(so|pyd))$" "\\1" _values "${_values}") + endif() + endif() + endif() else() set (config_flag "${NAME}") if (NAME STREQUAL "CONFIGDIR") @@ -412,6 +438,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}\"") set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "_${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND") return() endif() @@ -430,6 +457,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}\"") set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "_${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND") return() endif() @@ -447,6 +475,11 @@ function (_PYTHON_VALIDATE_INTERPRETER) OUTPUT_STRIP_TRAILING_WHITESPACE) if (result OR (_PVI_EXACT AND NOT version VERSION_EQUAL expected_version) OR (version VERSION_LESS expected_version)) # interpreter not usable or has wrong major version + if (result) + set (_${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE "Cannot use the interpreter \"${_${_PYTHON_PREFIX}_EXECUTABLE}\"") + else() + set (_${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE "Wrong major version for the interpreter \"${_${_PYTHON_PREFIX}_EXECUTABLE}\"") + endif() set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "_${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND") return() endif() @@ -462,6 +495,11 @@ function (_PYTHON_VALIDATE_INTERPRETER) OUTPUT_STRIP_TRAILING_WHITESPACE) 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}\"") + else() + set (_${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE "Wrong major version for the interpreter \"${_${_PYTHON_PREFIX}_EXECUTABLE}\"") + endif() set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "_${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND") return() endif() @@ -479,6 +517,11 @@ function (_PYTHON_VALIDATE_INTERPRETER) OUTPUT_STRIP_TRAILING_WHITESPACE) 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}\"") + else() + set (_${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE "Wrong architecture for the interpreter \"${_${_PYTHON_PREFIX}_EXECUTABLE}\"") + endif() set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "_${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND") return() endif() @@ -503,6 +546,7 @@ function (_PYTHON_VALIDATE_COMPILER expected_version) 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}\"") set_property (CACHE _${_PYTHON_PREFIX}_COMPILER PROPERTY VALUE "_${_PYTHON_PREFIX}_COMPILER-NOTFOUND") return() endif() @@ -529,6 +573,11 @@ function (_PYTHON_VALIDATE_COMPILER expected_version) if (result OR (_PVC_EXACT AND NOT version VERSION_EQUAL expected_version) OR (version VERSION_LESS expected_version)) # Compiler not usable or has wrong version + if (result) + set (_${_PYTHON_PREFIX}_Compiler_REASON_FAILURE "Cannot use the compiler \"${_${_PYTHON_PREFIX}_COMPILER}\"") + else() + set (_${_PYTHON_PREFIX}_Compiler_REASON_FAILURE "Wrong version for the compiler \"${_${_PYTHON_PREFIX}_COMPILER}\"") + endif() set_property (CACHE _${_PYTHON_PREFIX}_COMPILER PROPERTY VALUE "_${_PYTHON_PREFIX}_COMPILER-NOTFOUND") endif() endfunction() @@ -548,6 +597,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}\"") 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") @@ -561,16 +611,19 @@ 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}\"") set_property (CACHE _${_PYTHON_PREFIX}_LIBRARY_RELEASE PROPERTY VALUE "_${_PYTHON_PREFIX}_LIBRARY_RELEASE-NOTFOUND") else() if (expected_version) if ((_PVL_EXACT AND NOT lib_VERSION VERSION_EQUAL expected_version) OR (lib_VERSION VERSION_LESS expected_version)) # library has wrong version + set (_${_PYTHON_PREFIX}_Development_REASON_FAILURE "Wrong version for the library \"${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}\"") set_property (CACHE _${_PYTHON_PREFIX}_LIBRARY_RELEASE PROPERTY VALUE "_${_PYTHON_PREFIX}_LIBRARY_RELEASE-NOTFOUND") 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}\"") set_property (CACHE _${_PYTHON_PREFIX}_LIBRARY_RELEASE PROPERTY VALUE "_${_PYTHON_PREFIX}_LIBRARY_RELEASE-NOTFOUND") endif() endif() @@ -599,6 +652,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}\"") set_property (CACHE _${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "_${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND") return() endif() @@ -608,16 +662,19 @@ 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}\"") set_property (CACHE _${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "_${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND") else() if (expected_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}\"") set_property (CACHE _${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "_${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND") 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}\"") set_property (CACHE _${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "_${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND") endif() endif() @@ -717,6 +774,7 @@ else() _python_get_abiflags (_${_PYTHON_PREFIX}_ABIFLAGS) endif() endif() +unset (${_PYTHON_PREFIX}_SOABI) # Define lookup strategy if (_${_PYTHON_PREFIX}_LOOKUP_POLICY STREQUAL "NEW") @@ -806,8 +864,8 @@ else() set (_${_PYTHON_PREFIX}_FIND_REGISTRY "FIRST") endif() -# virtual environments handling -if (DEFINED ENV{VIRTUAL_ENV}) +# virtual environments recognition +if (DEFINED ENV{VIRTUAL_ENV} OR DEFINED ENV{CONDA_PREFIX}) if (DEFINED ${_PYTHON_PREFIX}_FIND_VIRTUALENV) if (NOT ${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY|STANDARD)$") message (AUTHOR_WARNING "Find${_PYTHON_PREFIX}: ${${_PYTHON_PREFIX}_FIND_VIRTUALENV}: invalid value for '${_PYTHON_PREFIX}_FIND_VIRTUALENV'. 'FIRST', 'ONLY' or 'STANDARD' expected. 'FIRST' will be used instead.") @@ -839,6 +897,10 @@ endif() unset (_${_PYTHON_PREFIX}_REQUIRED_VARS) unset (_${_PYTHON_PREFIX}_CACHED_VARS) +unset (_${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE) +unset (_${_PYTHON_PREFIX}_Compiler_REASON_FAILURE) +unset (_${_PYTHON_PREFIX}_Development_REASON_FAILURE) +unset (_${_PYTHON_PREFIX}_NumPy_REASON_FAILURE) # first step, search for the interpreter @@ -898,7 +960,7 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) NAMES ${_${_PYTHON_PREFIX}_NAMES} NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATHS ENV VIRTUAL_ENV + PATHS ENV VIRTUAL_ENV ENV CONDA_PREFIX PATH_SUFFIXES bin Scripts NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH @@ -1018,7 +1080,7 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) NAMES ${_${_PYTHON_PREFIX}_NAMES} NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATHS ENV VIRTUAL_ENV + PATHS ENV VIRTUAL_ENV ENV CONDA_PREFIX PATH_SUFFIXES bin Scripts NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH @@ -1164,6 +1226,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}\"") endif() endif() @@ -1234,7 +1297,6 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) # retrieve various package installation directories execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; from distutils import sysconfig;sys.stdout.write(';'.join([sysconfig.get_python_lib(plat_specific=False,standard_lib=True),sysconfig.get_python_lib(plat_specific=True,standard_lib=True),sysconfig.get_python_lib(plat_specific=False,standard_lib=False),sysconfig.get_python_lib(plat_specific=True,standard_lib=False)]))" - RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT OUTPUT_VARIABLE _${_PYTHON_PREFIX}_LIBPATHS ERROR_QUIET) @@ -1249,6 +1311,10 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) unset (${_PYTHON_PREFIX}_SITELIB) unset (${_PYTHON_PREFIX}_SITEARCH) endif() + + if (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR VERSION_GREATER_EQUAL 3) + _python_get_config_var (${_PYTHON_PREFIX}_SOABI SOABI) + endif() else() unset (_${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE CACHE) unset (${_PYTHON_PREFIX}_INTERPRETER_ID) @@ -1419,6 +1485,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}\"") endif() file (REMOVE_RECURSE "${_${_PYTHON_PREFIX}_VERSION_DIR}") endif() @@ -1488,9 +1555,13 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS unset (_${_PYTHON_PREFIX}_LIBRARY_RELEASE CACHE) unset (_${_PYTHON_PREFIX}_LIBRARY_DEBUG CACHE) unset (_${_PYTHON_PREFIX}_INCLUDE_DIR CACHE) - unset (_${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE CACHE) endif() endif() + if (NOT _${_PYTHON_PREFIX}_LIBRARY_RELEASE OR NOT _${_PYTHON_PREFIX}_INCLUDE_DIR) + unset (_${_PYTHON_PREFIX}_CONFIG CACHE) + unset (_${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE CACHE) + endif() + if (DEFINED ${_PYTHON_PREFIX}_LIBRARY AND IS_ABSOLUTE "${${_PYTHON_PREFIX}_LIBRARY}") set (_${_PYTHON_PREFIX}_LIBRARY_RELEASE "${${_PYTHON_PREFIX}_LIBRARY}" CACHE INTERNAL "") @@ -1521,7 +1592,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS set (_${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR) unset (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS) if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$") - set (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS ENV VIRTUAL_ENV) + set (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS ENV VIRTUAL_ENV ENV CONDA_PREFIX) endif() unset (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS) @@ -1752,7 +1823,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS unset (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS) if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$") - set (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS ENV VIRTUAL_ENV) + set (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS ENV VIRTUAL_ENV ENV CONDA_PREFIX) endif() if (_${_PYTHON_PREFIX}_FIND_STRATEGY STREQUAL "LOCATION") @@ -1917,6 +1988,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS set (${_PYTHON_PREFIX}_LIBRARY_RELEASE "${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}" CACHE FILEPATH "Path to a library." FORCE) 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}_LIBRARY_RELEASE PROPERTY VALUE "_${_PYTHON_PREFIX}_LIBRARY_RELEASE-NOTFOUND") endif() @@ -1972,7 +2044,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS if (NOT _${_PYTHON_PREFIX}_INCLUDE_DIR) unset (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS) if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$") - set (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS ENV VIRTUAL_ENV) + set (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS ENV VIRTUAL_ENV ENV CONDA_PREFIX) endif() unset (_${_PYTHON_PREFIX}_INCLUDE_HINTS) @@ -2049,6 +2121,7 @@ if ("Development" 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}_INCLUDE_DIR PROPERTY VALUE "_${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND") endif() @@ -2112,6 +2185,11 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS endif() endif() + if (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR VERSION_GREATER_EQUAL 3 + AND NOT DEFINED ${_PYTHON_PREFIX}_SOABI) + _python_get_config_var (${_PYTHON_PREFIX}_SOABI SOABI) + endif() + if (${_PYTHON_PREFIX}_Development_FOUND) # compute and save development signature string (MD5 __${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}:${_${_PYTHON_PREFIX}_INCLUDE_DIR}") @@ -2130,6 +2208,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG _${_PYTHON_PREFIX}_INCLUDE_DIR + _${_PYTHON_PREFIX}_CONFIG _${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE) endif() @@ -2172,6 +2251,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_INCLUDE_DIR PROPERTY VALUE "_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR-NOTFOUND") endif() @@ -2210,11 +2290,19 @@ if (${_PYTHON_PREFIX}_VERSION_MAJOR AND _python_display_failure ("Could NOT find ${_PYTHON_PREFIX}: Found unsuitable major version \"${${_PYTHON_PREFIX}_VERSION_MAJOR}\", but required major version is exact version \"${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}\"") endif() +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}") + endif() +endforeach() + include (${CMAKE_CURRENT_LIST_DIR}/../FindPackageHandleStandardArgs.cmake) find_package_handle_standard_args (${_PYTHON_PREFIX} REQUIRED_VARS ${_${_PYTHON_PREFIX}_REQUIRED_VARS} VERSION_VAR ${_PYTHON_PREFIX}_VERSION - HANDLE_COMPONENTS) + HANDLE_COMPONENTS + REASON_FAILURE_MESSAGE "${_${_PYTHON_PREFIX}_REASON_FAILURE}") # Create imported targets and helper functions if(_${_PYTHON_PREFIX}_CMAKE_ROLE STREQUAL "PROJECT") @@ -2380,5 +2468,3 @@ if (DEFINED _${_PYTHON_PREFIX}_CMAKE_FIND_FRAMEWORK) else() unset (CMAKE_FIND_FRAMEWORK) endif() - -unset (_${_PYTHON_PREFIX}_CONFIG CACHE) diff --git a/Modules/FindPython2.cmake b/Modules/FindPython2.cmake index 3cc7d56..9d4eda2 100644 --- a/Modules/FindPython2.cmake +++ b/Modules/FindPython2.cmake @@ -176,12 +176,12 @@ Hints variable will be used, if any. ``Python2_FIND_VIRTUALENV`` - This variable defines the handling of virtual environments. It is meaningfull - only when a virtual environment is active (i.e. the ``activate`` script has - been evaluated). In this case, it takes precedence over - ``Python2_FIND_REGISTRY`` and ``CMAKE_FIND_FRAMEWORK`` variables. - The ``Python2_FIND_VIRTUALENV`` variable can be set to empty or one of the - following: + This variable defines the handling of virtual environments managed by + ``virtualenv`` or ``conda``. It is meaningful only when a virtual environment + is active (i.e. the ``activate`` script has been evaluated). In this case, it + takes precedence over ``Python2_FIND_REGISTRY`` and ``CMAKE_FIND_FRAMEWORK`` + variables. The ``Python2_FIND_VIRTUALENV`` variable can be set to empty or + one of the following: * ``FIRST``: The virtual environment is used before any other standard paths to look-up for the interpreter. This is the default. diff --git a/Modules/FindPython3.cmake b/Modules/FindPython3.cmake index 066d0df..00c354e 100644 --- a/Modules/FindPython3.cmake +++ b/Modules/FindPython3.cmake @@ -94,6 +94,13 @@ This module will set the following variables in your project Information returned by ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=False)``. +``Python3_SOABI`` + Extension suffix for modules. + + Information returned by + ``distutils.sysconfig.get_config_flag('SOABI')`` or computed from + ``distutils.sysconfig.get_config_flag('EXT_SUFFIX')`` or + ``python3-config --extension-suffix``. ``Python3_Compiler_FOUND`` System has the Python 3 compiler. ``Python3_COMPILER`` @@ -217,12 +224,12 @@ Hints variable will be used, if any. ``Python3_FIND_VIRTUALENV`` - This variable defines the handling of virtual environments. It is meaningfull - only when a virtual environment is active (i.e. the ``activate`` script has - been evaluated). In this case, it takes precedence over - ``Python3_FIND_REGISTRY`` and ``CMAKE_FIND_FRAMEWORK`` variables. - The ``Python3_FIND_VIRTUALENV`` variable can be set to empty or one of the - following: + This variable defines the handling of virtual environments managed by + ``virtualenv`` or ``conda``. It is meaningful only when a virtual environment + is active (i.e. the ``activate`` script has been evaluated). In this case, it + takes precedence over ``Python3_FIND_REGISTRY`` and ``CMAKE_FIND_FRAMEWORK`` + variables. The ``Python3_FIND_VIRTUALENV`` variable can be set to empty or + one of the following: * ``FIRST``: The virtual environment is used before any other standard paths to look-up for the interpreter. This is the default. diff --git a/Modules/FindTCL.cmake b/Modules/FindTCL.cmake index be47c39..960265f 100644 --- a/Modules/FindTCL.cmake +++ b/Modules/FindTCL.cmake @@ -224,12 +224,14 @@ find_path(TK_INCLUDE_PATH include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(TCL DEFAULT_MSG TCL_LIBRARY TCL_INCLUDE_PATH) +set(FPHSA_NAME_MISMATCHED 1) set(TCLTK_FIND_REQUIRED ${TCL_FIND_REQUIRED}) set(TCLTK_FIND_QUIETLY ${TCL_FIND_QUIETLY}) FIND_PACKAGE_HANDLE_STANDARD_ARGS(TCLTK DEFAULT_MSG TCL_LIBRARY TCL_INCLUDE_PATH TK_LIBRARY TK_INCLUDE_PATH) set(TK_FIND_REQUIRED ${TCL_FIND_REQUIRED}) set(TK_FIND_QUIETLY ${TCL_FIND_QUIETLY}) FIND_PACKAGE_HANDLE_STANDARD_ARGS(TK DEFAULT_MSG TK_LIBRARY TK_INCLUDE_PATH) +unset(FPHSA_NAME_MISMATCHED) mark_as_advanced( TCL_INCLUDE_PATH diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake index b0c91b2..85174d9 100644 --- a/Modules/FindThreads.cmake +++ b/Modules/FindThreads.cmake @@ -63,6 +63,7 @@ int main(void) pthread_t thread; pthread_create(&thread, NULL, test_func, NULL); pthread_detach(thread); + pthread_cancel(thread); pthread_join(thread, NULL); pthread_atfork(NULL, NULL, NULL); pthread_exit(NULL); @@ -90,7 +91,7 @@ macro(_check_pthreads_flag) if(NOT Threads_FOUND) # If we did not found -lpthread, -lpthread, or -lthread, look for -pthread if(NOT DEFINED THREADS_HAVE_PTHREAD_ARG) - message(STATUS "Check if compiler accepts -pthread") + message(CHECK_START "Check if compiler accepts -pthread") if(CMAKE_C_COMPILER_LOADED) set(_threads_src ${CMAKE_CURRENT_LIST_DIR}/CheckForPthreads.c) elseif(CMAKE_CXX_COMPILER_LOADED) @@ -106,9 +107,9 @@ macro(_check_pthreads_flag) if(THREADS_HAVE_PTHREAD_ARG) set(Threads_FOUND TRUE) - message(STATUS "Check if compiler accepts -pthread - yes") + message(CHECK_PASS "yes") else() - message(STATUS "Check if compiler accepts -pthread - no") + message(CHECK_FAIL "no") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if compiler accepts -pthread failed with the following output:\n${OUTPUT}\n\n") diff --git a/Modules/FortranCInterface.cmake b/Modules/FortranCInterface.cmake index 893a96f..547346b 100644 --- a/Modules/FortranCInterface.cmake +++ b/Modules/FortranCInterface.cmake @@ -341,7 +341,7 @@ function(FortranCInterface_VERIFY) # Build the verification project if not yet built. if(NOT DEFINED FortranCInterface_VERIFIED_${lang}) set(_desc "Verifying Fortran/${lang} Compiler Compatibility") - message(STATUS "${_desc}") + message(CHECK_START "${_desc}") # Build a sample project which reports symbols. set(CMAKE_TRY_COMPILE_CONFIGURATION Release) @@ -363,12 +363,12 @@ function(FortranCInterface_VERIFY) # Report results. if(FortranCInterface_VERIFY_${lang}_COMPILED) - message(STATUS "${_desc} - Success") + message(CHECK_PASS "Success") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "${_desc} passed with the following output:\n${_output}\n\n") set(FortranCInterface_VERIFIED_${lang} 1 CACHE INTERNAL "Fortran/${lang} compatibility") else() - message(STATUS "${_desc} - Failed") + message(CHECK_FAIL "Failed") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "${_desc} failed with the following output:\n${_output}\n\n") set(FortranCInterface_VERIFIED_${lang} 0 CACHE INTERNAL "Fortran/${lang} compatibility") diff --git a/Modules/FortranCInterface/Detect.cmake b/Modules/FortranCInterface/Detect.cmake index 7789785..33de6c6 100644 --- a/Modules/FortranCInterface/Detect.cmake +++ b/Modules/FortranCInterface/Detect.cmake @@ -15,7 +15,7 @@ if(${FortranCInterface_BINARY_DIR}/Input.cmake OR ${CMAKE_CURRENT_LIST_FILE} IS_NEWER_THAN ${FortranCInterface_BINARY_DIR}/Output.cmake ) - message(STATUS "Detecting Fortran/C Interface") + message(CHECK_START "Detecting Fortran/C Interface") else() return() endif() @@ -172,7 +172,9 @@ if(FortranCInterface_GLOBAL_FOUND) else() set(_result "Found GLOBAL but not MODULE mangling") endif() + set(_result_type CHECK_PASS) elseif(NOT _result) set(_result "Failed to recognize symbols") + set(_result_type CHECK_FAIL) endif() -message(STATUS "Detecting Fortran/C Interface - ${_result}") +message(${_result_type} "${_result}") diff --git a/Modules/GNUInstallDirs.cmake b/Modules/GNUInstallDirs.cmake index f95e6e2..9ef22b9 100644 --- a/Modules/GNUInstallDirs.cmake +++ b/Modules/GNUInstallDirs.cmake @@ -221,6 +221,11 @@ if(NOT DEFINED CMAKE_INSTALL_LIBDIR OR (_libdir_set # default one. When CMAKE_INSTALL_PREFIX changes, the value is # updated to the new default, unless the user explicitly changed it. endif() + if (NOT DEFINED CMAKE_SYSTEM_NAME OR NOT DEFINED CMAKE_SIZEOF_VOID_P) + message(AUTHOR_WARNING + "Unable to determine default CMAKE_INSTALL_LIBDIR directory because no target architecture is known. " + "Please enable at least one language before including GNUInstallDirs.") + endif() if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$" AND NOT CMAKE_CROSSCOMPILING AND NOT EXISTS "/etc/arch-release") @@ -235,16 +240,10 @@ if(NOT DEFINED CMAKE_INSTALL_LIBDIR OR (_libdir_set endif() endif() else() # not debian, rely on CMAKE_SIZEOF_VOID_P: - if(NOT DEFINED CMAKE_SIZEOF_VOID_P) - message(AUTHOR_WARNING - "Unable to determine default CMAKE_INSTALL_LIBDIR directory because no target architecture is known. " - "Please enable at least one language before including GNUInstallDirs.") - else() - if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") - set(_LIBDIR_DEFAULT "lib64") - if(DEFINED _GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX) - set(__LAST_LIBDIR_DEFAULT "lib64") - endif() + if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") + set(_LIBDIR_DEFAULT "lib64") + if(DEFINED _GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX) + set(__LAST_LIBDIR_DEFAULT "lib64") endif() endif() endif() diff --git a/Modules/Internal/CPack/CPackDeb.cmake b/Modules/Internal/CPack/CPackDeb.cmake index 3927b1a..14bb104 100644 --- a/Modules/Internal/CPack/CPackDeb.cmake +++ b/Modules/Internal/CPack/CPackDeb.cmake @@ -540,7 +540,8 @@ function(cpack_deb_prepare_package_vars) # Ok, description has set. According to the `Debian Policy Manual`_ the frist # line is a pacakge summary. Try to get it as well... # See also: https://www.debian.org/doc/debian-policy/ch-controlfields.html#description - elseif(CPACK_PACKAGE_DESCRIPTION_SUMMARY) + elseif(CPACK_PACKAGE_DESCRIPTION_SUMMARY AND + NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY STREQUAL CPACK_DEFAULT_PACKAGE_DESCRIPTION_SUMMARY) # Merge summary w/ the detailed description string(PREPEND CPACK_DEBIAN_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}\n") endif() @@ -553,8 +554,8 @@ function(cpack_deb_prepare_package_vars) ) # Homepage: (optional) - if(NOT CPACK_DEBIAN_PACKAGE_HOMEPAGE AND CMAKE_PROJECT_HOMEPAGE_URL) - set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "${CMAKE_PROJECT_HOMEPAGE_URL}") + if(NOT CPACK_DEBIAN_PACKAGE_HOMEPAGE AND CPACK_PACKAGE_HOMEPAGE_URL) + set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "${CPACK_PACKAGE_HOMEPAGE_URL}") endif() # Section: (recommended) diff --git a/Modules/Internal/CPack/CPackFreeBSD.cmake b/Modules/Internal/CPack/CPackFreeBSD.cmake index 16f906c..ae40532 100644 --- a/Modules/Internal/CPack/CPackFreeBSD.cmake +++ b/Modules/Internal/CPack/CPackFreeBSD.cmake @@ -68,7 +68,7 @@ _cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_DESCRIPTION" # There's really only one homepage for a project, so # re-use the Debian setting if it's there. _cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_WWW" - "CMAKE_PROJECT_HOMEPAGE_URL" + "CPACK_PACKAGE_HOMEPAGE_URL" "CPACK_DEBIAN_PACKAGE_HOMEPAGE" "_cpack_freebsd_fallback_www" ) diff --git a/Modules/Internal/CPack/CPackNuGet.cmake b/Modules/Internal/CPack/CPackNuGet.cmake index 82053b2..1f4bcfd 100644 --- a/Modules/Internal/CPack/CPackNuGet.cmake +++ b/Modules/Internal/CPack/CPackNuGet.cmake @@ -230,31 +230,22 @@ function(_cpack_nuget_render_spec) foreach(_dep IN LISTS _deps) _cpack_nuget_debug(" checking dependency `${_dep}`") - string(MAKE_C_IDENTIFIER "${_dep}" _dep_id) - - _cpack_nuget_variable_fallback(_ver DEPENDENCIES_${_dep_id}_VERSION) + _cpack_nuget_variable_fallback(_ver DEPENDENCIES_${_dep}_VERSION) if(NOT _ver) - string(TOUPPER "${_dep_id}" _dep_id) - _cpack_nuget_variable_fallback(_ver DEPENDENCIES_${_dep_id}_VERSION) + string(TOUPPER "${_dep}" _dep_upper) + _cpack_nuget_variable_fallback(_ver DEPENDENCIES_${_dep_upper}_VERSION) endif() if(_ver) _cpack_nuget_debug(" got `${_dep}` dependency version ${_ver}") - list(APPEND _collected_deps "<dependency id=\"${_dep}\" version=\"${_ver}\" />") + string(CONCAT _collected_deps "${_collected_deps}" " <dependency id=\"${_dep}\" version=\"${_ver}\" />\n") endif() endforeach() # Render deps into the variable if(_collected_deps) - set(_CPACK_NUGET_DEPENDENCIES_TAG "<dependencies>\n") - foreach(_line IN LISTS _collected_deps) - string( - APPEND _CPACK_NUGET_DEPENDENCIES_TAG - " ${_line}\n" - ) - endforeach() - string(APPEND _CPACK_NUGET_DEPENDENCIES_TAG " </dependencies>") + string(CONCAT _CPACK_NUGET_DEPENDENCIES_TAG "<dependencies>\n" "${_collected_deps}" " </dependencies>") endif() # Render the spec file diff --git a/Modules/Internal/CPack/CPackRPM.cmake b/Modules/Internal/CPack/CPackRPM.cmake index ffb24e2..3485e7d 100644 --- a/Modules/Internal/CPack/CPackRPM.cmake +++ b/Modules/Internal/CPack/CPackRPM.cmake @@ -844,8 +844,8 @@ function(cpack_rpm_generate_package) endif() endif() - if(NOT CPACK_RPM_PACKAGE_URL AND CMAKE_PROJECT_HOMEPAGE_URL) - set(CPACK_RPM_PACKAGE_URL "${CMAKE_PROJECT_HOMEPAGE_URL}") + if(NOT CPACK_RPM_PACKAGE_URL AND CPACK_PACKAGE_HOMEPAGE_URL) + set(CPACK_RPM_PACKAGE_URL "${CPACK_PACKAGE_HOMEPAGE_URL}") endif() # CPACK_RPM_PACKAGE_NAME (mandatory) diff --git a/Modules/Internal/CPack/NSIS.template.in b/Modules/Internal/CPack/NSIS.template.in index f75ae78..660bfa3 100644 --- a/Modules/Internal/CPack/NSIS.template.in +++ b/Modules/Internal/CPack/NSIS.template.in @@ -524,14 +524,6 @@ FunctionEnd !endif ;-------------------------------- -; Installation types -@CPACK_NSIS_INSTALLATION_TYPES@ - -;-------------------------------- -; Component sections -@CPACK_NSIS_COMPONENT_SECTIONS@ - -;-------------------------------- ; Define some macro setting for the gui @CPACK_NSIS_INSTALLER_MUI_ICON_CODE@ @CPACK_NSIS_INSTALLER_ICON_CODE@ @@ -542,6 +534,8 @@ FunctionEnd ;-------------------------------- ;Pages + @CPACK_NSIS_INSTALLER_WELCOME_TITLE_CODE@ + @CPACK_NSIS_INSTALLER_WELCOME_TITLE_3LINES_CODE@ !insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_LICENSE "@CPACK_RESOURCE_FILE_LICENSE@" @@ -557,6 +551,8 @@ FunctionEnd @CPACK_NSIS_PAGE_COMPONENTS@ !insertmacro MUI_PAGE_INSTFILES + @CPACK_NSIS_INSTALLER_FINISH_TITLE_CODE@ + @CPACK_NSIS_INSTALLER_FINISH_TITLE_3LINES_CODE@ !insertmacro MUI_PAGE_FINISH !insertmacro MUI_UNPAGE_CONFIRM @@ -617,7 +613,6 @@ FunctionEnd !insertmacro MUI_LANGUAGE "Ukrainian" !insertmacro MUI_LANGUAGE "Welsh" - ;-------------------------------- ;Reserve Files @@ -628,6 +623,17 @@ FunctionEnd ReserveFile "NSIS.InstallOptions.ini" !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS + ; for UserInfo::GetName and UserInfo::GetAccountType + ReserveFile /plugin 'UserInfo.dll' + +;-------------------------------- +; Installation types +@CPACK_NSIS_INSTALLATION_TYPES@ + +;-------------------------------- +; Component sections +@CPACK_NSIS_COMPONENT_SECTIONS@ + ;-------------------------------- ;Installer Sections @@ -642,7 +648,7 @@ Section "-Core installation" WriteRegStr SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "" $INSTDIR ;Create uninstaller - WriteUninstaller "$INSTDIR\Uninstall.exe" + WriteUninstaller "$INSTDIR\@CPACK_NSIS_UNINSTALL_NAME@.exe" Push "DisplayName" Push "@CPACK_NSIS_DISPLAY_NAME@" Call ConditionalAddToRegisty @@ -653,7 +659,7 @@ Section "-Core installation" Push "@CPACK_PACKAGE_VENDOR@" Call ConditionalAddToRegisty Push "UninstallString" - Push "$INSTDIR\Uninstall.exe" + Push "$INSTDIR\@CPACK_NSIS_UNINSTALL_NAME@.exe" Call ConditionalAddToRegisty Push "NoRepair" Push "1" @@ -690,7 +696,7 @@ Section "-Core installation" CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER" @CPACK_NSIS_CREATE_ICONS@ @CPACK_NSIS_CREATE_ICONS_EXTRA@ - CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe" + CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\@CPACK_NSIS_UNINSTALL_NAME@.exe" ;Read a value from an InstallOptions INI file !insertmacro MUI_INSTALLOPTIONS_READ $DO_NOT_ADD_TO_PATH "NSIS.InstallOptions.ini" "Field 2" "State" @@ -829,7 +835,7 @@ Section "Uninstall" !endif ;Remove the uninstaller itself. - Delete "$INSTDIR\Uninstall.exe" + Delete "$INSTDIR\@CPACK_NSIS_UNINSTALL_NAME@.exe" DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" ;Remove the installation directory if it is empty. diff --git a/Modules/Internal/FeatureTesting.cmake b/Modules/Internal/FeatureTesting.cmake index 75be473..72d96b3 100644 --- a/Modules/Internal/FeatureTesting.cmake +++ b/Modules/Internal/FeatureTesting.cmake @@ -89,6 +89,16 @@ macro(_record_compiler_features_cxx std) unset(lang_level_has_features) endmacro() +macro(_record_compiler_features_cuda std) + list(APPEND CMAKE_CUDA${std}_COMPILE_FEATURES cuda_std_${std}) + + get_property(lang_level_has_features GLOBAL PROPERTY CMAKE_CUDA${std}_KNOWN_FEATURES) + if(lang_level_has_features) + _record_compiler_features(CUDA "${CMAKE_CUDA${std}_STANDARD_COMPILE_OPTION}" CMAKE_CUDA${std}_COMPILE_FEATURES) + endif() + unset(lang_level_has_features) +endmacro() + macro(_has_compiler_features lang level compile_flags feature_list) # presume all known features are supported get_property(known_features GLOBAL PROPERTY CMAKE_${lang}${level}_KNOWN_FEATURES) @@ -103,3 +113,7 @@ macro(_has_compiler_features_cxx std) list(APPEND CMAKE_CXX${std}_COMPILE_FEATURES cxx_std_${std}) _has_compiler_features(CXX ${std} "${CMAKE_CXX${std}_STANDARD_COMPILE_OPTION}" CMAKE_CXX${std}_COMPILE_FEATURES) endmacro() +macro(_has_compiler_features_cuda std) + list(APPEND CMAKE_CUDA${std}_COMPILE_FEATURES cuda_std_${std}) + _has_compiler_features(CUDA ${std} "${CMAKE_CUDA${std}_STANDARD_COMPILE_OPTION}" CMAKE_CUDA${std}_COMPILE_FEATURES) +endmacro() diff --git a/Modules/Platform/AIX-GNU.cmake b/Modules/Platform/AIX-GNU.cmake index 61d213a..5a532c7 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>/objects.exp <OBJECTS>" - "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> -Wl,-bE:<OBJECT_DIR>/objects.exp <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" + "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <OBJECT_DIR>/exports.exp <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 . <OBJECTS>" + "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <TARGET_IMPLIB> -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 64b0bc1..2a8c159 100644 --- a/Modules/Platform/AIX-XL.cmake +++ b/Modules/Platform/AIX-XL.cmake @@ -18,14 +18,24 @@ macro(__aix_compiler_xl lang) set(CMAKE_${lang}_LINK_FLAGS "-Wl,-bnoipath") + set(_OBJECTS " <OBJECTS>") + if(DEFINED CMAKE_XL_CreateExportList AND CMAKE_XL_CreateExportList STREQUAL "") + # Prior to CMake 3.16, CMAKE_XL_CreateExportList held the path to the XL CreateExportList tool. + # Users could set it to an empty value to skip automatic exports in favor of manual -bE: flags. + # Preserve that behavior for compatibility (even though it was undocumented). + set(_OBJECTS "") + endif() + # 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>/objects.exp <OBJECTS>" - "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> -Wl,-bE:<OBJECT_DIR>/objects.exp <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" + "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <OBJECT_DIR>/exports.exp <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 . <OBJECTS>" + "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <TARGET_IMPLIB> -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) endmacro() diff --git a/Modules/Platform/AIX/ExportImportList b/Modules/Platform/AIX/ExportImportList index 4f67ef5..891bce7 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>] [--] <objects>...' +usage='usage: ExportImportList -o <out-file> [-l <lib>] [-n] [--] <objects>...' die() { echo "$@" 1>&2; exit 1 @@ -14,10 +14,12 @@ die() { # Process command-line arguments. out='' lib='' +no_objects='' while test "$#" != 0; do case "$1" in -l) shift; lib="$1" ;; -o) shift; out="$1" ;; + -n) no_objects='1' ;; --) shift; break ;; -*) die "$usage" ;; *) break ;; @@ -26,23 +28,28 @@ while test "$#" != 0; do done test -n "$out" || die "$usage" -# Collect symbols exported from all object files. +# Build a temporary file that atomically replaces the output later. out_tmp="$out.tmp$$" trap 'rm -f "$out_tmp"' EXIT INT TERM -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)] +> "$out_tmp" + +# 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)] + } } - } - ' -done > "$out_tmp" + ' + done >> "$out_tmp" +fi # Generate the export/import file. { diff --git a/Modules/Platform/Android-Clang.cmake b/Modules/Platform/Android-Clang.cmake index 847178f..759448b 100644 --- a/Modules/Platform/Android-Clang.cmake +++ b/Modules/Platform/Android-Clang.cmake @@ -24,6 +24,14 @@ if(CMAKE_SYSTEM_VERSION EQUAL 1) return() endif() +# Natively compiling on an Android host doesn't use the NDK cross-compilation +# tools. +if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Android") + macro(__android_compiler_clang lang) + endmacro() + return() +endif() + include(Platform/Android-Common) # The NDK toolchain configuration files at: diff --git a/Modules/Platform/Android-Determine.cmake b/Modules/Platform/Android-Determine.cmake index e7c1b48..2225897 100644 --- a/Modules/Platform/Android-Determine.cmake +++ b/Modules/Platform/Android-Determine.cmake @@ -18,6 +18,12 @@ if(CMAKE_SYSTEM_VERSION EQUAL 1) return() endif() +# Natively compiling on an Android host doesn't use the NDK cross-compilation +# tools. +if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Android") + return() +endif() + cmake_policy(PUSH) cmake_policy(SET CMP0057 NEW) # if IN_LIST diff --git a/Modules/Platform/Android-Initialize.cmake b/Modules/Platform/Android-Initialize.cmake index a5d2820..b90dd7a 100644 --- a/Modules/Platform/Android-Initialize.cmake +++ b/Modules/Platform/Android-Initialize.cmake @@ -24,6 +24,12 @@ if(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED) return() endif() +# Natively compiling on an Android host doesn't use the NDK cross-compilation +# tools. +if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Android") + return() +endif() + if(NOT CMAKE_SYSROOT) if(CMAKE_ANDROID_NDK) set(CMAKE_SYSROOT "${CMAKE_ANDROID_NDK}/platforms/android-${CMAKE_SYSTEM_VERSION}/arch-${CMAKE_ANDROID_ARCH}") diff --git a/Modules/Platform/Android.cmake b/Modules/Platform/Android.cmake index f08f841..8ffa1b2 100644 --- a/Modules/Platform/Android.cmake +++ b/Modules/Platform/Android.cmake @@ -2,6 +2,11 @@ include(Platform/Linux) set(ANDROID 1) +# Natively compiling on an Android host doesn't need these flags to be reset. +if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Android") + return() +endif() + # Conventionally Android does not use versioned soname # But in modern versions it is acceptable if(NOT DEFINED CMAKE_PLATFORM_NO_VERSIONED_SONAME) diff --git a/Modules/Platform/Android/Determine-Compiler.cmake b/Modules/Platform/Android/Determine-Compiler.cmake index 5c6b97b..f9c2d89 100644 --- a/Modules/Platform/Android/Determine-Compiler.cmake +++ b/Modules/Platform/Android/Determine-Compiler.cmake @@ -31,6 +31,16 @@ elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux") set(_ANDROID_HOST_EXT "") elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") set(_ANDROID_HOST_EXT ".exe") +elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Android") + # Natively compiling on an Android host doesn't use the NDK cross-compilation + # tools. + macro(__android_determine_compiler lang) + # Do nothing + endmacro() + if(NOT CMAKE_CXX_COMPILER_NAMES) + set(CMAKE_CXX_COMPILER_NAMES c++) + endif() + return() else() message(FATAL_ERROR "Android: Builds hosted on '${CMAKE_HOST_SYSTEM_NAME}' not supported.") endif() diff --git a/Modules/Platform/Apple-GNU.cmake b/Modules/Platform/Apple-GNU.cmake index 0eb8168..9572736 100644 --- a/Modules/Platform/Apple-GNU.cmake +++ b/Modules/Platform/Apple-GNU.cmake @@ -19,17 +19,17 @@ endmacro() macro(cmake_gnu_set_sysroot_flag lang) if(NOT DEFINED CMAKE_${lang}_SYSROOT_FLAG) set(_doc "${lang} compiler has -isysroot") - message(STATUS "Checking whether ${_doc}") + message(CHECK_START "Checking whether ${_doc}") execute_process( COMMAND ${CMAKE_${lang}_COMPILER} "-v" "--help" OUTPUT_VARIABLE _gcc_help ERROR_VARIABLE _gcc_help ) if("${_gcc_help}" MATCHES "isysroot") - message(STATUS "Checking whether ${_doc} - yes") + message(CHECK_PASS "yes") set(CMAKE_${lang}_SYSROOT_FLAG "-isysroot") else() - message(STATUS "Checking whether ${_doc} - no") + message(CHECK_FAIL "no") set(CMAKE_${lang}_SYSROOT_FLAG "") endif() set(CMAKE_${lang}_SYSROOT_FLAG_CODE "set(CMAKE_${lang}_SYSROOT_FLAG \"${CMAKE_${lang}_SYSROOT_FLAG}\")") @@ -39,17 +39,17 @@ endmacro() macro(cmake_gnu_set_osx_deployment_target_flag lang) if(NOT DEFINED CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG) set(_doc "${lang} compiler supports OSX deployment target flag") - message(STATUS "Checking whether ${_doc}") + message(CHECK_START "Checking whether ${_doc}") execute_process( COMMAND ${CMAKE_${lang}_COMPILER} "-v" "--help" OUTPUT_VARIABLE _gcc_help ERROR_VARIABLE _gcc_help ) if("${_gcc_help}" MATCHES "macosx-version-min") - message(STATUS "Checking whether ${_doc} - yes") + message(CHECK_PASS "yes") set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mmacosx-version-min=") else() - message(STATUS "Checking whether ${_doc} - no") + message(CHECK_FAIL "no") set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "") endif() set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG_CODE "set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG \"${CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG}\")") diff --git a/Modules/Platform/Darwin-Initialize.cmake b/Modules/Platform/Darwin-Initialize.cmake index 2d797f6..729217c 100644 --- a/Modules/Platform/Darwin-Initialize.cmake +++ b/Modules/Platform/Darwin-Initialize.cmake @@ -122,7 +122,97 @@ endforeach() set(CMAKE_OSX_SYSROOT "${_CMAKE_OSX_SYSROOT_DEFAULT}" CACHE ${_CMAKE_OSX_SYSROOT_TYPE} "The product will be built against the headers and libraries located inside the indicated SDK.") -# Transform the cached value to something we can use. +# Resolves the SDK name into a path +function(_apple_resolve_sdk_path sdk_name ret) + execute_process( + COMMAND xcrun -sdk ${sdk_name} --show-sdk-path + OUTPUT_VARIABLE _stdout + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE _stderr + RESULT_VARIABLE _failed + ) + set(${ret} "${_stdout}" PARENT_SCOPE) +endfunction() +# Handle multi-arch sysroots. Do this before CMAKE_OSX_SYSROOT is +# transformed into a path, so that we know the sysroot name. +function(_apple_resolve_multi_arch_sysroots) + if(CMAKE_APPLE_ARCH_SYSROOTS) + return() # Already cached + endif() + + list(LENGTH CMAKE_OSX_ARCHITECTURES _num_archs) + if(NOT (_num_archs GREATER 1)) + return() # Only apply to multi-arch + endif() + + if(CMAKE_OSX_SYSROOT STREQUAL "macosx") + # macOS doesn't have a simulator sdk / sysroot, so there is no need to handle per-sdk arches. + return() + endif() + + if(IS_DIRECTORY "${CMAKE_OSX_SYSROOT}") + if(NOT CMAKE_OSX_SYSROOT STREQUAL _CMAKE_OSX_SYSROOT_DEFAULT) + message(WARNING "Can not resolve multi-arch sysroots with CMAKE_OSX_SYSROOT set to path (${CMAKE_OSX_SYSROOT})") + endif() + return() + endif() + + string(REPLACE "os" "simulator" _simulator_sdk ${CMAKE_OSX_SYSROOT}) + set(_sdks "${CMAKE_OSX_SYSROOT};${_simulator_sdk}") + foreach(sdk ${_sdks}) + _apple_resolve_sdk_path(${sdk} _sdk_path) + if(NOT IS_DIRECTORY "${_sdk_path}") + message(WARNING "Failed to resolve SDK path for '${sdk}'") + continue() + endif() + + execute_process( + COMMAND plutil -extract SupportedTargets.${sdk}.Archs json ${_sdk_path}/SDKSettings.plist -o - + OUTPUT_VARIABLE _sdk_archs_json + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE _stderr + RESULT_VARIABLE _failed + ) + if(_failed) + # Failure to extract supported architectures for an SDK means that the installed SDK is old + # and does not provide such information (SDKs that come with Xcode >= 10.x started providing + # the information). In such a case, return early, and handle multi-arch builds the old way + # (no per-sdk arches). + return() + endif() + + # Poor man's JSON decoding + string(REGEX REPLACE "[]\\[\"]" "" _sdk_archs ${_sdk_archs_json}) + string(REPLACE "," ";" _sdk_archs ${_sdk_archs}) + + set(_sdk_archs_${sdk} ${_sdk_archs}) + set(_sdk_path_${sdk} ${_sdk_path}) + endforeach() + + foreach(arch ${CMAKE_OSX_ARCHITECTURES}) + set(_arch_sysroot "") + foreach(sdk ${_sdks}) + list(FIND _sdk_archs_${sdk} ${arch} arch_index) + if(NOT arch_index EQUAL -1) + set(_arch_sysroot ${_sdk_path_${sdk}}) + break() + endif() + endforeach() + if(_arch_sysroot) + list(APPEND _arch_sysroots ${_arch_sysroot}) + else() + message(WARNING "No SDK found for architecture '${arch}'") + list(APPEND _arch_sysroots "") # Placeholder + endif() + endforeach() + + set(CMAKE_APPLE_ARCH_SYSROOTS "${_arch_sysroots}" CACHE INTERNAL + "Architecture dependent sysroots, one per CMAKE_OSX_ARCHITECTURES") +endfunction() + +_apple_resolve_multi_arch_sysroots() + +# Transform CMAKE_OSX_SYSROOT to absolute path set(_CMAKE_OSX_SYSROOT_PATH "") if(CMAKE_OSX_SYSROOT) if("x${CMAKE_OSX_SYSROOT}" MATCHES "/") @@ -134,16 +224,9 @@ if(CMAKE_OSX_SYSROOT) endif() set(_CMAKE_OSX_SYSROOT_PATH "${CMAKE_OSX_SYSROOT}") else() - # Transform the sdk name into a path. - execute_process( - COMMAND xcodebuild -sdk ${CMAKE_OSX_SYSROOT} -version Path - OUTPUT_VARIABLE _stdout - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_VARIABLE _stderr - RESULT_VARIABLE _failed - ) - if(NOT _failed AND IS_DIRECTORY "${_stdout}") - set(_CMAKE_OSX_SYSROOT_PATH "${_stdout}") + _apple_resolve_sdk_path(${CMAKE_OSX_SYSROOT} _sdk_path) + if(IS_DIRECTORY "${_sdk_path}") + set(_CMAKE_OSX_SYSROOT_PATH "${_sdk_path}") # For non-Xcode generators use the path. if(NOT "${CMAKE_GENERATOR}" MATCHES "Xcode") set(CMAKE_OSX_SYSROOT "${_CMAKE_OSX_SYSROOT_PATH}") diff --git a/Modules/Platform/Generic-SDCC-C.cmake b/Modules/Platform/Generic-SDCC-C.cmake index aef4abf..c51767e 100644 --- a/Modules/Platform/Generic-SDCC-C.cmake +++ b/Modules/Platform/Generic-SDCC-C.cmake @@ -19,14 +19,28 @@ set(CMAKE_DL_LIBS "") set(CMAKE_C_OUTPUT_EXTENSION ".rel") -# find sdcclib as CMAKE_AR -# since cmake may already have searched for "ar", sdcclib has to -# be searched with a different variable name (SDCCLIB_EXECUTABLE) -# and must then be forced into the cache +# find sdar/sdcclib as CMAKE_AR +# since cmake may already have searched for "ar", sdar has to +# be searched with a different variable name (SDCCAR_EXECUTABLE) +# and must then be forced into the cache. +# sdcclib has been deprecated in SDCC 3.2.0 and removed in 3.8.6 +# so we first look for sdar get_filename_component(SDCC_LOCATION "${CMAKE_C_COMPILER}" PATH) -find_program(SDCCLIB_EXECUTABLE sdcclib PATHS "${SDCC_LOCATION}" NO_DEFAULT_PATH) -find_program(SDCCLIB_EXECUTABLE sdcclib) -set(CMAKE_AR "${SDCCLIB_EXECUTABLE}" CACHE FILEPATH "The sdcc librarian" FORCE) +find_program(SDCCAR_EXECUTABLE sdar NAMES sdcclib PATHS "${SDCC_LOCATION}" NO_DEFAULT_PATH) +find_program(SDCCAR_EXECUTABLE sdar NAMES sdcclib) +# for compatibility, in case SDCCLIB_EXECUTABLE is set, we use it +if(DEFINED SDCCLIB_EXECUTABLE) + set(CMAKE_AR "${SDCCLIB_EXECUTABLE}" CACHE FILEPATH "The sdcc librarian" FORCE) +else() + set(CMAKE_AR "${SDCCAR_EXECUTABLE}" CACHE FILEPATH "The sdcc librarian" FORCE) +endif() + + +if("${SDCCAR_EXECUTABLE}" MATCHES "sdcclib") + set(CMAKE_AR_OPTIONS "-a") +else() + set(CMAKE_AR_OPTIONS "-rc") +endif() # CMAKE_C_FLAGS_INIT and CMAKE_EXE_LINKER_FLAGS_INIT should be set in a CMAKE_SYSTEM_PROCESSOR file if(NOT DEFINED CMAKE_C_FLAGS_INIT) @@ -45,10 +59,10 @@ set(CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o # link object files to an executable set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <FLAGS> <OBJECTS> -o <TARGET> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>") -# needs sdcc 2.7.0 + sddclib from cvs +# needs sdcc + sdar/sdcclib set(CMAKE_C_CREATE_STATIC_LIBRARY "\"${CMAKE_COMMAND}\" -E remove <TARGET>" - "<CMAKE_AR> -a <TARGET> <LINK_FLAGS> <OBJECTS> ") + "<CMAKE_AR> ${CMAKE_AR_OPTIONS} <TARGET> <LINK_FLAGS> <OBJECTS> ") # not supported by sdcc set(CMAKE_C_CREATE_SHARED_LIBRARY "") diff --git a/Modules/Platform/Windows-Apple-Swift.cmake b/Modules/Platform/Windows-Apple-Swift.cmake new file mode 100644 index 0000000..1177755 --- /dev/null +++ b/Modules/Platform/Windows-Apple-Swift.cmake @@ -0,0 +1 @@ +set(CMAKE_Swift_IMPLIB_LINKER_FLAGS "-Xlinker -implib:<TARGET_IMPLIB>") diff --git a/Modules/Platform/Windows-Clang-ASM.cmake b/Modules/Platform/Windows-Clang-ASM.cmake new file mode 100644 index 0000000..345d77d --- /dev/null +++ b/Modules/Platform/Windows-Clang-ASM.cmake @@ -0,0 +1,2 @@ +include(Platform/Windows-Clang) +__windows_compiler_clang(ASM) diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake index 02864c6..5eddd04 100644 --- a/Modules/Platform/Windows-Clang.cmake +++ b/Modules/Platform/Windows-Clang.cmake @@ -21,10 +21,12 @@ macro(__windows_compiler_clang_gnu lang) set(CMAKE_SHARED_LIBRARY_SUFFIX ".dll") set(CMAKE_SHARED_MODULE_SUFFIX ".dll") set(CMAKE_STATIC_LIBRARY_SUFFIX ".lib") - set(CMAKE_DEPFILE_FLAGS_${lang} "-MD -MT <OBJECT> -MF <DEPFILE>") + if(NOT "${lang}" STREQUAL "ASM") + set(CMAKE_DEPFILE_FLAGS_${lang} "-MD -MT <OBJECT> -MF <DEPFILE>") + endif() set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "") - set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll" ".dll.a" ".a" ".lib") + set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a" ".a" ".lib") set(CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS 1) set (CMAKE_LINK_DEF_FILE_FLAG "-Xlinker /DEF:") @@ -61,23 +63,25 @@ macro(__windows_compiler_clang_gnu lang) set(CMAKE_${lang}_LINK_EXECUTABLE "<CMAKE_${lang}_COMPILER> -fuse-ld=lld-link -nostartfiles -nostdlib <FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Xlinker /implib:<TARGET_IMPLIB> -Xlinker /pdb:<TARGET_PDB> -Xlinker /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>") - set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -Xclang -flto-visibility-public-std -D_MT -Xclang --dependent-lib=libcmt) - set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -D_DLL -D_MT -Xclang --dependent-lib=msvcrt) - set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -D_DEBUG -Xclang -flto-visibility-public-std -D_MT -Xclang --dependent-lib=libcmtd) - set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd) + if(NOT "${lang}" STREQUAL "ASM") + set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -Xclang -flto-visibility-public-std -D_MT -Xclang --dependent-lib=libcmt) + set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -D_DLL -D_MT -Xclang --dependent-lib=msvcrt) + set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -D_DEBUG -Xclang -flto-visibility-public-std -D_MT -Xclang --dependent-lib=libcmtd) + 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 "") - 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") - endif() + if(CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT) + set(__ADDED_FLAGS "") + set(__ADDED_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") + 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}") + 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}") + endif() set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ") set(CMAKE_PCH_EXTENSION .pch) diff --git a/Modules/Platform/Windows-GNU-ASM.cmake b/Modules/Platform/Windows-GNU-ASM.cmake new file mode 100644 index 0000000..8600892 --- /dev/null +++ b/Modules/Platform/Windows-GNU-ASM.cmake @@ -0,0 +1,2 @@ +include(Platform/Windows-GNU) +__windows_compiler_gnu(ASM) diff --git a/Modules/Platform/Windows-GNU.cmake b/Modules/Platform/Windows-GNU.cmake index 6bf245c..38a8cf4 100644 --- a/Modules/Platform/Windows-GNU.cmake +++ b/Modules/Platform/Windows-GNU.cmake @@ -25,7 +25,7 @@ endif() if(MINGW) set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "") - set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll" ".dll.a" ".a" ".lib") + set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a" ".a" ".lib") set(CMAKE_C_STANDARD_LIBRARIES_INIT "-lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32") set(CMAKE_CXX_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}") endif() @@ -124,7 +124,7 @@ macro(__windows_compiler_gnu lang) string(REPLACE "<OBJECTS>" "-Wl,--whole-archive <OBJECT_DIR>/objects.a -Wl,--no-whole-archive" CMAKE_${lang}_${rule} "${CMAKE_${lang}_${rule}}") set(CMAKE_${lang}_${rule} - "<CMAKE_COMMAND> -E remove -f <OBJECT_DIR>/objects.a" + "<CMAKE_COMMAND> -E rm -f <OBJECT_DIR>/objects.a" "<CMAKE_AR> cr <OBJECT_DIR>/objects.a <OBJECTS>" "${CMAKE_${lang}_${rule}}" ) diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index 34f5d03..e1d6733 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -217,7 +217,7 @@ elseif(WINDOWS_PHONE OR WINDOWS_STORE) else() set(_PLATFORM_DEFINES "/DWIN32") - if(_MSVC_C_ARCHITECTURE_FAMILY STREQUAL "ARM" OR _MSVC_CXX_ARCHITECTURE_FAMILY STREQUAL "ARM" OR _MSVC_C_ARCHITECTURE_FAMILY STREQUAL "ARM64" OR _MSVC_CXX_ARCHITECTURE_FAMILY STREQUAL "ARM64") + if(_MSVC_C_ARCHITECTURE_FAMILY STREQUAL "ARM" OR _MSVC_CXX_ARCHITECTURE_FAMILY STREQUAL "ARM") set(CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib") elseif(MSVC_VERSION GREATER 1310) if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "v[0-9]+_clang_.*") diff --git a/Modules/Platform/Windows-NVIDIA-CUDA.cmake b/Modules/Platform/Windows-NVIDIA-CUDA.cmake index 94d77b9..f809094 100644 --- a/Modules/Platform/Windows-NVIDIA-CUDA.cmake +++ b/Modules/Platform/Windows-NVIDIA-CUDA.cmake @@ -1,11 +1,11 @@ include(Platform/Windows-MSVC) set(CMAKE_CUDA_COMPILE_PTX_COMPILATION - "<CMAKE_CUDA_COMPILER> ${CMAKE_CUDA_HOST_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -ptx <SOURCE> -o <OBJECT> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS") + "<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -ptx <SOURCE> -o <OBJECT> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS") set(CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION - "<CMAKE_CUDA_COMPILER> ${CMAKE_CUDA_HOST_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -dc <SOURCE> -o <OBJECT> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS") + "<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -dc <SOURCE> -o <OBJECT> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS") set(CMAKE_CUDA_COMPILE_WHOLE_COMPILATION - "<CMAKE_CUDA_COMPILER> ${CMAKE_CUDA_HOST_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -c <SOURCE> -o <OBJECT> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS") + "<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -c <SOURCE> -o <OBJECT> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS") set(__IMPLICT_LINKS ) foreach(dir ${CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES}) @@ -30,11 +30,6 @@ set(CMAKE_CUDA_LINK_EXECUTABLE unset(_CMAKE_VS_LINK_EXE) unset(_CMAKE_VS_LINK_EXE) -if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "8.0.0") - set(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS "-Wno-deprecated-gpu-targets") -else() - set(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS "") -endif() # Add implicit host link directories that contain device libraries # to the device link line. @@ -51,11 +46,9 @@ endforeach() unset(__IMPLICT_DLINK_DIRS) set(CMAKE_CUDA_DEVICE_LINK_LIBRARY - "<CMAKE_CUDA_COMPILER> <LANGUAGE_COMPILE_FLAGS> ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS${__IMPLICT_DLINK_FLAGS}") + "<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <LANGUAGE_COMPILE_FLAGS> ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS${__IMPLICT_DLINK_FLAGS}") set(CMAKE_CUDA_DEVICE_LINK_EXECUTABLE - "<CMAKE_CUDA_COMPILER> <FLAGS> ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS${__IMPLICT_DLINK_FLAGS}") - -unset(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS) + "<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <FLAGS> ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS${__IMPLICT_DLINK_FLAGS}") unset(__IMPLICT_DLINK_FLAGS) string(REPLACE "/D" "-D" _PLATFORM_DEFINES_CUDA "${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_CXX}") @@ -76,6 +69,11 @@ else() endif() unset(_cmp0092) +set(CMAKE_CUDA_RUNTIME_LIBRARY_DEFAULT "STATIC") +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 "") + 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_RELEASE_INIT " -Xcompiler=\"${_MD}-O2 -Ob2\" -DNDEBUG") diff --git a/Modules/Platform/Windows-PGI.cmake b/Modules/Platform/Windows-PGI.cmake index ad77e8a..8166240 100644 --- a/Modules/Platform/Windows-PGI.cmake +++ b/Modules/Platform/Windows-PGI.cmake @@ -9,9 +9,10 @@ endif() set(__WINDOWS_COMPILER_PGI 1) # PGI on Windows doesn't support parallel compile processes -if(NOT DEFINED CMAKE_JOB_POOL_LINK OR NOT DEFINED CMAKE_JOB_POOL_COMPILE) +if(NOT DEFINED CMAKE_JOB_POOL_LINK OR NOT DEFINED CMAKE_JOB_POOL_COMPILE OR NOT DEFINED CMAKE_JOB_POOL_PRECOMPILE_HEADER) set(CMAKE_JOB_POOL_LINK PGITaskPool) set(CMAKE_JOB_POOL_COMPILE PGITaskPool) + set(CMAKE_JOB_POOL_PRECOMPILE_HEADER PGITaskPool) get_property(_pgijp GLOBAL PROPERTY JOB_POOLS) if(NOT _pgijp MATCHES "PGITaskPool=") set_property(GLOBAL APPEND PROPERTY JOB_POOLS PGITaskPool=1) diff --git a/Modules/Platform/WindowsPhone-Clang-ASM.cmake b/Modules/Platform/WindowsPhone-Clang-ASM.cmake new file mode 100644 index 0000000..94f4ca7 --- /dev/null +++ b/Modules/Platform/WindowsPhone-Clang-ASM.cmake @@ -0,0 +1 @@ +include(Platform/Windows-Clang-ASM) diff --git a/Modules/Platform/WindowsPhone-GNU-ASM.cmake b/Modules/Platform/WindowsPhone-GNU-ASM.cmake new file mode 100644 index 0000000..140eea7 --- /dev/null +++ b/Modules/Platform/WindowsPhone-GNU-ASM.cmake @@ -0,0 +1 @@ +include(Platform/Windows-GNU-ASM) diff --git a/Modules/Platform/WindowsStore-Clang-ASM.cmake b/Modules/Platform/WindowsStore-Clang-ASM.cmake new file mode 100644 index 0000000..94f4ca7 --- /dev/null +++ b/Modules/Platform/WindowsStore-Clang-ASM.cmake @@ -0,0 +1 @@ +include(Platform/Windows-Clang-ASM) diff --git a/Modules/Platform/WindowsStore-GNU-ASM.cmake b/Modules/Platform/WindowsStore-GNU-ASM.cmake new file mode 100644 index 0000000..140eea7 --- /dev/null +++ b/Modules/Platform/WindowsStore-GNU-ASM.cmake @@ -0,0 +1 @@ +include(Platform/Windows-GNU-ASM) diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake index 33cacf1..cb6ae43 100644 --- a/Modules/Qt4Macros.cmake +++ b/Modules/Qt4Macros.cmake @@ -436,7 +436,7 @@ macro(QT4_CREATE_TRANSLATION _qm_files) if(_my_sources) # make a .pro file to call lupdate on, so we don't make our commands too # long for some systems - get_filename_component(_ts_name ${_ts_file} NAME_WE) + get_filename_component(_ts_name ${_ts_file} NAME) set(_ts_pro ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_ts_name}_lupdate.pro) set(_pro_srcs) foreach(_pro_src ${_my_sources}) @@ -463,13 +463,15 @@ endmacro() macro(QT4_ADD_TRANSLATION _qm_files) foreach (_current_FILE ${ARGN}) get_filename_component(_abs_FILE ${_current_FILE} ABSOLUTE) - get_filename_component(qm ${_abs_FILE} NAME_WE) - get_property(output_location SOURCE ${_abs_FILE} PROPERTY OUTPUT_LOCATION) + get_filename_component(qm ${_abs_FILE} NAME) + # everything before the last dot has to be considered the file name (including other dots) + string(REGEX REPLACE "\\.[^.]*$" "" FILE_NAME ${qm}) + get_source_file_property(output_location ${_abs_FILE} OUTPUT_LOCATION) if(output_location) file(MAKE_DIRECTORY "${output_location}") - set(qm "${output_location}/${qm}.qm") + set(qm "${output_location}/${FILE_NAME}.qm") else() - set(qm "${CMAKE_CURRENT_BINARY_DIR}/${qm}.qm") + set(qm "${CMAKE_CURRENT_BINARY_DIR}/${FILE_NAME}.qm") endif() add_custom_command(OUTPUT ${qm} diff --git a/Modules/TestBigEndian.cmake b/Modules/TestBigEndian.cmake index 0c6e188..8a769b7 100644 --- a/Modules/TestBigEndian.cmake +++ b/Modules/TestBigEndian.cmake @@ -19,8 +19,8 @@ include(CheckTypeSize) macro(TEST_BIG_ENDIAN VARIABLE) if(NOT DEFINED HAVE_${VARIABLE}) - message(STATUS "Check if the system is big endian") - message(STATUS "Searching 16 bit integer") + message(CHECK_START "Check if the system is big endian") + message(CHECK_START "Searching 16 bit integer") if(CMAKE_C_COMPILER_LOADED) set(_test_language "C") @@ -32,19 +32,19 @@ macro(TEST_BIG_ENDIAN VARIABLE) CHECK_TYPE_SIZE("unsigned short" CMAKE_SIZEOF_UNSIGNED_SHORT LANGUAGE ${_test_language}) if(CMAKE_SIZEOF_UNSIGNED_SHORT EQUAL 2) - message(STATUS "Using unsigned short") + message(CHECK_PASS "Using unsigned short") set(CMAKE_16BIT_TYPE "unsigned short") else() CHECK_TYPE_SIZE("unsigned int" CMAKE_SIZEOF_UNSIGNED_INT LANGUAGE ${_test_language}) if(CMAKE_SIZEOF_UNSIGNED_INT) - message(STATUS "Using unsigned int") + message(CHECK_PASS "Using unsigned int") set(CMAKE_16BIT_TYPE "unsigned int") else() CHECK_TYPE_SIZE("unsigned long" CMAKE_SIZEOF_UNSIGNED_LONG LANGUAGE ${_test_language}) if(CMAKE_SIZEOF_UNSIGNED_LONG) - message(STATUS "Using unsigned long") + message(CHECK_PASS "Using unsigned long") set(CMAKE_16BIT_TYPE "unsigned long") else() message(FATAL_ERROR "no suitable type found") @@ -95,15 +95,16 @@ macro(TEST_BIG_ENDIAN VARIABLE) if(CMAKE_TEST_ENDIANESS_STRINGS_LE) set(${VARIABLE} 0 CACHE INTERNAL "Result of TEST_BIG_ENDIAN" FORCE) - message(STATUS "Check if the system is big endian - little endian") + message(CHECK_PASS "little endian") endif() if(CMAKE_TEST_ENDIANESS_STRINGS_BE) set(${VARIABLE} 1 CACHE INTERNAL "Result of TEST_BIG_ENDIAN" FORCE) - message(STATUS "Check if the system is big endian - big endian") + message(CHECK_PASS "big endian") endif() if(NOT CMAKE_TEST_ENDIANESS_STRINGS_BE AND NOT CMAKE_TEST_ENDIANESS_STRINGS_LE) + message(CHECK_FAIL "TEST_BIG_ENDIAN found no result!") message(SEND_ERROR "TEST_BIG_ENDIAN found no result!") endif() @@ -111,7 +112,7 @@ macro(TEST_BIG_ENDIAN VARIABLE) "Determining if the system is big endian passed with the following output:\n${OUTPUT}\nTestEndianess.c:\n${TEST_ENDIANESS_FILE_CONTENT}\n\n") else() - message(STATUS "Check if the system is big endian - failed") + 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") set(${VARIABLE}) diff --git a/Modules/TestCXXAcceptsFlag.cmake b/Modules/TestCXXAcceptsFlag.cmake index 92a362e..ce505f3 100644 --- a/Modules/TestCXXAcceptsFlag.cmake +++ b/Modules/TestCXXAcceptsFlag.cmake @@ -23,19 +23,19 @@ Check if the CXX compiler accepts a flag. macro(CHECK_CXX_ACCEPTS_FLAG FLAGS VARIABLE) if(NOT DEFINED ${VARIABLE}) - message(STATUS "Checking to see if CXX compiler accepts flag ${FLAGS}") + message(CHECK_START "Checking to see if CXX compiler accepts flag ${FLAGS}") try_compile(${VARIABLE} ${CMAKE_BINARY_DIR} ${CMAKE_ROOT}/Modules/DummyCXXFile.cxx CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${FLAGS} OUTPUT_VARIABLE OUTPUT) if(${VARIABLE}) - message(STATUS "Checking to see if CXX compiler accepts flag ${FLAGS} - yes") + message(CHECK_PASS "yes") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the CXX compiler accepts the flag ${FLAGS} passed with " "the following output:\n${OUTPUT}\n\n") else() - message(STATUS "Checking to see if CXX compiler accepts flag ${FLAGS} - no") + message(CHECK_FAIL "no") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the CXX compiler accepts the flag ${FLAGS} failed with " "the following output:\n${OUTPUT}\n\n") diff --git a/Modules/TestForANSIForScope.cmake b/Modules/TestForANSIForScope.cmake index 272e4ec..0f2dc01 100644 --- a/Modules/TestForANSIForScope.cmake +++ b/Modules/TestForANSIForScope.cmake @@ -16,19 +16,19 @@ for-init-statement to the loop body. #]=======================================================================] if(NOT DEFINED CMAKE_ANSI_FOR_SCOPE) - message(STATUS "Check for ANSI scope") + message(CHECK_START "Check for ANSI scope") try_compile(CMAKE_ANSI_FOR_SCOPE ${CMAKE_BINARY_DIR} ${CMAKE_ROOT}/Modules/TestForAnsiForScope.cxx OUTPUT_VARIABLE OUTPUT) if (CMAKE_ANSI_FOR_SCOPE) - message(STATUS "Check for ANSI scope - found") + message(CHECK_PASS "found") set (CMAKE_NO_ANSI_FOR_SCOPE 0 CACHE INTERNAL "Does the compiler support ansi for scope.") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the CXX compiler understands ansi for scopes passed with " "the following output:\n${OUTPUT}\n\n") else () - message(STATUS "Check for ANSI scope - not found") + message(CHECK_FAIL "not found") set (CMAKE_NO_ANSI_FOR_SCOPE 1 CACHE INTERNAL "Does the compiler support ansi for scope.") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log diff --git a/Modules/TestForSSTREAM.cmake b/Modules/TestForSSTREAM.cmake index e70df00..545b7ec 100644 --- a/Modules/TestForSSTREAM.cmake +++ b/Modules/TestForSSTREAM.cmake @@ -15,19 +15,19 @@ check if the compiler supports the standard ANSI sstream header #]=======================================================================] if(NOT DEFINED CMAKE_HAS_ANSI_STRING_STREAM) - message(STATUS "Check for sstream") + message(CHECK_START "Check for sstream") try_compile(CMAKE_HAS_ANSI_STRING_STREAM ${CMAKE_BINARY_DIR} ${CMAKE_ROOT}/Modules/TestForSSTREAM.cxx OUTPUT_VARIABLE OUTPUT) if (CMAKE_HAS_ANSI_STRING_STREAM) - message(STATUS "Check for sstream - found") + message(CHECK_PASS "found") set (CMAKE_NO_ANSI_STRING_STREAM 0 CACHE INTERNAL "Does the compiler support sstream") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the CXX compiler has sstream passed with " "the following output:\n${OUTPUT}\n\n") else () - message(STATUS "Check for sstream - not found") + message(CHECK_FAIL "not found") set (CMAKE_NO_ANSI_STRING_STREAM 1 CACHE INTERNAL "Does the compiler support sstream") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log diff --git a/Modules/TestForSTDNamespace.cmake b/Modules/TestForSTDNamespace.cmake index 703e631..d101c83 100644 --- a/Modules/TestForSTDNamespace.cmake +++ b/Modules/TestForSTDNamespace.cmake @@ -15,19 +15,19 @@ check if the compiler supports std:: on stl classes #]=======================================================================] if(NOT DEFINED CMAKE_STD_NAMESPACE) - message(STATUS "Check for STD namespace") + message(CHECK_START "Check for STD namespace") try_compile(CMAKE_STD_NAMESPACE ${CMAKE_BINARY_DIR} ${CMAKE_ROOT}/Modules/TestForSTDNamespace.cxx OUTPUT_VARIABLE OUTPUT) if (CMAKE_STD_NAMESPACE) - message(STATUS "Check for STD namespace - found") + message(CHECK_PASS "found") set (CMAKE_NO_STD_NAMESPACE 0 CACHE INTERNAL "Does the compiler support std::.") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the CXX compiler has std namespace passed with " "the following output:\n${OUTPUT}\n\n") else () - message(STATUS "Check for STD namespace - not found") + message(CHECK_FAIL "not found") set (CMAKE_NO_STD_NAMESPACE 1 CACHE INTERNAL "Does the compiler support std::.") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index 0798488..b668b9e 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -405,9 +405,14 @@ endfunction() # define helper scripts set(_JAVA_EXPORT_TARGETS_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/javaTargets.cmake.in) -set(_JAVA_CLASS_FILELIST_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/UseJavaClassFilelist.cmake) set(_JAVA_SYMLINK_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/UseJavaSymlinks.cmake) +if (CMAKE_HOST_WIN32 AND NOT CYGWIN AND CMAKE_HOST_SYSTEM_NAME MATCHES "Windows") + set(_UseJava_PATH_SEP "$<SEMICOLON>") +else () + set(_UseJava_PATH_SEP ":") +endif() + function(add_jar _TARGET_NAME) cmake_parse_arguments(_add_jar @@ -497,14 +502,8 @@ function(add_jar _TARGET_NAME) ${CMAKE_JAVA_LIBRARY_OUTPUT_PATH} ) - if (CMAKE_HOST_WIN32 AND NOT CYGWIN AND CMAKE_HOST_SYSTEM_NAME MATCHES "Windows") - set(CMAKE_JAVA_INCLUDE_FLAG_SEP ";") - else () - set(CMAKE_JAVA_INCLUDE_FLAG_SEP ":") - endif() - foreach (JAVA_INCLUDE_DIR IN LISTS CMAKE_JAVA_INCLUDE_PATH) - string(APPEND CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_FLAG_SEP}${JAVA_INCLUDE_DIR}") + string(APPEND CMAKE_JAVA_INCLUDE_PATH_FINAL "${_UseJava_PATH_SEP}${JAVA_INCLUDE_DIR}") endforeach() set(CMAKE_JAVA_CLASS_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_TARGET_NAME}.dir") @@ -576,7 +575,7 @@ function(add_jar _TARGET_NAME) if (TARGET ${_JAVA_INCLUDE_JAR}) get_target_property(_JAVA_JAR_PATH ${_JAVA_INCLUDE_JAR} JAR_FILE) if (_JAVA_JAR_PATH) - string(APPEND CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_FLAG_SEP}${_JAVA_JAR_PATH}") + string(APPEND CMAKE_JAVA_INCLUDE_PATH_FINAL "${_UseJava_PATH_SEP}${_JAVA_JAR_PATH}") list(APPEND CMAKE_JAVA_INCLUDE_PATH ${_JAVA_JAR_PATH}) list(APPEND _JAVA_DEPENDS ${_JAVA_INCLUDE_JAR}) list(APPEND _JAVA_COMPILE_DEPENDS ${_JAVA_JAR_PATH}) @@ -584,7 +583,7 @@ function(add_jar _TARGET_NAME) message(SEND_ERROR "add_jar: INCLUDE_JARS target ${_JAVA_INCLUDE_JAR} is not a jar") endif () else () - string(APPEND CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_FLAG_SEP}${_JAVA_INCLUDE_JAR}") + string(APPEND CMAKE_JAVA_INCLUDE_PATH_FINAL "${_UseJava_PATH_SEP}${_JAVA_INCLUDE_JAR}") list(APPEND CMAKE_JAVA_INCLUDE_PATH "${_JAVA_INCLUDE_JAR}") list(APPEND _JAVA_DEPENDS "${_JAVA_INCLUDE_JAR}") list(APPEND _JAVA_COMPILE_DEPENDS "${_JAVA_INCLUDE_JAR}") @@ -627,7 +626,7 @@ function(add_jar _TARGET_NAME) COMMAND ${CMAKE_COMMAND} -DCMAKE_JAVA_CLASS_OUTPUT_PATH=${CMAKE_JAVA_CLASS_OUTPUT_PATH} -DCMAKE_JAR_CLASSES_PREFIX="${CMAKE_JAR_CLASSES_PREFIX}" - -P ${_JAVA_CLASS_FILELIST_SCRIPT} + -P ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/UseJavaClassFilelist.cmake DEPENDS ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) @@ -1190,55 +1189,40 @@ function(create_javadoc _target) set(_javadoc_options -d ${_javadoc_builddir}) if (_javadoc_sourcepath) - set(_start TRUE) - foreach(_path IN LISTS _javadoc_sourcepath) - if (_start) - set(_sourcepath ${_path}) - set(_start FALSE) - else () - set(_sourcepath ${_sourcepath}:${_path}) - endif () - endforeach() - set(_javadoc_options ${_javadoc_options} -sourcepath ${_sourcepath}) + list(JOIN _javadoc_sourcepath "${_UseJava_PATH_SEP}" _javadoc_sourcepath) + list(APPEND _javadoc_options -sourcepath "\"${_javadoc_sourcepath}\"") endif () if (_javadoc_classpath) - set(_start TRUE) - foreach(_path IN LISTS _javadoc_classpath) - if (_start) - set(_classpath ${_path}) - set(_start FALSE) - else () - set(_classpath ${_classpath}:${_path}) - endif () - endforeach() - set(_javadoc_options ${_javadoc_options} -classpath "${_classpath}") + list(JOIN _javadoc_classpath "${_UseJava_PATH_SEP}" _javadoc_classpath) + list(APPEND _javadoc_options -classpath "\"${_javadoc_classpath}\"") endif () if (_javadoc_doctitle) - set(_javadoc_options ${_javadoc_options} -doctitle '${_javadoc_doctitle}') + list(APPEND _javadoc_options -doctitle '${_javadoc_doctitle}') endif () if (_javadoc_windowtitle) - set(_javadoc_options ${_javadoc_options} -windowtitle '${_javadoc_windowtitle}') + list(APPEND _javadoc_options -windowtitle '${_javadoc_windowtitle}') endif () if (_javadoc_author) - set(_javadoc_options ${_javadoc_options} -author) + list(APPEND _javadoc_options -author) endif () if (_javadoc_use) - set(_javadoc_options ${_javadoc_options} -use) + list(APPEND _javadoc_options -use) endif () if (_javadoc_version) - set(_javadoc_options ${_javadoc_options} -version) + list(APPEND _javadoc_options -version) endif () add_custom_target(${_target}_javadoc ALL - COMMAND ${Java_JAVADOC_EXECUTABLE} ${_javadoc_options} - ${_javadoc_files} - ${_javadoc_packages} + COMMAND ${Java_JAVADOC_EXECUTABLE} + ${_javadoc_options} + ${_javadoc_files} + ${_javadoc_packages} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) @@ -1274,11 +1258,6 @@ function (create_javah) endif() set (_output_files) - if (WIN32 AND NOT CYGWIN AND CMAKE_HOST_SYSTEM_NAME MATCHES "Windows") - set(_classpath_sep "$<SEMICOLON>") - else () - set(_classpath_sep ":") - endif() # handle javah options set (_javah_options) @@ -1304,7 +1283,7 @@ function (create_javah) message(SEND_ERROR "create_javah: CLASSPATH entry ${_path} does not exist.") endif() endforeach() - string (REPLACE ";" "${_classpath_sep}" _classpath "${_classpath}") + string (REPLACE ";" "${_UseJava_PATH_SEP}" _classpath "${_classpath}") list (APPEND _javah_options -classpath "${_classpath}") endif() |