diff options
Diffstat (limited to 'Modules')
82 files changed, 1281 insertions, 417 deletions
diff --git a/Modules/AutogenInfo.cmake.in b/Modules/AutogenInfo.cmake.in index 3fafaff..5e945bc 100644 --- a/Modules/AutogenInfo.cmake.in +++ b/Modules/AutogenInfo.cmake.in @@ -1,25 +1,34 @@ -set(AM_SOURCES @_moc_uic_sources@) -set(AM_HEADERS @_moc_uic_headers@) -set(AM_SKIP_MOC @_skip_moc@) -set(AM_SKIP_UIC @_skip_uic@) -set(AM_MOC_COMPILE_DEFINITIONS @_moc_compile_defs@) -set(AM_MOC_INCLUDES @_moc_incs@) -set(AM_MOC_OPTIONS @_moc_options@) -set(AM_MOC_RELAXED_MODE "@_moc_relaxed_mode@") -set(AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE "@CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE@") +# Target names +set(AM_TARGET_NAME @_autogen_target_name@) +set(AM_ORIGIN_TARGET_NAME @_origin_target_name@) +# Directories and files set(AM_CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@/") set(AM_CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@/") -set(AM_QT_MOC_EXECUTABLE "@_qt_moc_executable@") -set(AM_QT_UIC_EXECUTABLE "@_qt_uic_executable@") -set(AM_QT_RCC_EXECUTABLE "@_qt_rcc_executable@") set(AM_CMAKE_CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@/") set(AM_CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@/") -set(AM_QT_VERSION_MAJOR "@_target_qt_version@") -set(AM_TARGET_NAME @_moc_target_name@) -set(AM_ORIGIN_TARGET_NAME @_origin_target_name@) +set(AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE "@CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE@") +set(AM_SOURCES @_sources@) +set(AM_HEADERS @_headers@) +# Qt environment +set(AM_QT_VERSION_MAJOR @_qt_version_major@) +set(AM_QT_MOC_EXECUTABLE @_qt_moc_executable@) +set(AM_QT_UIC_EXECUTABLE @_qt_uic_executable@) +set(AM_QT_RCC_EXECUTABLE @_qt_rcc_executable@) +# MOC settings +set(AM_MOC_SKIP @_moc_skip@) +set(AM_MOC_DEFINITIONS @_moc_compile_defs@) +set(AM_MOC_INCLUDES @_moc_incs@) +set(AM_MOC_OPTIONS @_moc_options@) +set(AM_MOC_RELAXED_MODE @_moc_relaxed_mode@) +set(AM_MOC_DEPEND_FILTERS @_moc_depend_filters@) +set(AM_MOC_PREDEFS_CMD @_moc_predefs_cmd@) +# UIC settings +set(AM_UIC_SKIP @_uic_skip@) set(AM_UIC_TARGET_OPTIONS @_uic_target_options@) set(AM_UIC_OPTIONS_FILES @_qt_uic_options_files@) set(AM_UIC_OPTIONS_OPTIONS @_qt_uic_options_options@) +set(AM_UIC_SEARCH_PATHS @_uic_search_paths@) +# RCC settings set(AM_RCC_SOURCES @_rcc_files@ ) set(AM_RCC_INPUTS @_rcc_inputs@) set(AM_RCC_OPTIONS_FILES @_rcc_options_files@) diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake index 5d6f402..121a8f0 100644 --- a/Modules/BundleUtilities.cmake +++ b/Modules/BundleUtilities.cmake @@ -432,6 +432,16 @@ function(get_item_rpaths item rpaths_var) endif() endif() + if(UNIX AND NOT APPLE) + file(READ_ELF ${item} RPATH rpath_var RUNPATH runpath_var CAPTURE_ERROR error_var) + get_filename_component(item_dir ${item} DIRECTORY) + foreach(rpath ${rpath_var} ${runpath_var}) + # Substitute $ORIGIN with the exepath and add to the found rpaths + string(REPLACE "$ORIGIN" "${item_dir}" rpath "${rpath}") + gp_append_unique(${rpaths_var} "${rpath}") + endforeach() + endif() + set(${rpaths_var} ${${rpaths_var}} PARENT_SCOPE) endfunction() @@ -998,7 +1008,8 @@ function(verify_bundle_prerequisites bundle result_var info_var) endif() if(NOT ignoreFile) - get_prerequisites("${f}" prereqs 1 1 "${exepath}" "") + get_item_rpaths(${f} _main_exe_rpaths) + get_prerequisites("${f}" prereqs 1 1 "${exepath}" "${_main_exe_rpaths}") # On the Mac, # "embedded" and "system" prerequisites are fine... anything else means diff --git a/Modules/CMakeASMCompiler.cmake.in b/Modules/CMakeASMCompiler.cmake.in index 8e58307..7b94d0f 100644 --- a/Modules/CMakeASMCompiler.cmake.in +++ b/Modules/CMakeASMCompiler.cmake.in @@ -1,7 +1,9 @@ set(CMAKE_ASM@ASM_DIALECT@_COMPILER "@_CMAKE_ASM_COMPILER@") set(CMAKE_ASM@ASM_DIALECT@_COMPILER_ARG1 "@_CMAKE_ASM_COMPILER_ARG1@") set(CMAKE_AR "@CMAKE_AR@") +set(CMAKE_ASM@ASM_DIALECT@_COMPILER_AR "@_CMAKE_ASM_COMPILER_AR@") set(CMAKE_RANLIB "@CMAKE_RANLIB@") +set(CMAKE_ASM@ASM_DIALECT@_COMPILER_RANLIB "@_CMAKE_ASM_COMPILER_RANLIB@") set(CMAKE_LINKER "@CMAKE_LINKER@") set(CMAKE_ASM@ASM_DIALECT@_COMPILER_LOADED 1) set(CMAKE_ASM@ASM_DIALECT@_COMPILER_ID "@_CMAKE_ASM_COMPILER_ID@") diff --git a/Modules/CMakeASMInformation.cmake b/Modules/CMakeASMInformation.cmake index 01355ff..f7cf900 100644 --- a/Modules/CMakeASMInformation.cmake +++ b/Modules/CMakeASMInformation.cmake @@ -75,11 +75,13 @@ set (CMAKE_ASM${ASM_DIALECT}_FLAGS "${CMAKE_ASM${ASM_DIALECT}_FLAGS_INIT}" CACHE "Flags used by the assembler during all build types.") if(NOT CMAKE_NOT_USING_CONFIG_FLAGS) -# default build type is none - if(NOT CMAKE_NO_BUILD_TYPE) + get_property(_GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + # default build type is none + if(NOT _GENERATOR_IS_MULTI_CONFIG AND NOT CMAKE_NO_BUILD_TYPE) set (CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE_INIT} CACHE STRING "Choose the type of build, options are: None, Debug Release RelWithDebInfo MinSizeRel.") endif() + unset(_GENERATOR_IS_MULTI_CONFIG) set (CMAKE_ASM${ASM_DIALECT}_FLAGS_DEBUG "${CMAKE_ASM${ASM_DIALECT}_FLAGS_DEBUG_INIT}" CACHE STRING "Flags used by the assembler during debug builds.") set (CMAKE_ASM${ASM_DIALECT}_FLAGS_MINSIZEREL "${CMAKE_ASM${ASM_DIALECT}_FLAGS_MINSIZEREL_INIT}" CACHE STRING diff --git a/Modules/CMakeBackwardCompatibilityC.cmake b/Modules/CMakeBackwardCompatibilityC.cmake index 228e063..5d86d73 100644 --- a/Modules/CMakeBackwardCompatibilityC.cmake +++ b/Modules/CMakeBackwardCompatibilityC.cmake @@ -2,12 +2,6 @@ # file Copyright.txt or https://cmake.org/licensing for details. -# Nothing here yet -if(CMAKE_GENERATOR MATCHES "Visual Studio 7") - include(CMakeVS7BackwardCompatibility) - set(CMAKE_SKIP_COMPATIBILITY_TESTS 1) -endif() - if(NOT CMAKE_SKIP_COMPATIBILITY_TESTS) # Old CMake versions did not support OS X universal binaries anyway, # so just get through this with at least some size for the types. diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in index 50b12f2..974a579 100644 --- a/Modules/CMakeCCompiler.cmake.in +++ b/Modules/CMakeCCompiler.cmake.in @@ -13,8 +13,11 @@ set(CMAKE_C_PLATFORM_ID "@CMAKE_C_PLATFORM_ID@") set(CMAKE_C_SIMULATE_ID "@CMAKE_C_SIMULATE_ID@") set(CMAKE_C_SIMULATE_VERSION "@CMAKE_C_SIMULATE_VERSION@") @SET_MSVC_C_ARCHITECTURE_ID@ +@SET_CMAKE_XCODE_CURRENT_ARCH@ set(CMAKE_AR "@CMAKE_AR@") +set(CMAKE_C_COMPILER_AR "@CMAKE_C_COMPILER_AR@") set(CMAKE_RANLIB "@CMAKE_RANLIB@") +set(CMAKE_C_COMPILER_RANLIB "@CMAKE_C_COMPILER_RANLIB@") set(CMAKE_LINKER "@CMAKE_LINKER@") set(CMAKE_COMPILER_IS_GNUCC @CMAKE_COMPILER_IS_GNUCC@) set(CMAKE_C_COMPILER_LOADED 1) diff --git a/Modules/CMakeCInformation.cmake b/Modules/CMakeCInformation.cmake index 709e316..71aadb4 100644 --- a/Modules/CMakeCInformation.cmake +++ b/Modules/CMakeCInformation.cmake @@ -110,11 +110,13 @@ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS_INIT}" CACHE STRING "Flags used by the compiler during all build types.") if(NOT CMAKE_NOT_USING_CONFIG_FLAGS) -# default build type is none - if(NOT CMAKE_NO_BUILD_TYPE) + get_property(_GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + # default build type is none + if(NOT _GENERATOR_IS_MULTI_CONFIG AND NOT CMAKE_NO_BUILD_TYPE) set (CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE_INIT} CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") endif() + unset(_GENERATOR_IS_MULTI_CONFIG) set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG_INIT}" CACHE STRING "Flags used by the compiler during debug builds.") set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL_INIT}" CACHE STRING diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index 6d56488..fda7950 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -14,8 +14,11 @@ set(CMAKE_CXX_PLATFORM_ID "@CMAKE_CXX_PLATFORM_ID@") set(CMAKE_CXX_SIMULATE_ID "@CMAKE_CXX_SIMULATE_ID@") set(CMAKE_CXX_SIMULATE_VERSION "@CMAKE_CXX_SIMULATE_VERSION@") @SET_MSVC_CXX_ARCHITECTURE_ID@ +@SET_CMAKE_XCODE_CURRENT_ARCH@ set(CMAKE_AR "@CMAKE_AR@") +set(CMAKE_CXX_COMPILER_AR "@CMAKE_CXX_COMPILER_AR@") set(CMAKE_RANLIB "@CMAKE_RANLIB@") +set(CMAKE_CXX_COMPILER_RANLIB "@CMAKE_CXX_COMPILER_RANLIB@") set(CMAKE_LINKER "@CMAKE_LINKER@") set(CMAKE_COMPILER_IS_GNUCXX @CMAKE_COMPILER_IS_GNUCXX@) set(CMAKE_CXX_COMPILER_LOADED 1) diff --git a/Modules/CMakeCommonLanguageInclude.cmake b/Modules/CMakeCommonLanguageInclude.cmake index 418860e..43b5da0 100644 --- a/Modules/CMakeCommonLanguageInclude.cmake +++ b/Modules/CMakeCommonLanguageInclude.cmake @@ -17,11 +17,13 @@ foreach(t EXE SHARED MODULE STATIC) endforeach() if(NOT CMAKE_NOT_USING_CONFIG_FLAGS) -# default build type is none - if(NOT CMAKE_NO_BUILD_TYPE) + get_property(_GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + # default build type is none + if(NOT _GENERATOR_IS_MULTI_CONFIG AND NOT CMAKE_NO_BUILD_TYPE) set (CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE_INIT} CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") endif() + unset(_GENERATOR_IS_MULTI_CONFIG) set (CMAKE_EXE_LINKER_FLAGS_DEBUG ${CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT} CACHE STRING "Flags used by the linker during debug builds.") diff --git a/Modules/CMakeCompilerABI.h b/Modules/CMakeCompilerABI.h index f2714b4..ad481d6 100644 --- a/Modules/CMakeCompilerABI.h +++ b/Modules/CMakeCompilerABI.h @@ -25,6 +25,10 @@ const char info_sizeof_dptr[] = { #elif defined(__GNU__) && defined(__ELF__) && defined(__ARMEL__) #define ABI_ID "ELF ARM" +#elif defined(__linux__) && defined(__ELF__) && defined(__amd64__) && \ + defined(__ILP32__) +#define ABI_ID "ELF X32" + #elif defined(__ELF__) #define ABI_ID "ELF" #endif diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake index 4162726..87c6b28 100644 --- a/Modules/CMakeDetermineASMCompiler.cmake +++ b/Modules/CMakeDetermineASMCompiler.cmake @@ -92,9 +92,17 @@ if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_ARMCC ) set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_ARMCC "(ARM Compiler)|(ARM Assembler)") - include(CMakeDetermineCompilerId) - CMAKE_DETERMINE_COMPILER_ID_VENDOR(ASM${ASM_DIALECT}) + list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS NASM) + set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_NASM "-v") + set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_NASM "(NASM version)") + + list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS YASM) + set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_YASM "--version") + set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_YASM "(yasm)") + include(CMakeDetermineCompilerId) + set(userflags) + CMAKE_DETERMINE_COMPILER_ID_VENDOR(ASM${ASM_DIALECT} "${userflags}") endif() if(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) @@ -149,6 +157,8 @@ set(_CMAKE_ASM_COMPILER "${CMAKE_ASM${ASM_DIALECT}_COMPILER}") set(_CMAKE_ASM_COMPILER_ID "${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}") set(_CMAKE_ASM_COMPILER_ARG1 "${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARG1}") set(_CMAKE_ASM_COMPILER_ENV_VAR "${CMAKE_ASM${ASM_DIALECT}_COMPILER_ENV_VAR}") +set(_CMAKE_ASM_COMPILER_AR "${CMAKE_ASM${ASM_DIALECT}_COMPILER_AR}") +set(_CMAKE_ASM_COMPILER_RANLIB "${CMAKE_ASM${ASM_DIALECT}_COMPILER_RANLIB}") # configure variables set in this file for fast reload later on configure_file(${CMAKE_ROOT}/Modules/CMakeASMCompiler.cmake.in @@ -157,3 +167,5 @@ configure_file(${CMAKE_ROOT}/Modules/CMakeASMCompiler.cmake.in set(_CMAKE_ASM_COMPILER) set(_CMAKE_ASM_COMPILER_ARG1) set(_CMAKE_ASM_COMPILER_ENV_VAR) +set(_CMAKE_ASM_COMPILER_AR) +set(_CMAKE_ASM_COMPILER_RANLIB) diff --git a/Modules/CMakeDetermineASM_NASMCompiler.cmake b/Modules/CMakeDetermineASM_NASMCompiler.cmake index 4c8e422..dd75310 100644 --- a/Modules/CMakeDetermineASM_NASMCompiler.cmake +++ b/Modules/CMakeDetermineASM_NASMCompiler.cmake @@ -7,8 +7,21 @@ set(CMAKE_ASM_NASM_COMPILER_LIST nasm yasm) if(NOT CMAKE_ASM_NASM_COMPILER) - find_program(CMAKE_ASM_NASM_COMPILER nasm - "$ENV{ProgramFiles}/NASM") + set(_CMAKE_ENV_VARX86 "ProgramFiles(x86)") + set(_CMAKE_ASM_NASM_COMPILER_PATHS + "[HKEY_CURRENT_USER\\SOFTWARE\\nasm]" + "$ENV{ProgramFiles}/NASM" + "$ENV{${ENV_VARX86}}/NASM" + "$ENV{LOCALAPPDATA}/NASM" + ) + find_program(CMAKE_ASM_NASM_COMPILER + NAMES ${CMAKE_ASM_NASM_COMPILER_LIST} + PATHS ${_CMAKE_ASM_NASM_COMPILER_PATHS} + NO_DEFAULT_PATH + DOC "NASM compiler" + ) + unset(_CMAKE_ENV_VARX86) + unset(_CMAKE_ASM_NASM_COMPILER_PATHS) endif() # Load the generic DetermineASM compiler file with the DIALECT set properly: diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 4a315e0..3caccde 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -166,11 +166,20 @@ if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX) endif () include(CMakeFindBinUtils) +set(_CMAKE_PROCESSING_LANGUAGE "C") +include(Compiler/${CMAKE_C_COMPILER_ID}-FindBinUtils OPTIONAL) +unset(_CMAKE_PROCESSING_LANGUAGE) + if(MSVC_C_ARCHITECTURE_ID) set(SET_MSVC_C_ARCHITECTURE_ID "set(MSVC_C_ARCHITECTURE_ID ${MSVC_C_ARCHITECTURE_ID})") endif() +if(CMAKE_C_XCODE_CURRENT_ARCH) + set(SET_CMAKE_XCODE_CURRENT_ARCH + "set(CMAKE_XCODE_CURRENT_ARCH ${CMAKE_C_XCODE_CURRENT_ARCH})") +endif() + # configure variables set in this file for fast reload later on configure_file(${CMAKE_ROOT}/Modules/CMakeCCompiler.cmake.in ${CMAKE_PLATFORM_INFO_DIR}/CMakeCCompiler.cmake diff --git a/Modules/CMakeDetermineCSharpCompiler.cmake b/Modules/CMakeDetermineCSharpCompiler.cmake index 1b8dd02..55b2fb3 100644 --- a/Modules/CMakeDetermineCSharpCompiler.cmake +++ b/Modules/CMakeDetermineCSharpCompiler.cmake @@ -1,7 +1,7 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -if(NOT ${CMAKE_GENERATOR} MATCHES "Visual Studio ([^789]|[789][0-9])") +if(NOT ${CMAKE_GENERATOR} MATCHES "Visual Studio ([^89]|[89][0-9])") message(FATAL_ERROR "C# is currently only supported for Microsoft Visual Studio 2010 and later.") endif() diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake index 7b6d17b..89ac9fa 100644 --- a/Modules/CMakeDetermineCUDACompiler.cmake +++ b/Modules/CMakeDetermineCUDACompiler.cmake @@ -5,36 +5,40 @@ include(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake) include(${CMAKE_ROOT}/Modules//CMakeParseImplicitLinkInfo.cmake) if( NOT ( ("${CMAKE_GENERATOR}" MATCHES "Make") OR - ("${CMAKE_GENERATOR}" MATCHES "Ninja") ) ) + ("${CMAKE_GENERATOR}" MATCHES "Ninja") OR + ("${CMAKE_GENERATOR}" MATCHES "Visual Studio (1|[89][0-9])") ) ) message(FATAL_ERROR "CUDA language not currently supported by \"${CMAKE_GENERATOR}\" generator") endif() -if(NOT CMAKE_CUDA_COMPILER) - set(CMAKE_CUDA_COMPILER_INIT NOTFOUND) - - # prefer the environment variable CUDACXX - if(NOT $ENV{CUDACXX} STREQUAL "") - get_filename_component(CMAKE_CUDA_COMPILER_INIT $ENV{CUDACXX} PROGRAM PROGRAM_ARGS CMAKE_CUDA_FLAGS_ENV_INIT) - if(CMAKE_CUDA_FLAGS_ENV_INIT) - set(CMAKE_CUDA_COMPILER_ARG1 "${CMAKE_CUDA_FLAGS_ENV_INIT}" CACHE STRING "First argument to CXX compiler") - endif() - if(NOT EXISTS ${CMAKE_CUDA_COMPILER_INIT}) - message(FATAL_ERROR "Could not find compiler set in environment variable CUDACXX:\n$ENV{CUDACXX}.\n${CMAKE_CUDA_COMPILER_INIT}") +if(${CMAKE_GENERATOR} MATCHES "Visual Studio") +else() + if(NOT CMAKE_CUDA_COMPILER) + set(CMAKE_CUDA_COMPILER_INIT NOTFOUND) + + # prefer the environment variable CUDACXX + if(NOT $ENV{CUDACXX} STREQUAL "") + get_filename_component(CMAKE_CUDA_COMPILER_INIT $ENV{CUDACXX} PROGRAM PROGRAM_ARGS CMAKE_CUDA_FLAGS_ENV_INIT) + if(CMAKE_CUDA_FLAGS_ENV_INIT) + set(CMAKE_CUDA_COMPILER_ARG1 "${CMAKE_CUDA_FLAGS_ENV_INIT}" CACHE STRING "First argument to CXX compiler") + endif() + if(NOT EXISTS ${CMAKE_CUDA_COMPILER_INIT}) + message(FATAL_ERROR "Could not find compiler set in environment variable CUDACXX:\n$ENV{CUDACXX}.\n${CMAKE_CUDA_COMPILER_INIT}") + endif() endif() + + # finally list compilers to try + if(NOT CMAKE_CUDA_COMPILER_INIT) + set(CMAKE_CUDA_COMPILER_LIST nvcc) endif() - # finally list compilers to try - if(NOT CMAKE_CUDA_COMPILER_INIT) - set(CMAKE_CUDA_COMPILER_LIST nvcc) + _cmake_find_compiler(CUDA) + else() + _cmake_find_compiler_path(CUDA) endif() - _cmake_find_compiler(CUDA) -else() - _cmake_find_compiler_path(CUDA) + mark_as_advanced(CMAKE_CUDA_COMPILER) endif() -mark_as_advanced(CMAKE_CUDA_COMPILER) - #Allow the user to specify a host compiler set(CMAKE_CUDA_HOST_COMPILER "" CACHE FILEPATH "Host compiler to be used by nvcc") if(NOT $ENV{CUDAHOSTCXX} STREQUAL "") @@ -75,14 +79,12 @@ if(MSVC_CUDA_ARCHITECTURE_ID) "set(MSVC_CUDA_ARCHITECTURE_ID ${MSVC_CUDA_ARCHITECTURE_ID})") endif() -#if this compiler vendor is matches NVIDIA we can determine -#what the host compiler is. This only needs to be done if the CMAKE_CUDA_HOST_COMPILER -#has NOT been explicitly set -# -#Find the line from compiler ID that contains a.out ( or last line ) -#We also need to find the implicit link lines. Which can be done by replacing -#the compiler with cuda-fake-ld and pass too CMAKE_PARSE_IMPLICIT_LINK_INFO -if(CMAKE_CUDA_COMPILER_ID STREQUAL NVIDIA) +if(${CMAKE_GENERATOR} MATCHES "Visual Studio") + set(CMAKE_CUDA_HOST_LINK_LAUNCHER "${CMAKE_LINKER}") + set(CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES "") + set(CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES "") + set(CMAKE_CUDA_HOST_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "") +elseif(CMAKE_CUDA_COMPILER_ID STREQUAL NVIDIA) set(_nvcc_log "") string(REPLACE "\r" "" _nvcc_output_orig "${CMAKE_CUDA_COMPILER_PRODUCED_OUTPUT}") if(_nvcc_output_orig MATCHES "#\\\$ +LIBRARIES= *([^\n]*)\n") diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index f2e0bb2..9150962 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -161,11 +161,20 @@ if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX) endif () include(CMakeFindBinUtils) +set(_CMAKE_PROCESSING_LANGUAGE "CXX") +include(Compiler/${CMAKE_CXX_COMPILER_ID}-FindBinUtils OPTIONAL) +unset(_CMAKE_PROCESSING_LANGUAGE) + if(MSVC_CXX_ARCHITECTURE_ID) set(SET_MSVC_CXX_ARCHITECTURE_ID "set(MSVC_CXX_ARCHITECTURE_ID ${MSVC_CXX_ARCHITECTURE_ID})") endif() +if(CMAKE_CXX_XCODE_CURRENT_ARCH) + set(SET_CMAKE_XCODE_CURRENT_ARCH + "set(CMAKE_XCODE_CURRENT_ARCH ${CMAKE_CXX_XCODE_CURRENT_ARCH})") +endif() + # configure all variables set in this file configure_file(${CMAKE_ROOT}/Modules/CMakeCXXCompiler.cmake.in ${CMAKE_PLATFORM_INFO_DIR}/CMakeCXXCompiler.cmake diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index c41a986..687263a 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -24,16 +24,21 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) # Try building with no extra flags and then try each set # of helper flags. Stop when the compiler is identified. - foreach(flags ${CMAKE_${lang}_COMPILER_ID_TEST_FLAGS_FIRST} - "" - ${CMAKE_${lang}_COMPILER_ID_TEST_FLAGS}) - CMAKE_DETERMINE_COMPILER_ID_BUILD("${lang}" "${flags}" "${src}") - CMAKE_DETERMINE_COMPILER_ID_MATCH_VENDOR("${lang}" "${COMPILER_${lang}_PRODUCED_OUTPUT}") - if(CMAKE_${lang}_COMPILER_ID) - break() - endif() - foreach(file ${COMPILER_${lang}_PRODUCED_FILES}) - CMAKE_DETERMINE_COMPILER_ID_CHECK("${lang}" "${CMAKE_${lang}_COMPILER_ID_DIR}/${file}" "${src}") + foreach(userflags "${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST}" "") + foreach(testflags ${CMAKE_${lang}_COMPILER_ID_TEST_FLAGS_FIRST} + "" + ${CMAKE_${lang}_COMPILER_ID_TEST_FLAGS}) + CMAKE_DETERMINE_COMPILER_ID_BUILD("${lang}" "${testflags}" "${userflags}" "${src}") + CMAKE_DETERMINE_COMPILER_ID_MATCH_VENDOR("${lang}" "${COMPILER_${lang}_PRODUCED_OUTPUT}") + if(CMAKE_${lang}_COMPILER_ID) + break() + endif() + foreach(file ${COMPILER_${lang}_PRODUCED_FILES}) + CMAKE_DETERMINE_COMPILER_ID_CHECK("${lang}" "${CMAKE_${lang}_COMPILER_ID_DIR}/${file}" "${src}") + endforeach() + if(CMAKE_${lang}_COMPILER_ID) + break() + endif() endforeach() if(CMAKE_${lang}_COMPILER_ID) break() @@ -42,7 +47,9 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) # If the compiler is still unknown, try to query its vendor. if(CMAKE_${lang}_COMPILER AND NOT CMAKE_${lang}_COMPILER_ID) - CMAKE_DETERMINE_COMPILER_ID_VENDOR(${lang}) + foreach(userflags "${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST}" "") + CMAKE_DETERMINE_COMPILER_ID_VENDOR(${lang} "${userflags}") + endforeach() endif() if (COMPILER_QNXNTO AND CMAKE_${lang}_COMPILER_ID STREQUAL "GNU") @@ -66,7 +73,9 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) endif() if(CMAKE_GENERATOR STREQUAL "Ninja" AND MSVC_${lang}_ARCHITECTURE_ID) - CMAKE_DETERMINE_MSVC_SHOWINCLUDES_PREFIX(${lang}) + foreach(userflags "${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST}" "") + CMAKE_DETERMINE_MSVC_SHOWINCLUDES_PREFIX(${lang} "${userflags}") + endforeach() else() set(CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX "") endif() @@ -95,6 +104,7 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) set(CMAKE_${lang}_PLATFORM_ID "${CMAKE_${lang}_PLATFORM_ID}" PARENT_SCOPE) set(MSVC_${lang}_ARCHITECTURE_ID "${MSVC_${lang}_ARCHITECTURE_ID}" PARENT_SCOPE) + set(CMAKE_${lang}_XCODE_CURRENT_ARCH "${CMAKE_${lang}_XCODE_CURRENT_ARCH}" PARENT_SCOPE) set(CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX "${CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX}" PARENT_SCOPE) set(CMAKE_${lang}_COMPILER_VERSION "${CMAKE_${lang}_COMPILER_VERSION}" PARENT_SCOPE) set(CMAKE_${lang}_COMPILER_WRAPPER "${CMAKE_${lang}_COMPILER_WRAPPER}" PARENT_SCOPE) @@ -127,7 +137,7 @@ endfunction() #----------------------------------------------------------------------------- # Function to build the compiler id source file and look for output # files. -function(CMAKE_DETERMINE_COMPILER_ID_BUILD lang testflags src) +function(CMAKE_DETERMINE_COMPILER_ID_BUILD lang testflags userflags src) # Create a clean working directory. file(REMOVE_RECURSE ${CMAKE_${lang}_COMPILER_ID_DIR}) file(MAKE_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR}) @@ -137,7 +147,7 @@ function(CMAKE_DETERMINE_COMPILER_ID_BUILD lang testflags src) # Construct a description of this test case. set(COMPILER_DESCRIPTION "Compiler: ${CMAKE_${lang}_COMPILER} ${CMAKE_${lang}_COMPILER_ID_ARG1} -Build flags: ${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST} +Build flags: ${userflags} Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} ") @@ -226,6 +236,26 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} endif() set(id_dir ${CMAKE_${lang}_COMPILER_ID_DIR}) set(id_src "${src}") + set(id_compile "ClCompile") + set(id_PostBuildEvent_Command "for %%i in (${id_cl}) do %40echo CMAKE_${lang}_COMPILER=%%~$PATH:i") + set(id_Import_props "") + set(id_Import_targets "") + set(id_ItemDefinitionGroup_entry "") + set(id_Link_AdditionalDependencies "") + if(lang STREQUAL CUDA) + if(NOT CMAKE_VS_PLATFORM_TOOLSET_CUDA) + message(FATAL_ERROR "No CUDA toolset found.") + endif() + set(cuda_tools "CUDA ${CMAKE_VS_PLATFORM_TOOLSET_CUDA}") + set(id_compile "CudaCompile") + set(id_PostBuildEvent_Command [[echo CMAKE_CUDA_COMPILER=$(CudaToolkitBinDir)\nvcc.exe]]) + string(CONCAT id_Import_props [[<Import Project="$(VCTargetsPath)\BuildCustomizations\]] "${cuda_tools}" [[.props" />]]) + string(CONCAT id_Import_targets [[<Import Project="$(VCTargetsPath)\BuildCustomizations\]] "${cuda_tools}" [[.targets" />]]) + if(CMAKE_VS_PLATFORM_NAME STREQUAL x64) + set(id_ItemDefinitionGroup_entry "<CudaCompile><TargetMachinePlatform>64</TargetMachinePlatform></CudaCompile>") + endif() + set(id_Link_AdditionalDependencies "<AdditionalDependencies>cudart.lib</AdditionalDependencies>") + endif() configure_file(${CMAKE_ROOT}/Modules/CompilerId/VS-${v}.${ext}.in ${id_dir}/CompilerId${lang}.${ext} @ONLY) if(CMAKE_VS_MSBUILD_COMMAND AND NOT lang STREQUAL "Fortran") @@ -329,11 +359,14 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} endif() endif() endif() + if("${CMAKE_${lang}_COMPILER_ID_OUTPUT}" MATCHES "CURRENT_ARCH=([^%\r\n]+)[\r\n]") + set(CMAKE_${lang}_XCODE_CURRENT_ARCH "${CMAKE_MATCH_1}" PARENT_SCOPE) + endif() else() execute_process( COMMAND "${CMAKE_${lang}_COMPILER}" ${CMAKE_${lang}_COMPILER_ID_ARG1} - ${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST} + ${userflags} ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} "${src}" @@ -621,7 +654,7 @@ endfunction() # set(CMAKE_${lang}_COMPILER_ID_VENDOR_REGEX_${vendor} "Some Vendor Output") # We try running the compiler with the flag for each vendor and # matching its regular expression in the output. -function(CMAKE_DETERMINE_COMPILER_ID_VENDOR lang) +function(CMAKE_DETERMINE_COMPILER_ID_VENDOR lang userflags) if(NOT CMAKE_${lang}_COMPILER_ID_DIR) # We get here when this function is called not from within CMAKE_DETERMINE_COMPILER_ID() @@ -639,7 +672,7 @@ function(CMAKE_DETERMINE_COMPILER_ID_VENDOR lang) execute_process( COMMAND "${CMAKE_${lang}_COMPILER}" ${CMAKE_${lang}_COMPILER_ID_ARG1} - ${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST} + ${userflags} ${flags} WORKING_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR} OUTPUT_VARIABLE output ERROR_VARIABLE output @@ -667,7 +700,7 @@ function(CMAKE_DETERMINE_COMPILER_ID_VENDOR lang) endforeach() endfunction() -function(CMAKE_DETERMINE_MSVC_SHOWINCLUDES_PREFIX lang) +function(CMAKE_DETERMINE_MSVC_SHOWINCLUDES_PREFIX lang userflags) # Run this MSVC-compatible compiler to detect what the /showIncludes # option displays. We can use a C source even with the C++ compiler # because MSVC-compatible compilers handle both and show the same output. @@ -677,7 +710,7 @@ function(CMAKE_DETERMINE_MSVC_SHOWINCLUDES_PREFIX lang) execute_process( COMMAND "${CMAKE_${lang}_COMPILER}" ${CMAKE_${lang}_COMPILER_ID_ARG1} - ${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST} + ${userflags} /nologo /showIncludes /c main.c WORKING_DIRECTORY ${showdir} OUTPUT_VARIABLE out diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake index 484fa66..9e9770a 100644 --- a/Modules/CMakeDetermineFortranCompiler.cmake +++ b/Modules/CMakeDetermineFortranCompiler.cmake @@ -255,6 +255,9 @@ if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX) endif () include(CMakeFindBinUtils) +set(_CMAKE_PROCESSING_LANGUAGE "Fortran") +include(Compiler/${CMAKE_Fortran_COMPILER_ID}-FindBinUtils OPTIONAL) +unset(_CMAKE_PROCESSING_LANGUAGE) if(MSVC_Fortran_ARCHITECTURE_ID) set(SET_MSVC_Fortran_ARCHITECTURE_ID diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake index 8675553..20dcf1b 100644 --- a/Modules/CMakeDetermineSystem.cmake +++ b/Modules/CMakeDetermineSystem.cmake @@ -35,10 +35,17 @@ if(CMAKE_HOST_UNIX) find_program(CMAKE_UNAME uname /bin /usr/bin /usr/local/bin ) if(CMAKE_UNAME) - exec_program(uname ARGS -s OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_NAME) - exec_program(uname ARGS -r OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION) + if(CMAKE_HOST_SYSTEM_NAME STREQUAL "AIX") + exec_program(${CMAKE_UNAME} ARGS -v OUTPUT_VARIABLE _CMAKE_HOST_SYSTEM_MAJOR_VERSION) + exec_program(${CMAKE_UNAME} ARGS -r OUTPUT_VARIABLE _CMAKE_HOST_SYSTEM_MINOR_VERSION) + set(CMAKE_HOST_SYSTEM_VERSION "${_CMAKE_HOST_SYSTEM_MAJOR_VERSION}.${_CMAKE_HOST_SYSTEM_MINOR_VERSION}") + unset(_CMAKE_HOST_SYSTEM_MAJOR_VERSION) + unset(_CMAKE_HOST_SYSTEM_MINOR_VERSION) + else() + exec_program(${CMAKE_UNAME} ARGS -r OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION) + endif() if(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|CYGWIN.*|Darwin|^GNU$") - exec_program(uname ARGS -m OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR + exec_program(${CMAKE_UNAME} ARGS -m OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR RETURN_VALUE val) if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "Power Macintosh") @@ -49,10 +56,10 @@ if(CMAKE_HOST_UNIX) exec_program(arch ARGS -s OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR RETURN_VALUE val) else() - exec_program(uname ARGS -p OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR + exec_program(${CMAKE_UNAME} ARGS -p OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR RETURN_VALUE val) if("${val}" GREATER 0) - exec_program(uname ARGS -m OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR + exec_program(${CMAKE_UNAME} ARGS -m OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR RETURN_VALUE val) endif() endif() @@ -67,7 +74,6 @@ if(CMAKE_HOST_UNIX) endif() else() if(CMAKE_HOST_WIN32) - set (CMAKE_HOST_SYSTEM_NAME "Windows") if (DEFINED ENV{PROCESSOR_ARCHITEW6432}) set (CMAKE_HOST_SYSTEM_PROCESSOR "$ENV{PROCESSOR_ARCHITEW6432}") else() diff --git a/Modules/CMakeFortranCompiler.cmake.in b/Modules/CMakeFortranCompiler.cmake.in index 69800d7..d521190 100644 --- a/Modules/CMakeFortranCompiler.cmake.in +++ b/Modules/CMakeFortranCompiler.cmake.in @@ -8,7 +8,9 @@ set(CMAKE_Fortran_SIMULATE_ID "@CMAKE_Fortran_SIMULATE_ID@") set(CMAKE_Fortran_SIMULATE_VERSION "@CMAKE_Fortran_SIMULATE_VERSION@") @SET_MSVC_Fortran_ARCHITECTURE_ID@ set(CMAKE_AR "@CMAKE_AR@") +set(CMAKE_Fortran_COMPILER_AR "@CMAKE_Fortran_COMPILER_AR@") set(CMAKE_RANLIB "@CMAKE_RANLIB@") +set(CMAKE_Fortran_COMPILER_RANLIB "@CMAKE_Fortran_COMPILER_RANLIB@") set(CMAKE_COMPILER_IS_GNUG77 @CMAKE_COMPILER_IS_GNUG77@) set(CMAKE_Fortran_COMPILER_LOADED 1) set(CMAKE_Fortran_COMPILER_WORKS @CMAKE_Fortran_COMPILER_WORKS@) diff --git a/Modules/CMakeVS7BackwardCompatibility.cmake b/Modules/CMakeVS7BackwardCompatibility.cmake deleted file mode 100644 index cf477c8..0000000 --- a/Modules/CMakeVS7BackwardCompatibility.cmake +++ /dev/null @@ -1,16 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - - -# hard code these for fast backwards compatibility tests -set (CMAKE_SIZEOF_INT 4 CACHE INTERNAL "Size of int data type") -set (CMAKE_SIZEOF_LONG 4 CACHE INTERNAL "Size of long data type") -set (CMAKE_SIZEOF_VOID_P 4 CACHE INTERNAL "Size of void* data type") -set (CMAKE_SIZEOF_CHAR 1 CACHE INTERNAL "Size of char data type") -set (CMAKE_SIZEOF_SHORT 2 CACHE INTERNAL "Size of short data type") -set (CMAKE_SIZEOF_FLOAT 4 CACHE INTERNAL "Size of float data type") -set (CMAKE_SIZEOF_DOUBLE 8 CACHE INTERNAL "Size of double data type") -set (CMAKE_NO_ANSI_FOR_SCOPE 0 CACHE INTERNAL - "Does the compiler support ansi for scope.") -set (CMAKE_USE_WIN32_THREADS TRUE CACHE BOOL "Use the win32 thread library.") -set (CMAKE_WORDS_BIGENDIAN 0 CACHE INTERNAL "endianness of bytes") diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index 4e7546b..a63fc83 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -98,7 +98,12 @@ # # .. variable:: CPACK_PACKAGE_DESCRIPTION_SUMMARY # -# Short description of the project (only a few words). +# Short description of the project (only a few words). Default value is:: +# +# ${PROJECT_DESCRIPTION} +# +# if DESCRIPTION has given to the project() call or +# CMake generated string with PROJECT_NAME otherwise. # # .. variable:: CPACK_PACKAGE_FILE_NAME # @@ -360,8 +365,13 @@ _cpack_set_default(CPACK_PACKAGE_VERSION_PATCH "1") _cpack_set_default(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") _cpack_set_default(CPACK_PACKAGE_VENDOR "Humanity") -_cpack_set_default(CPACK_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") +endif() _cpack_set_default(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_ROOT}/Templates/CPack.GenericDescription.txt") diff --git a/Modules/CPackComponent.cmake b/Modules/CPackComponent.cmake index 188dde3..2adc9b9 100644 --- a/Modules/CPackComponent.cmake +++ b/Modules/CPackComponent.cmake @@ -105,7 +105,8 @@ # [DEPENDS comp1 comp2 ... ] # [INSTALL_TYPES type1 type2 ... ] # [DOWNLOADED] -# [ARCHIVE_FILE filename]) +# [ARCHIVE_FILE filename] +# [PLIST filename]) # # # @@ -163,6 +164,9 @@ # a file with some name based on CPACK_PACKAGE_FILE_NAME and the name of # the component. See cpack_configure_downloads for more information. # +# PLIST gives a filename that is passed to pkgbuild with the +# ``--component-plist`` argument when using the productbuild generator. +# # .. command:: cpack_add_component_group # # Describes a group of related CPack installation components. @@ -299,38 +303,6 @@ if(NOT CPackComponent_CMake_INCLUDED) set(CPackComponent_CMake_INCLUDED 1) -# Argument-parsing macro from https://cmake.org/Wiki/CMakeMacroParseArguments -macro(cpack_parse_arguments prefix arg_names option_names) - set(${prefix}_DEFAULT_ARGS) - foreach(arg_name ${arg_names}) - set(${prefix}_${arg_name}) - endforeach() - foreach(option ${option_names}) - set(${prefix}_${option} FALSE) - endforeach() - - set(current_arg_name DEFAULT_ARGS) - set(current_arg_list) - foreach(arg ${ARGN}) - set(larg_names ${arg_names}) - list(FIND larg_names "${arg}" is_arg_name) - if (is_arg_name GREATER -1) - set(${prefix}_${current_arg_name} ${current_arg_list}) - set(current_arg_name ${arg}) - set(current_arg_list) - else () - set(loption_names ${option_names}) - list(FIND loption_names "${arg}" is_option) - if (is_option GREATER -1) - set(${prefix}_${arg} TRUE) - else () - set(current_arg_list ${current_arg_list} ${arg}) - endif () - endif () - endforeach() - set(${prefix}_${current_arg_name} ${current_arg_list}) -endmacro() - # Macro that appends a SET command for the given variable name (var) # to the macro named strvar, but only if the variable named "var" # has been defined. The string will eventually be appended to a CPack @@ -388,9 +360,10 @@ endmacro() # Macro that adds a component to the CPack installer macro(cpack_add_component compname) string(TOUPPER ${compname} _CPACK_ADDCOMP_UNAME) - cpack_parse_arguments(CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME} - "DISPLAY_NAME;DESCRIPTION;GROUP;DEPENDS;INSTALL_TYPES;ARCHIVE_FILE" + cmake_parse_arguments(CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME} "HIDDEN;REQUIRED;DISABLED;DOWNLOADED" + "DISPLAY_NAME;DESCRIPTION;GROUP;ARCHIVE_FILE;PLIST" + "DEPENDS;INSTALL_TYPES" ${ARGN} ) @@ -445,6 +418,9 @@ macro(cpack_add_component compname) cpack_append_option_set_command( CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_DOWNLOADED _CPACK_ADDCOMP_STR) + cpack_append_string_variable_set_command( + CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_PLIST + _CPACK_ADDCOMP_STR) # Backward compatibility issue. # Write to config iff the macros is used after CPack.cmake has been # included, other it's not necessary because the variables @@ -457,9 +433,10 @@ endmacro() # Macro that adds a component group to the CPack installer macro(cpack_add_component_group grpname) string(TOUPPER ${grpname} _CPACK_ADDGRP_UNAME) - cpack_parse_arguments(CPACK_COMPONENT_GROUP_${_CPACK_ADDGRP_UNAME} - "DISPLAY_NAME;DESCRIPTION;PARENT_GROUP" + cmake_parse_arguments(CPACK_COMPONENT_GROUP_${_CPACK_ADDGRP_UNAME} "EXPANDED;BOLD_TITLE" + "DISPLAY_NAME;DESCRIPTION;PARENT_GROUP" + "" ${ARGN} ) @@ -491,7 +468,8 @@ endmacro() # Macro that adds an installation type to the CPack installer macro(cpack_add_install_type insttype) string(TOUPPER ${insttype} _CPACK_INSTTYPE_UNAME) - cpack_parse_arguments(CPACK_INSTALL_TYPE_${_CPACK_INSTTYPE_UNAME} + cmake_parse_arguments(CPACK_INSTALL_TYPE_${_CPACK_INSTTYPE_UNAME} + "" "DISPLAY_NAME" "" ${ARGN} @@ -514,9 +492,10 @@ macro(cpack_add_install_type insttype) endmacro() macro(cpack_configure_downloads site) - cpack_parse_arguments(CPACK_DOWNLOAD - "UPLOAD_DIRECTORY" + cmake_parse_arguments(CPACK_DOWNLOAD "ALL;ADD_REMOVE;NO_ADD_REMOVE" + "UPLOAD_DIRECTORY" + "" ${ARGN} ) diff --git a/Modules/CPackIFW.cmake b/Modules/CPackIFW.cmake index deb724c..099dd1c 100644 --- a/Modules/CPackIFW.cmake +++ b/Modules/CPackIFW.cmake @@ -28,8 +28,32 @@ # and Mac OS X. # # You should also install QtIFW_ to use CPack ``IFW`` generator. -# If you don't use a default path for the installation, please set -# the used path in the variable ``QTIFWDIR``. +# +# Hints +# ^^^^^ +# +# Generally, the CPack ``IFW`` generator automatically finds QtIFW_ tools, +# but if you don't use a default path for installation of the QtIFW_ tools, +# the path may be specified in either a CMake or an environment variable: +# +# .. variable:: CPACK_IFW_ROOT +# +# An CMake variable which specifies the location of the QtIFW_ tool suite. +# +# The variable will be cached in the ``CPackConfig.cmake`` file and used at +# CPack runtime. +# +# .. variable:: QTIFWDIR +# +# An environment variable which specifies the location of the QtIFW_ tool +# suite. +# +# .. note:: +# The specified path should not contain "bin" at the end +# (for example: "D:\\DevTools\\QtIFW2.0.5"). +# +# The :variable:`CPACK_IFW_ROOT` variable has a higher priority and overrides +# the value of the :variable:`QTIFWDIR` variable. # # Variables # ^^^^^^^^^ @@ -197,7 +221,7 @@ # dependent components. # # Tools -# """""""" +# """"" # # .. variable:: CPACK_IFW_FRAMEWORK_VERSION # @@ -207,13 +231,25 @@ # # The path to "binarycreator" command line client. # -# This variable is cached and can be configured user if need. +# This variable is cached and may be configured if needed. # # .. variable:: CPACK_IFW_REPOGEN_EXECUTABLE # # The path to "repogen" command line client. # -# This variable is cached and can be configured user if need. +# This variable is cached and may be configured if needed. +# +# .. variable:: CPACK_IFW_INSTALLERBASE_EXECUTABLE +# +# The path to "installerbase" installer executable base. +# +# This variable is cached and may be configured if needed. +# +# .. variable:: CPACK_IFW_DEVTOOL_EXECUTABLE +# +# The path to "devtool" command line client. +# +# This variable is cached and may be configured if needed. # # Commands # ^^^^^^^^^ @@ -568,7 +604,7 @@ # Default path -foreach(_CPACK_IFW_PATH_VAR "QTIFWDIR" "QTDIR") +foreach(_CPACK_IFW_PATH_VAR "CPACK_IFW_ROOT" "QTIFWDIR" "QTDIR") if(DEFINED ${_CPACK_IFW_PATH_VAR} AND NOT "${${_CPACK_IFW_PATH_VAR}}" STREQUAL "") list(APPEND _CPACK_IFW_PATHS "${${_CPACK_IFW_PATH_VAR}}") @@ -597,6 +633,10 @@ set(_CPACK_IFW_PREFIXES "QtIFW-") set(_CPACK_IFW_VERSIONS + "3.1" + "3.1.0" + "3.0" + "3.0.0" "2.3" "2.3.0" "2.2" @@ -604,6 +644,7 @@ set(_CPACK_IFW_VERSIONS "2.1" "2.1.0" "2.0" + "2.0.5" "2.0.3" "2.0.2" "2.0.1" diff --git a/Modules/CPackProductBuild.cmake b/Modules/CPackProductBuild.cmake index d545d3e..4779b95 100644 --- a/Modules/CPackProductBuild.cmake +++ b/Modules/CPackProductBuild.cmake @@ -46,3 +46,11 @@ # # Specify a specific keychain to search for the signing identity. # +# +# .. variable:: CPACK_PRODUCTBUILD_RESOURCES_DIR +# +# If specified the productbuild generator copies files from this directory +# (including subdirectories) to the ``Resources`` directory. This is done +# before the :variable:`CPACK_RESOURCE_FILE_WELCOME`, +# :variable:`CPACK_RESOURCE_FILE_README`, and +# :variable:`CPACK_RESOURCE_FILE_LICENSE` files are copied. diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index 866c61e..fa2a6e4 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -817,6 +817,30 @@ # is set then :variable:`CPACK_RPM_DEBUGINFO_PACKAGE` is automatically set to # ``ON`` when :variable:`CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE` is set. # +# .. variable:: CPACK_RPM_DEBUGINFO_FILE_NAME +# CPACK_RPM_<component>_DEBUGINFO_FILE_NAME +# +# Debuginfo package file name. +# +# * Mandatory : NO +# * Default : rpmbuild tool generated package file name +# +# Alternatively provided debuginfo package file name must end with ``.rpm`` +# suffix and should differ from file names of other generated packages. +# +# Variable may contain ``@cpack_component@`` placeholder which will be +# replaced by component name if component packaging is enabled otherwise it +# deletes the placeholder. +# +# Setting the variable to ``RPM-DEFAULT`` may be used to explicitly set +# filename generation to default. +# +# .. note:: +# +# :variable:`CPACK_RPM_FILE_NAME` also supports rpmbuild tool generated package +# file name - disabled by default but can be enabled by setting the variable to +# ``RPM-DEFAULT``. +# # Packaging of sources (SRPM) # ^^^^^^^^^^^^^^^^^^^^^^^^^^^ # @@ -963,10 +987,20 @@ function(cpack_rpm_prepare_relocation_paths) foreach(RELOCATION_PATH ${RPM_RELOCATION_PATHS}) if(IS_ABSOLUTE "${RELOCATION_PATH}") set(PREPARED_RELOCATION_PATH "${RELOCATION_PATH}") + elseif(PATH_PREFIX STREQUAL "/") + # don't prefix path with a second slash as "//" is treated as network path + # by get_filename_component() so it remains in path even inside rpm + # package where it may cause problems with relocation + set(PREPARED_RELOCATION_PATH "/${RELOCATION_PATH}") else() set(PREPARED_RELOCATION_PATH "${PATH_PREFIX}/${RELOCATION_PATH}") endif() + # handle cases where path contains extra slashes (e.g. /a//b/ instead of + # /a/b) + get_filename_component(PREPARED_RELOCATION_PATH + "${PREPARED_RELOCATION_PATH}" ABSOLUTE) + if(EXISTS "${WDIR}/${PREPARED_RELOCATION_PATH}") string(APPEND TMP_RPM_PREFIXES "Prefix: ${PREPARED_RELOCATION_PATH}\n") list(APPEND RPM_USED_PACKAGE_PREFIXES "${PREPARED_RELOCATION_PATH}") @@ -1049,7 +1083,7 @@ function(cpack_rpm_prepare_content_list) endif() if(NOT DEFINED CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST) - set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST /etc /etc/init.d /usr /usr/share /usr/share/doc /usr/bin /usr/lib /usr/lib64 /usr/include) + set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST /etc /etc/init.d /usr /usr/share /usr/share/doc /usr/bin /usr/lib /usr/lib64 /usr/libx32 /usr/include) if(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION) if(CPACK_RPM_PACKAGE_DEBUG) message("CPackRPM:Debug: Adding ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION} to builtin omit list.") @@ -2135,6 +2169,11 @@ function(cpack_rpm_generate_package) set(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/usr/src/debug/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}") endif() + # handle cases where path contains extra slashes (e.g. /a//b/ instead of + # /a/b) + get_filename_component(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX + "${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}" ABSOLUTE) + if(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE AND GENERATE_SPEC_PARTS) file(WRITE "${CPACK_RPM_ROOTDIR}/SPECS/${CPACK_RPM_PACKAGE_COMPONENT}.files" "${CPACK_RPM_INSTALL_FILES}") @@ -2638,11 +2677,27 @@ mv %_topdir/tmpBBroot $RPM_BUILD_ROOT unset(expected_filenames_) unset(filenames_) if(CPACK_RPM_DEBUGINFO_PACKAGE AND NOT CPACK_RPM_FILE_NAME STREQUAL "RPM-DEFAULT") - string(TOLOWER "${CPACK_RPM_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.*\\.rpm" efn_) - list(APPEND expected_filenames_ "${efn_}") + list(APPEND expected_filenames_ + "${CPACK_RPM_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.*\\.rpm") list(APPEND filenames_ "${CPACK_RPM_FILE_NAME}") endif() + if(CPACK_RPM_DEBUGINFO_PACKAGE) + cpack_rpm_variable_fallback("CPACK_RPM_DEBUGINFO_FILE_NAME" + "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_DEBUGINFO_FILE_NAME" + "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEBUGINFO_FILE_NAME" + "CPACK_RPM_DEBUGINFO_FILE_NAME") + + if(CPACK_RPM_DEBUGINFO_FILE_NAME AND + NOT CPACK_RPM_DEBUGINFO_FILE_NAME STREQUAL "RPM-DEFAULT") + list(APPEND expected_filenames_ + "${CPACK_RPM_PACKAGE_NAME}-debuginfo-${CPACK_PACKAGE_VERSION}.*\\.rpm") + string(REPLACE "@cpack_component@" "${CPACK_RPM_PACKAGE_COMPONENT}" + CPACK_RPM_DEBUGINFO_FILE_NAME "${CPACK_RPM_DEBUGINFO_FILE_NAME}") + list(APPEND filenames_ "${CPACK_RPM_DEBUGINFO_FILE_NAME}") + endif() + endif() + # check if other files have to be renamed file(GLOB rename_files_ "${CPACK_RPM_DIRECTORY}/SPECS/*.rpm_name") if(rename_files_) diff --git a/Modules/CPackWIX.cmake b/Modules/CPackWIX.cmake index 0f2278f..1dc37d4 100644 --- a/Modules/CPackWIX.cmake +++ b/Modules/CPackWIX.cmake @@ -243,20 +243,20 @@ # # .. variable:: CPACK_WIX_ROOT_FEATURE_TITLE # -# Sets the name of the root install feature in the WIX installer. Same as -# CPACK_COMPONENT_<compName>_DISPLAY_NAME for components. +# Sets the name of the root install feature in the WIX installer. Same as +# CPACK_COMPONENT_<compName>_DISPLAY_NAME for components. # # .. variable:: CPACK_WIX_ROOT_FEATURE_DESCRIPTION # -# Sets the description of the root install feature in the WIX installer. Same as -# CPACK_COMPONENT_<compName>_DESCRIPTION for components. +# Sets the description of the root install feature in the WIX installer. Same as +# CPACK_COMPONENT_<compName>_DESCRIPTION for components. # # .. variable:: CPACK_WIX_SKIP_PROGRAM_FOLDER # -# If this variable is set to true, the default install location -# of the generated package will be CPACK_PACKAGE_INSTALL_DIRECTORY directly. -# The install location will not be located relatively below -# ProgramFiles or ProgramFiles64. +# If this variable is set to true, the default install location +# of the generated package will be CPACK_PACKAGE_INSTALL_DIRECTORY directly. +# The install location will not be located relatively below +# ProgramFiles or ProgramFiles64. # # .. note:: # Installers created with this feature do not take differences @@ -268,6 +268,25 @@ # follow the localization or convention of the system on which the # installation is performed. # +# .. variable:: CPACK_WIX_ROOT_FOLDER_ID +# +# This variable allows specification of a custom root folder ID. +# The generator specific ``<64>`` token can be used for +# folder IDs that come in 32-bit and 64-bit variants. +# In 32-bit builds the token will expand empty while in 64-bit builds +# it will expand to ``64``. +# +# When unset generated installers will default installing to +# ``ProgramFiles<64>Folder``. +# +# .. variable:: CPACK_WIX_ROOT +# +# This variable can optionally be set to the root directory +# of a custom WiX Toolset installation. +# +# When unspecified CPack will try to locate a WiX Toolset +# installation via the ``WIX`` environment variable instead. +# if(NOT CPACK_WIX_ROOT) file(TO_CMAKE_PATH "$ENV{WIX}" CPACK_WIX_ROOT) diff --git a/Modules/CTest.cmake b/Modules/CTest.cmake index 7aeb5be..9370596 100644 --- a/Modules/CTest.cmake +++ b/Modules/CTest.cmake @@ -54,15 +54,11 @@ in the ``CTestConfig.cmake`` file. option(BUILD_TESTING "Build the testing tree." ON) # function to turn generator name into a version string -# like vs7 vs71 vs8 vs9 +# like vs8 vs9 function(GET_VS_VERSION_STRING generator var) string(REGEX REPLACE "Visual Studio ([0-9][0-9]?)($|.*)" "\\1" NUMBER "${generator}") - if("${generator}" MATCHES "Visual Studio 7 .NET 2003") - set(ver_string "vs71") - else() set(ver_string "vs${NUMBER}") - endif() set(${var} ${ver_string} PARENT_SCOPE) endfunction() diff --git a/Modules/CheckIPOSupported.cmake b/Modules/CheckIPOSupported.cmake new file mode 100644 index 0000000..712a95e --- /dev/null +++ b/Modules/CheckIPOSupported.cmake @@ -0,0 +1,230 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +CheckIPOSupported +----------------- + +Check whether the compiler supports an interprocedural optimization (IPO/LTO). +Use this before enabling the :prop_tgt:`INTERPROCEDURAL_OPTIMIZATION` target +property. + +.. command:: check_ipo_supported + + :: + + check_ipo_supported([RESULT <result>] [OUTPUT <output>] + [LANGUAGES <lang>...]) + + Options are: + + ``RESULT <result>`` + Set ``<result>`` variable to ``YES`` if IPO is supported by the + compiler and ``NO`` otherwise. If this option is not given then + the command will issue a fatal error if IPO is not supported. + ``OUTPUT <output>`` + Set ``<output>`` variable with details about any error. + ``LANGUAGES <lang>...`` + Specify languages whose compilers to check. + Languages ``C`` and ``CXX`` are supported. + +It makes no sense to use this module when :policy:`CMP0069` is set to ``OLD`` so +module will return error in this case. See policy :policy:`CMP0069` for details. + +Examples +^^^^^^^^ + +.. code-block:: cmake + + check_ipo_supported() # fatal error if IPO is not supported + set_property(TARGET foo PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) + +.. code-block:: cmake + + # Optional IPO. Do not use IPO if it's not supported by compiler. + check_ipo_supported(RESULT result OUTPUT output) + if(result) + set_property(TARGET foo PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) + else() + message(WARNING "IPO is not supported: ${output}") + endif() + +#]=======================================================================] + +include(CMakeParseArguments) # cmake_parse_arguments + +# X_RESULT - name of the final result variable +# X_OUTPUT - name of the variable with information about error +macro(_ipo_not_supported output) + string(COMPARE EQUAL "${X_RESULT}" "" is_empty) + if(is_empty) + message(FATAL_ERROR "IPO is not supported (${output}).") + endif() + + set("${X_RESULT}" NO PARENT_SCOPE) + set("${X_OUTPUT}" "${output}" PARENT_SCOPE) +endmacro() + +# Run IPO/LTO test +macro(_ipo_run_language_check language) + set(testdir "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/_CMakeLTOTest-${language}") + + file(REMOVE_RECURSE "${testdir}") + file(MAKE_DIRECTORY "${testdir}") + + set(bindir "${testdir}/bin") + set(srcdir "${testdir}/src") + + file(MAKE_DIRECTORY "${bindir}") + file(MAKE_DIRECTORY "${srcdir}") + + set(TRY_COMPILE_PROJECT_NAME "lto-test") + + set(try_compile_src "${CMAKE_ROOT}/Modules/CheckIPOSupported") + + # Use: + # * TRY_COMPILE_PROJECT_NAME + # * CMAKE_VERSION + configure_file( + "${try_compile_src}/CMakeLists-${language}.txt.in" + "${srcdir}/CMakeLists.txt" + @ONLY + ) + + string(COMPARE EQUAL "${language}" "C" is_c) + string(COMPARE EQUAL "${language}" "CXX" is_cxx) + string(COMPARE EQUAL "${language}" "Fortran" is_fortran) + + if(is_c) + set(copy_sources foo.c main.c) + elseif(is_cxx) + set(copy_sources foo.cpp main.cpp) + elseif(is_fortran) + set(copy_sources foo.f main.f) + else() + message(FATAL_ERROR "Language not supported") + endif() + + foreach(x ${copy_sources}) + configure_file( + "${try_compile_src}/${x}" + "${srcdir}/${x}" + COPYONLY + ) + endforeach() + + try_compile( + result + "${bindir}" + "${srcdir}" + "${TRY_COMPILE_PROJECT_NAME}" + CMAKE_FLAGS + "-DCMAKE_VERBOSE_MAKEFILE=ON" + "-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON" + OUTPUT_VARIABLE output + ) + + if(NOT result) + _ipo_not_supported("${output}") + return() + endif() +endmacro() + +function(check_ipo_supported) + cmake_policy(GET CMP0069 x) + + string(COMPARE EQUAL "${x}" "" not_set) + if(not_set) + message(FATAL_ERROR "Policy CMP0069 is not set") + endif() + + string(COMPARE EQUAL "${x}" "OLD" is_old) + if(is_old) + message(FATAL_ERROR "Policy CMP0069 set to OLD") + endif() + + set(optional) + set(one RESULT OUTPUT) + set(multiple LANGUAGES) + + # Introduce: + # * X_RESULT + # * X_OUTPUT + # * X_LANGUAGES + cmake_parse_arguments(X "${optional}" "${one}" "${multiple}" "${ARGV}") + + string(COMPARE NOTEQUAL "${X_UNPARSED_ARGUMENTS}" "" has_unparsed) + if(has_unparsed) + message(FATAL_ERROR "Unparsed arguments: ${X_UNPARSED_ARGUMENTS}") + endif() + + string(COMPARE EQUAL "${X_LANGUAGES}" "" no_languages) + if(no_languages) + # User did not set any languages, use defaults + get_property(enabled_languages GLOBAL PROPERTY ENABLED_LANGUAGES) + string(COMPARE EQUAL "${enabled_languages}" "" no_languages) + if(no_languages) + _ipo_not_supported( + "no languages found in ENABLED_LANGUAGES global property" + ) + return() + endif() + + set(languages "") + list(FIND enabled_languages "CXX" result) + if(NOT result EQUAL -1) + list(APPEND languages "CXX") + endif() + + list(FIND enabled_languages "C" result) + if(NOT result EQUAL -1) + list(APPEND languages "C") + endif() + + list(FIND enabled_languages "Fortran" result) + if(NOT result EQUAL -1) + list(APPEND languages "Fortran") + endif() + + string(COMPARE EQUAL "${languages}" "" no_languages) + if(no_languages) + _ipo_not_supported( + "no C/CXX/Fortran languages found in ENABLED_LANGUAGES global property" + ) + return() + endif() + else() + set(languages "${X_LANGUAGES}") + + set(unsupported_languages "${languages}") + list(REMOVE_ITEM unsupported_languages "C" "CXX" "Fortran") + string(COMPARE NOTEQUAL "${unsupported_languages}" "" has_unsupported) + if(has_unsupported) + _ipo_not_supported( + "language(s) '${unsupported_languages}' not supported" + ) + return() + endif() + endif() + + if(NOT _CMAKE_IPO_SUPPORTED_BY_CMAKE) + _ipo_not_supported("CMake doesn't support IPO for current compiler") + return() + endif() + + if(NOT _CMAKE_IPO_MAY_BE_SUPPORTED_BY_COMPILER) + _ipo_not_supported("Compiler doesn't support IPO") + return() + endif() + + if(CMAKE_GENERATOR MATCHES "^(Visual Studio |Xcode$)") + _ipo_not_supported("CMake doesn't support IPO for current generator") + return() + endif() + + foreach(x ${languages}) + _ipo_run_language_check(${x}) + endforeach() + + set("${X_RESULT}" YES PARENT_SCOPE) +endfunction() diff --git a/Modules/CheckIPOSupported/CMakeLists-C.txt.in b/Modules/CheckIPOSupported/CMakeLists-C.txt.in new file mode 100644 index 0000000..5a3b8ee --- /dev/null +++ b/Modules/CheckIPOSupported/CMakeLists-C.txt.in @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION "@CMAKE_VERSION@") +project("@TRY_COMPILE_PROJECT_NAME@" LANGUAGES C) + +cmake_policy(SET CMP0069 NEW) + +add_library(foo foo.c) +add_executable(boo main.c) +target_link_libraries(boo PUBLIC foo) diff --git a/Modules/CheckIPOSupported/CMakeLists-CXX.txt.in b/Modules/CheckIPOSupported/CMakeLists-CXX.txt.in new file mode 100644 index 0000000..30993fa --- /dev/null +++ b/Modules/CheckIPOSupported/CMakeLists-CXX.txt.in @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION "@CMAKE_VERSION@") +project("@TRY_COMPILE_PROJECT_NAME@" LANGUAGES CXX) + +cmake_policy(SET CMP0069 NEW) + +add_library(foo foo.cpp) +add_executable(boo main.cpp) +target_link_libraries(boo PUBLIC foo) diff --git a/Modules/CheckIPOSupported/CMakeLists-Fortran.txt.in b/Modules/CheckIPOSupported/CMakeLists-Fortran.txt.in new file mode 100644 index 0000000..9fab077 --- /dev/null +++ b/Modules/CheckIPOSupported/CMakeLists-Fortran.txt.in @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION "@CMAKE_VERSION@") +project("@TRY_COMPILE_PROJECT_NAME@" LANGUAGES Fortran) + +cmake_policy(SET CMP0069 NEW) + +add_library(foo foo.f) +add_executable(boo main.f) +target_link_libraries(boo PUBLIC foo) diff --git a/Modules/CheckIPOSupported/foo.c b/Modules/CheckIPOSupported/foo.c new file mode 100644 index 0000000..1e56597 --- /dev/null +++ b/Modules/CheckIPOSupported/foo.c @@ -0,0 +1,4 @@ +int foo() +{ + return 0x42; +} diff --git a/Modules/CheckIPOSupported/foo.cpp b/Modules/CheckIPOSupported/foo.cpp new file mode 100644 index 0000000..1e56597 --- /dev/null +++ b/Modules/CheckIPOSupported/foo.cpp @@ -0,0 +1,4 @@ +int foo() +{ + return 0x42; +} diff --git a/Modules/CheckIPOSupported/foo.f b/Modules/CheckIPOSupported/foo.f new file mode 100644 index 0000000..945d2d5 --- /dev/null +++ b/Modules/CheckIPOSupported/foo.f @@ -0,0 +1,2 @@ + SUBROUTINE FOO + END diff --git a/Modules/CheckIPOSupported/main.c b/Modules/CheckIPOSupported/main.c new file mode 100644 index 0000000..5be0864 --- /dev/null +++ b/Modules/CheckIPOSupported/main.c @@ -0,0 +1,6 @@ +int foo(); + +int main() +{ + return foo(); +} diff --git a/Modules/CheckIPOSupported/main.cpp b/Modules/CheckIPOSupported/main.cpp new file mode 100644 index 0000000..5be0864 --- /dev/null +++ b/Modules/CheckIPOSupported/main.cpp @@ -0,0 +1,6 @@ +int foo(); + +int main() +{ + return foo(); +} diff --git a/Modules/CheckIPOSupported/main.f b/Modules/CheckIPOSupported/main.f new file mode 100644 index 0000000..9d1de9f --- /dev/null +++ b/Modules/CheckIPOSupported/main.f @@ -0,0 +1,3 @@ + PROGRAM BOO + CALL FOO() + END diff --git a/Modules/CheckLanguage.cmake b/Modules/CheckLanguage.cmake index 6b4a9e4..1ea91d2 100644 --- a/Modules/CheckLanguage.cmake +++ b/Modules/CheckLanguage.cmake @@ -46,6 +46,8 @@ file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\" 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}" OUTPUT_VARIABLE output ERROR_VARIABLE output RESULT_VARIABLE result diff --git a/Modules/CheckSymbolExists.cmake b/Modules/CheckSymbolExists.cmake index 8fecc57..6f1afcf 100644 --- a/Modules/CheckSymbolExists.cmake +++ b/Modules/CheckSymbolExists.cmake @@ -1,38 +1,47 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CheckSymbolExists -# ----------------- -# -# Check if a symbol exists as a function, variable, or macro -# -# CHECK_SYMBOL_EXISTS(<symbol> <files> <variable>) -# -# Check that the <symbol> is available after including given header -# <files> and store the result in a <variable>. Specify the list of -# files in one argument as a semicolon-separated list. -# <variable> will be created as an internal cache variable. -# -# If the header files define the symbol as a macro it is considered -# available and assumed to work. If the header files declare the symbol -# as a function or variable then the symbol must also be available for -# linking. If the symbol is a type or enum value it will not be -# recognized (consider using CheckTypeSize or CheckCSourceCompiles). If -# the check needs to be done in C++, consider using -# CHECK_CXX_SYMBOL_EXISTS(), which does the same as -# CHECK_SYMBOL_EXISTS(), but in C++. -# -# The following variables may be set before calling this macro to modify -# the way the check is run: -# -# :: -# -# CMAKE_REQUIRED_FLAGS = string of compile command line flags -# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) -# CMAKE_REQUIRED_INCLUDES = list of include directories -# CMAKE_REQUIRED_LIBRARIES = list of libraries to link -# CMAKE_REQUIRED_QUIET = execute quietly without messages +#[=======================================================================[.rst: +CheckSymbolExists +----------------- + +Provides a macro to check if a symbol exists as a function, variable, +or macro in ``C``. + +.. command:: check_symbol_exists + + :: + + check_symbol_exists(<symbol> <files> <variable>) + + Check that the ``<symbol>`` is available after including given header + ``<files>`` and store the result in a ``<variable>``. Specify the list + of files in one argument as a semicolon-separated list. + ``<variable>`` will be created as an internal cache variable. + +If the header files define the symbol as a macro it is considered +available and assumed to work. If the header files declare the symbol +as a function or variable then the symbol must also be available for +linking (so intrinsics may not be detected). +If the symbol is a type, enum value, or intrinsic it will not be recognized +(consider using :module:`CheckTypeSize` or :module:`CheckCSourceCompiles`). +If the check needs to be done in C++, consider using +:module:`CheckCXXSymbolExists` instead. + +The following variables may be set before calling this macro to modify +the way the check is run: + +``CMAKE_REQUIRED_FLAGS`` + string of compile command line flags +``CMAKE_REQUIRED_DEFINITIONS`` + list of macros to define (-DFOO=bar) +``CMAKE_REQUIRED_INCLUDES`` + list of include directories +``CMAKE_REQUIRED_LIBRARIES`` + list of libraries to link +``CMAKE_REQUIRED_QUIET`` + execute quietly without messages +#]=======================================================================] macro(CHECK_SYMBOL_EXISTS SYMBOL FILES VARIABLE) if(CMAKE_C_COMPILER_LOADED) diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake index 96263fc..6b99a08 100644 --- a/Modules/Compiler/Clang.cmake +++ b/Modules/Compiler/Clang.cmake @@ -27,5 +27,13 @@ else() set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "--target=") set(CMAKE_${lang}_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN "--gcc-toolchain=") endif() + + set(_CMAKE_IPO_SUPPORTED_BY_CMAKE NO) + set(_CMAKE_IPO_MAY_BE_SUPPORTED_BY_COMPILER NO) + + unset(CMAKE_${lang}_COMPILE_OPTIONS_IPO) + unset(CMAKE_${lang}_ARCHIVE_CREATE_IPO) + unset(CMAKE_${lang}_ARCHIVE_APPEND_IPO) + unset(CMAKE_${lang}_ARCHIVE_FINISH_IPO) endmacro() endif() diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake index c007c98..2499d2f 100644 --- a/Modules/Compiler/GNU-CXX.cmake +++ b/Modules/Compiler/GNU-CXX.cmake @@ -11,8 +11,7 @@ else() endif() endif() -if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4) - # Supported since 4.3 +if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4) set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98") set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98") endif() diff --git a/Modules/Compiler/GNU-FindBinUtils.cmake b/Modules/Compiler/GNU-FindBinUtils.cmake new file mode 100644 index 0000000..1aa0219 --- /dev/null +++ b/Modules/Compiler/GNU-FindBinUtils.cmake @@ -0,0 +1,25 @@ +if(NOT DEFINED _CMAKE_PROCESSING_LANGUAGE OR _CMAKE_PROCESSING_LANGUAGE STREQUAL "") + message(FATAL_ERROR "Internal error: _CMAKE_PROCESSING_LANGUAGE is not set") +endif() + +string(REGEX MATCH "^([0-9]+\\.[0-9]+)" __version_x_y + "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_VERSION}") + +# Try to find tools in the same directory as GCC itself +get_filename_component(__gcc_hints "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER}" DIRECTORY) + +# http://manpages.ubuntu.com/manpages/wily/en/man1/gcc-ar.1.html +find_program(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_AR NAMES + "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar" + "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar-${__version_x_y}" + HINTS ${__gcc_hints} + DOC "A wrapper around 'ar' adding the appropriate '--plugin' option for the GCC compiler" +) + +# http://manpages.ubuntu.com/manpages/wily/en/man1/gcc-ranlib.1.html +find_program(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_RANLIB NAMES + "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib" + "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib-${__version_x_y}" + HINTS ${__gcc_hints} + DOC "A wrapper around 'ranlib' adding the appropriate '--plugin' option for the GCC compiler" +) diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake index b67002c..0a510f5 100644 --- a/Modules/Compiler/GNU.cmake +++ b/Modules/Compiler/GNU.cmake @@ -45,4 +45,43 @@ macro(__compiler_gnu lang) if(NOT APPLE OR NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4) # work around #4462 set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ") endif() + + set(_CMAKE_IPO_SUPPORTED_BY_CMAKE YES) + set(_CMAKE_IPO_MAY_BE_SUPPORTED_BY_COMPILER NO) + + # '-flto' introduced since GCC 4.5: + # * https://gcc.gnu.org/onlinedocs/gcc-4.4.7/gcc/Option-Summary.html (no) + # * https://gcc.gnu.org/onlinedocs/gcc-4.5.4/gcc/Option-Summary.html (yes) + if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4.5) + set(_CMAKE_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES) + set(__lto_flags -flto) + + if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4.7) + # '-ffat-lto-objects' introduced since GCC 4.7: + # * https://gcc.gnu.org/onlinedocs/gcc-4.6.4/gcc/Option-Summary.html (no) + # * https://gcc.gnu.org/onlinedocs/gcc-4.7.4/gcc/Option-Summary.html (yes) + list(APPEND __lto_flags -fno-fat-lto-objects) + endif() + + set(CMAKE_${lang}_COMPILE_OPTIONS_IPO ${__lto_flags}) + + # Need to use version of 'ar'/'ranlib' with plugin support. + # Quote from [documentation][1]: + # + # To create static libraries suitable for LTO, + # use gcc-ar and gcc-ranlib instead of ar and ranlib + # + # [1]: https://gcc.gnu.org/onlinedocs/gcc-4.9.4/gcc/Optimize-Options.html + set(CMAKE_${lang}_ARCHIVE_CREATE_IPO + "${CMAKE_${lang}_COMPILER_AR} cr <TARGET> <LINK_FLAGS> <OBJECTS>" + ) + + set(CMAKE_${lang}_ARCHIVE_APPEND_IPO + "${CMAKE_${lang}_COMPILER_AR} r <TARGET> <LINK_FLAGS> <OBJECTS>" + ) + + set(CMAKE_${lang}_ARCHIVE_FINISH_IPO + "${CMAKE_${lang}_COMPILER_RANLIB} <TARGET>" + ) + endif() endmacro() diff --git a/Modules/Compiler/Intel.cmake b/Modules/Compiler/Intel.cmake index 02968b4..06d01f1 100644 --- a/Modules/Compiler/Intel.cmake +++ b/Modules/Compiler/Intel.cmake @@ -22,5 +22,7 @@ else() string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os") string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3") string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g") + + set(CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "${CMAKE_${lang}_COMPILER}" "-QdM" "-P" "-Za" "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp") endmacro() endif() diff --git a/Modules/Compiler/QCC.cmake b/Modules/Compiler/QCC.cmake index 2d7e881..695a138 100644 --- a/Modules/Compiler/QCC.cmake +++ b/Modules/Compiler/QCC.cmake @@ -12,4 +12,12 @@ macro(__compiler_qcc lang) set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-Wp,-isystem,") set(CMAKE_DEPFILE_FLAGS_${lang} "-Wc,-MD,<DEPFILE>,-MT,<OBJECT>,-MF,<DEPFILE>") + + set(_CMAKE_IPO_SUPPORTED_BY_CMAKE NO) + set(_CMAKE_IPO_MAY_BE_SUPPORTED_BY_COMPILER NO) + + unset(CMAKE_${lang}_COMPILE_OPTIONS_IPO) + unset(CMAKE_${lang}_ARCHIVE_CREATE_IPO) + unset(CMAKE_${lang}_ARCHIVE_APPEND_IPO) + unset(CMAKE_${lang}_ARCHIVE_FINISH_IPO) endmacro() diff --git a/Modules/CompilerId/VS-10.vcxproj.in b/Modules/CompilerId/VS-10.vcxproj.in index 50be9cb..6b9b361 100644 --- a/Modules/CompilerId/VS-10.vcxproj.in +++ b/Modules/CompilerId/VS-10.vcxproj.in @@ -25,6 +25,9 @@ <CharacterSet>MultiByte</CharacterSet> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + @id_Import_props@ + </ImportGroup> <PropertyGroup> <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|@id_platform@'">.\</OutDir> @@ -44,16 +47,21 @@ <DebugInformationFormat> </DebugInformationFormat> </ClCompile> + @id_ItemDefinitionGroup_entry@ <Link> <GenerateDebugInformation>false</GenerateDebugInformation> <SubSystem>Console</SubSystem> + @id_Link_AdditionalDependencies@ </Link> <PostBuildEvent> - <Command>for %%i in (@id_cl@) do %40echo CMAKE_@id_lang@_COMPILER=%%~$PATH:i</Command> + <Command>@id_PostBuildEvent_Command@</Command> </PostBuildEvent> </ItemDefinitionGroup> <ItemGroup> - <ClCompile Include="@id_src@" /> + <@id_compile@ Include="@id_src@" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + @id_Import_targets@ + </ImportGroup> </Project> diff --git a/Modules/CompilerId/Xcode-3.pbxproj.in b/Modules/CompilerId/Xcode-3.pbxproj.in index 22ad4f6..84f48ae 100644 --- a/Modules/CompilerId/Xcode-3.pbxproj.in +++ b/Modules/CompilerId/Xcode-3.pbxproj.in @@ -58,7 +58,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "echo \"GCC_VERSION=$GCC_VERSION\""; + shellScript = "echo \"GCC_VERSION=$GCC_VERSION\" ; echo \"CURRENT_ARCH=$CURRENT_ARCH\""; showEnvVarsInLog = 0; }; 2C18F0B515DC1DCE00593670 = { diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index b42d2dd..b812845 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -531,6 +531,15 @@ function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git else() set(git_clone_shallow_options "--depth 1") endif() + 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-- "--") + else() + # Use `git checkout <branch>` even though this risks ambiguity with a + # local path. Unfortunately we cannot use `git checkout <tree-ish> --` + # because that will not search for remote branch names, a common use case. + set(git_checkout_explicit-- "") + endif() file(WRITE ${script_filename} "if(\"${git_tag}\" STREQUAL \"\") message(FATAL_ERROR \"Tag for git checkout should not be empty.\") @@ -600,11 +609,8 @@ if(error_code) message(FATAL_ERROR \"Failed to clone repository: '${git_repository}'\") endif() -# Use `git checkout <branch>` even though this risks ambiguity with a -# local path. Unfortunately we cannot use `git checkout <tree-ish> --` -# because that will not search for remote branch names, a common use case. execute_process( - COMMAND \"${git_EXECUTABLE}\" \${git_options} checkout ${git_tag} + COMMAND \"${git_EXECUTABLE}\" \${git_options} checkout ${git_tag} ${git_checkout_explicit--} WORKING_DIRECTORY \"${work_dir}/${src_name}\" RESULT_VARIABLE error_code ) @@ -1990,11 +1996,10 @@ function(_ep_add_download_command name) set(comment "Performing download step (${steps}) for '${name}'") _ep_write_verifyfile_script("${stamp_dir}/verify-${name}.cmake" "${file}" "${hash}") endif() - list(APPEND cmd ${CMAKE_COMMAND} -P ${stamp_dir}/verify-${name}.cmake - COMMAND) + list(APPEND cmd ${CMAKE_COMMAND} -P ${stamp_dir}/verify-${name}.cmake) if (NOT no_extract) _ep_write_extractfile_script("${stamp_dir}/extract-${name}.cmake" "${name}" "${file}" "${source_dir}") - list(APPEND cmd ${CMAKE_COMMAND} -P ${stamp_dir}/extract-${name}.cmake) + list(APPEND cmd COMMAND ${CMAKE_COMMAND} -P ${stamp_dir}/extract-${name}.cmake) else () set_property(TARGET ${name} PROPERTY _EP_DOWNLOADED_FILE ${file}) endif () diff --git a/Modules/FeatureSummary.cmake b/Modules/FeatureSummary.cmake index f29a5f0..1b93304 100644 --- a/Modules/FeatureSummary.cmake +++ b/Modules/FeatureSummary.cmake @@ -63,6 +63,16 @@ is set for all the packages. The default value for this global property is ``OPTIONAL``. + +.. variable:: FeatureSummary_<TYPE>_DESCRIPTION + +The global property :variable:`FeatureSummary_<TYPE>_DESCRIPTION` can be defined +for each type to replace the type name with the specified string whenever the +package type is used in an output string. + +If not set, the string "``<TYPE>`` packages" is used. + + #]=======================================================================] get_property(_fsPkgTypeIsSet GLOBAL PROPERTY FeatureSummary_PKG_TYPES SET) @@ -196,7 +206,7 @@ endfunction() [VAR <variable_name>] [INCLUDE_QUIET_PACKAGES] [FATAL_ON_MISSING_REQUIRED_PACKAGES] - [DESCRIPTION "<description>"] + [DESCRIPTION "<description>" | DEFAULT_DESCRIPTION] [QUIET_ON_EMPTY] WHAT (ALL | PACKAGES_FOUND | PACKAGES_NOT_FOUND @@ -247,7 +257,10 @@ endfunction() information is "printed" into the specified variable. If ``FILENAME`` is not used, the information is printed to the terminal. Using the ``DESCRIPTION`` option a description or headline can be set which will be - printed above the actual content. + printed above the actual content. If only one type of + package was requested, no title is printed, unless it is explicitly set using + either ``DESCRIPTION`` to use a custom string, or ``DEFAULT_DESCRIPTION`` to + use a default title for the requested type. If ``INCLUDE_QUIET_PACKAGES`` is given, packages which have been searched with ``find_package(... QUIET)`` will also be listed. By default they are skipped. If ``FATAL_ON_MISSING_REQUIRED_PACKAGES`` is given, CMake will abort if a @@ -306,8 +319,14 @@ endfunction() function(FEATURE_SUMMARY) # CMAKE_PARSE_ARGUMENTS(<prefix> <options> <one_value_keywords> <multi_value_keywords> args...) - set(options APPEND INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES QUIET_ON_EMPTY) - set(oneValueArgs FILENAME VAR DESCRIPTION) + set(options APPEND + INCLUDE_QUIET_PACKAGES + FATAL_ON_MISSING_REQUIRED_PACKAGES + QUIET_ON_EMPTY + DEFAULT_DESCRIPTION) + set(oneValueArgs FILENAME + VAR + DESCRIPTION) set(multiValueArgs WHAT) CMAKE_PARSE_ARGUMENTS(_FS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN}) @@ -320,6 +339,11 @@ function(FEATURE_SUMMARY) message(FATAL_ERROR "The call to FEATURE_SUMMARY() doesn't set the required WHAT argument.") endif() + if(_FS_DEFAULT_DESCRIPTION AND DEFINED _FS_DESCRIPTION) + message(WARNING "DEFAULT_DESCRIPTION option discarded since DESCRIPTION is set.") + set(_FS_DEFAULT_DESCRIPTION 0) + endif() + set(validWhatParts "ENABLED_FEATURES" "DISABLED_FEATURES" "PACKAGES_FOUND" @@ -332,11 +356,29 @@ function(FEATURE_SUMMARY) "${_fsPkgType}_PACKAGES_NOT_FOUND") endforeach() + set(title_ENABLED_FEATURES "The following features have been enabled:") + set(title_DISABLED_FEATURES "The following features have been disabled:") + set(title_PACKAGES_FOUND "The following packages have been found:") + set(title_PACKAGES_NOT_FOUND "The following packages have not been found:") + foreach(_fsPkgType ${_fsPkgTypes}) + set(_fsPkgTypeDescription "${_fsPkgType} packages") + get_property(_fsPkgTypeDescriptionIsSet GLOBAL PROPERTY FeatureSummary_${_fsPkgType}_DESCRIPTION SET) + if(_fsPkgTypeDescriptionIsSet) + get_property(_fsPkgTypeDescription GLOBAL PROPERTY FeatureSummary_${_fsPkgType}_DESCRIPTION ) + endif() + set(title_${_fsPkgType}_PACKAGES_FOUND "The following ${_fsPkgTypeDescription} have been found:") + set(title_${_fsPkgType}_PACKAGES_NOT_FOUND "The following ${_fsPkgTypeDescription} have not been found:") + endforeach() + list(FIND validWhatParts "${_FS_WHAT}" indexInList) if(NOT "${indexInList}" STREQUAL "-1") _FS_GET_FEATURE_SUMMARY( ${_FS_WHAT} _featureSummary ${_FS_INCLUDE_QUIET_PACKAGES} ) if(_featureSummary OR NOT _FS_QUIET_ON_EMPTY) - set(_fullText "${_FS_DESCRIPTION}${_featureSummary}\n") + if(_FS_DEFAULT_DESCRIPTION) + set(_fullText "${title_${_FS_WHAT}}\n${_featureSummary}\n") + else() + set(_fullText "${_FS_DESCRIPTION}${_featureSummary}\n") + endif() endif() if(_featureSummary) @@ -375,15 +417,6 @@ function(FEATURE_SUMMARY) endforeach() endif() - set(title_ENABLED_FEATURES "The following features have been enabled:") - set(title_DISABLED_FEATURES "The following features have been disabled:") - set(title_PACKAGES_FOUND "The following packages have been found:") - set(title_PACKAGES_NOT_FOUND "The following packages have not been found:") - foreach(_fsPkgType ${_fsPkgTypes}) - set(title_${_fsPkgType}_PACKAGES_FOUND "The following ${_fsPkgType} packages have been found:") - set(title_${_fsPkgType}_PACKAGES_NOT_FOUND "The following ${_fsPkgType} packages have not been found:") - endforeach() - set(_fullText "${_FS_DESCRIPTION}") foreach(part ${allWhatParts}) set(_tmp) diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 2dd08e1..093d8c9 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -127,7 +127,10 @@ # ('n' tag). Default is OFF. # Boost_COMPILER - Set to the compiler-specific library suffix # (e.g. "-gcc43"). Default is auto-computed -# for the C++ compiler in use. +# for the C++ compiler in use. A list may be +# used if multiple compatible suffixes should +# be tested for, in decreasing order of +# preference. # Boost_THREADAPI - Suffix for "thread" component library name, # such as "pthread" or "win32". Names with # and without this suffix will both be tried. @@ -428,7 +431,7 @@ function(_Boost_GUESS_COMPILER_PREFIX _ret) set(_boost_COMPILER "-ghs") elseif("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC") if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.10) - set(_boost_COMPILER "-vc141") + set(_boost_COMPILER "-vc141;-vc140") elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19) set(_boost_COMPILER "-vc140") elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18) @@ -893,7 +896,7 @@ endfunction() # This function would append corresponding directories if MSVC is a current compiler, # so having `BOOST_ROOT` would be enough to specify to find everything. # -macro(_Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS componentlibvar basedir) +function(_Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS componentlibvar basedir) if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC") if(CMAKE_SIZEOF_VOID_P EQUAL 8) set(_arch_suffix 64) @@ -901,7 +904,8 @@ macro(_Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS componentlib set(_arch_suffix 32) endif() if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.10) - list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-15.0) + list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-14.1) + list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-14.0) elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19) list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-14.0) elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18) @@ -915,8 +919,9 @@ macro(_Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS componentlib elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14) list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-8.0) endif() + set(${componentlibvar} ${${componentlibvar}} PARENT_SCOPE) endif() -endmacro() +endfunction() # # End functions/macros @@ -1119,6 +1124,12 @@ if(NOT Boost_INCLUDE_DIR) if( Boost_NO_SYSTEM_PATHS) list(APPEND _boost_INCLUDE_SEARCH_DIRS NO_CMAKE_SYSTEM_PATH NO_SYSTEM_ENVIRONMENT_PATH) else() + if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC") + foreach(ver ${_Boost_KNOWN_VERSIONS}) + string(REPLACE "." "_" ver "${ver}") + list(APPEND _boost_INCLUDE_SEARCH_DIRS PATHS "C:/local/boost_${ver}") + endforeach() + endif() list(APPEND _boost_INCLUDE_SEARCH_DIRS PATHS C:/boost/include C:/boost @@ -1392,12 +1403,16 @@ foreach(c DEBUG RELEASE) if( Boost_NO_SYSTEM_PATHS ) list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} NO_CMAKE_SYSTEM_PATH NO_SYSTEM_ENVIRONMENT_PATH) else() + foreach(ver ${_Boost_KNOWN_VERSIONS}) + string(REPLACE "." "_" ver "${ver}") + _Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS(_boost_LIBRARY_SEARCH_DIRS_${c} "C:/local/boost_${ver}") + endforeach() + _Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS(_boost_LIBRARY_SEARCH_DIRS_${c} "C:/boost") list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} PATHS C:/boost/lib C:/boost /sw/local/lib ) - _Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS(_boost_LIBRARY_SEARCH_DIRS_${c} "C:/boost") endif() endif() endforeach() @@ -1524,17 +1539,24 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS}) # # Find RELEASE libraries # - set(_boost_RELEASE_NAMES - ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG} + unset(_boost_RELEASE_NAMES) + foreach(compiler IN LISTS _boost_COMPILER) + list(APPEND _boost_RELEASE_NAMES + ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${compiler}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${compiler}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG} ) + endforeach() + list(APPEND _boost_RELEASE_NAMES ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT} ) if(_boost_STATIC_RUNTIME_WORKAROUND) set(_boost_RELEASE_STATIC_ABI_TAG "-s${_boost_RELEASE_ABI_TAG}") + foreach(compiler IN LISTS _boost_COMPILER) + list(APPEND _boost_RELEASE_NAMES + ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${compiler}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${compiler}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} ) + endforeach() list(APPEND _boost_RELEASE_NAMES - ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} ) endif() @@ -1565,18 +1587,25 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS}) # # Find DEBUG libraries # - set(_boost_DEBUG_NAMES - ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG} + unset(_boost_DEBUG_NAMES) + foreach(compiler IN LISTS _boost_COMPILER) + list(APPEND _boost_DEBUG_NAMES + ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${compiler}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${compiler}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG} ) + endforeach() + list(APPEND _boost_DEBUG_NAMES ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT} ) if(_boost_STATIC_RUNTIME_WORKAROUND) set(_boost_DEBUG_STATIC_ABI_TAG "-s${_boost_DEBUG_ABI_TAG}") + foreach(compiler IN LISTS _boost_COMPILER) + list(APPEND _boost_DEBUG_NAMES + ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${compiler}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${compiler}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} ) + endforeach() list(APPEND _boost_DEBUG_NAMES - ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} ) endif() diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 6b76c25..e323430 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -67,6 +67,13 @@ # -- Set to ON for Emulation mode. -D_DEVICEEMU is defined for CUDA C files # when CUDA_BUILD_EMULATION is TRUE. # +# CUDA_LINK_LIBRARIES_KEYWORD (Default "") +# -- The <PRIVATE|PUBLIC|INTERFACE> keyword to use for internal +# target_link_libraries calls. The default is to use no keyword which +# uses the old "plain" form of target_link_libraries. Note that is matters +# because whatever is used inside the FindCUDA module must also be used +# outside - the two forms of target_link_libraries cannot be mixed. +# # CUDA_GENERATED_OUTPUT_DIR (Default CMAKE_CURRENT_BINARY_DIR) # -- Set to the path you wish to have the generated files placed. If it is # blank output files will be placed in CMAKE_CURRENT_BINARY_DIR. @@ -1740,12 +1747,12 @@ macro(CUDA_ADD_LIBRARY cuda_target) # variable will have been defined. CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS("${link_file}" ${cuda_target} "${_options}" "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") - target_link_libraries(${cuda_target} + target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_LIBRARIES} ) if(CUDA_SEPARABLE_COMPILATION) - target_link_libraries(${cuda_target} + target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cudadevrt_LIBRARY} ) endif() @@ -1790,7 +1797,7 @@ macro(CUDA_ADD_EXECUTABLE cuda_target) # variable will have been defined. CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS("${link_file}" ${cuda_target} "${_options}" "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") - target_link_libraries(${cuda_target} + target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_LIBRARIES} ) @@ -1876,9 +1883,9 @@ endmacro() ############################################################################### macro(CUDA_ADD_CUFFT_TO_TARGET target) if (CUDA_BUILD_EMULATION) - target_link_libraries(${target} ${CUDA_cufftemu_LIBRARY}) + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cufftemu_LIBRARY}) else() - target_link_libraries(${target} ${CUDA_cufft_LIBRARY}) + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cufft_LIBRARY}) endif() endmacro() @@ -1889,9 +1896,9 @@ endmacro() ############################################################################### macro(CUDA_ADD_CUBLAS_TO_TARGET target) if (CUDA_BUILD_EMULATION) - target_link_libraries(${target} ${CUDA_cublasemu_LIBRARY}) + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cublasemu_LIBRARY}) else() - target_link_libraries(${target} ${CUDA_cublas_LIBRARY} ${CUDA_cublas_device_LIBRARY}) + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cublas_LIBRARY} ${CUDA_cublas_device_LIBRARY}) endif() endmacro() diff --git a/Modules/FindDevIL.cmake b/Modules/FindDevIL.cmake index 45fab82..4b868a2 100644 --- a/Modules/FindDevIL.cmake +++ b/Modules/FindDevIL.cmake @@ -45,7 +45,7 @@ find_path(IL_INCLUDE_DIR il.h find_library(IL_LIBRARIES NAMES IL DEVIL - PATH_SUFFIXES lib64 lib lib32 + PATH_SUFFIXES libx32 lib64 lib lib32 DOC "The file that corresponds to the base il library." ) @@ -53,7 +53,7 @@ find_library(IL_LIBRARIES find_library(ILUT_LIBRARIES NAMES ILUT - PATH_SUFFIXES lib64 lib lib32 + PATH_SUFFIXES libx32 lib64 lib lib32 DOC "The file that corresponds to the il (system?) utility library." ) @@ -61,7 +61,7 @@ find_library(ILUT_LIBRARIES find_library(ILU_LIBRARIES NAMES ILU - PATH_SUFFIXES lib64 lib lib32 + PATH_SUFFIXES libx32 lib64 lib lib32 DOC "The file that corresponds to the il utility library." ) diff --git a/Modules/FindGLEW.cmake b/Modules/FindGLEW.cmake index d8609e6..11e8724 100644 --- a/Modules/FindGLEW.cmake +++ b/Modules/FindGLEW.cmake @@ -27,7 +27,7 @@ find_path(GLEW_INCLUDE_DIR GL/glew.h) if(NOT GLEW_LIBRARY) - find_library(GLEW_LIBRARY_RELEASE NAMES GLEW glew32 glew glew32s PATH_SUFFIXES lib64) + find_library(GLEW_LIBRARY_RELEASE NAMES GLEW glew32 glew glew32s PATH_SUFFIXES lib64 libx32) find_library(GLEW_LIBRARY_DEBUG NAMES GLEWd glew32d glewd PATH_SUFFIXES lib64) include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) diff --git a/Modules/FindGTK2.cmake b/Modules/FindGTK2.cmake index fd179a8..b87b9f3 100644 --- a/Modules/FindGTK2.cmake +++ b/Modules/FindGTK2.cmake @@ -292,8 +292,10 @@ function(_GTK2_FIND_INCLUDE_DIR _var _hdr) find_path(GTK2_${_var}_INCLUDE_DIR ${_hdr} PATHS ${_gtk2_arch_dir} + /usr/local/libx32 /usr/local/lib64 /usr/local/lib + /usr/libx32 /usr/lib64 /usr/lib /usr/X11R6/include diff --git a/Modules/FindGTest.cmake b/Modules/FindGTest.cmake index 6540171..c4b4535 100644 --- a/Modules/FindGTest.cmake +++ b/Modules/FindGTest.cmake @@ -70,64 +70,10 @@ # Deeper integration with CTest # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ # -# If you would like each Google test to show up in CTest as a test you -# may use the following macro:: -# -# GTEST_ADD_TESTS(executable extra_args files...) -# -# ``executable`` -# the path to the test executable -# ``extra_args`` -# a list of extra arguments to be passed to executable enclosed in -# quotes (or ``""`` for none) -# ``files...`` -# a list of source files to search for tests and test fixtures. Or -# ``AUTO`` to find them from executable target -# -# However, note that this macro will slow down your tests by running -# an executable for each test and test fixture. -# -# Example usage:: -# -# set(FooTestArgs --foo 1 --bar 2) -# add_executable(FooTest FooUnitTest.cc) -# GTEST_ADD_TESTS(FooTest "${FooTestArgs}" AUTO) - -# -# Thanks to Daniel Blezek <blezek@gmail.com> for the GTEST_ADD_TESTS code - -function(GTEST_ADD_TESTS executable extra_args) - if(NOT ARGN) - message(FATAL_ERROR "Missing ARGN: Read the documentation for GTEST_ADD_TESTS") - endif() - if(ARGN STREQUAL "AUTO") - # obtain sources used for building that executable - get_property(ARGN TARGET ${executable} PROPERTY SOURCES) - endif() - set(gtest_case_name_regex ".*\\( *([A-Za-z_0-9]+) *, *([A-Za-z_0-9]+) *\\).*") - set(gtest_test_type_regex "(TYPED_TEST|TEST_?[FP]?)") - foreach(source ${ARGN}) - set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${source}) - file(READ "${source}" contents) - string(REGEX MATCHALL "${gtest_test_type_regex} *\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents}) - foreach(hit ${found_tests}) - string(REGEX MATCH "${gtest_test_type_regex}" test_type ${hit}) +# See :module:`GoogleTest` for information on the :command:`gtest_add_tests` +# command. - # Parameterized tests have a different signature for the filter - if("x${test_type}" STREQUAL "xTEST_P") - string(REGEX REPLACE ${gtest_case_name_regex} "*/\\1.\\2/*" test_name ${hit}) - elseif("x${test_type}" STREQUAL "xTEST_F" OR "x${test_type}" STREQUAL "xTEST") - string(REGEX REPLACE ${gtest_case_name_regex} "\\1.\\2" test_name ${hit}) - elseif("x${test_type}" STREQUAL "xTYPED_TEST") - string(REGEX REPLACE ${gtest_case_name_regex} "\\1/*.\\2" test_name ${hit}) - else() - message(WARNING "Could not parse GTest ${hit} for adding to CTest.") - continue() - endif() - add_test(NAME ${test_name} COMMAND ${executable} --gtest_filter=${test_name} ${extra_args}) - endforeach() - endforeach() -endfunction() +include(${CMAKE_CURRENT_LIST_DIR}/GoogleTest.cmake) function(_gtest_append_debugs _endvar _library) if(${_library} AND ${_library}_DEBUG) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 2a81da6..1e2ea69 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -59,12 +59,19 @@ # bindings, if the HL component is enabled # # Available components are: C CXX Fortran and HL. For each enabled language -# binding, a corresponding HDF5_${LANG}_LIBRARIES variable will be defined. +# binding, a corresponding HDF5_${LANG}_LIBRARIES variable, and potentially +# HDF5_${LANG}_DEFINITIONS, will be defined. # If the HL component is enabled, then an HDF5_${LANG}_HL_LIBRARIES will # also be defined. With all components enabled, the following variables will be defined: # # :: # +# HDF5_C_DEFINITIONS -- Required compiler definitions for HDF5 C bindings +# HDF5_CXX_DEFINITIONS -- Required compiler definitions for HDF5 C++ bindings +# HDF5_Fortran_DEFINITIONS -- Required compiler definitions for HDF5 Fortran bindings +# HDF5_C_INCLUDE_DIRS -- Required include directories for HDF5 C bindings +# HDF5_CXX_INCLUDE_DIRS -- Required include directories for HDF5 C++ bindings +# HDF5_Fortran_INCLUDE_DIRS -- Required include directories for HDF5 Fortran bindings # HDF5_C_LIBRARIES - Required libraries for the HDF5 C bindings # HDF5_CXX_LIBRARIES - Required libraries for the HDF5 C++ bindings # HDF5_Fortran_LIBRARIES - Required libraries for the HDF5 Fortran bindings @@ -92,6 +99,9 @@ # ``HDF5_ROOT`` # Specify the path to the HDF5 installation to use. # +# ``HDF5_FIND_DEBUG`` +# Set to a true value to get some extra debugging output. +# # ``HDF5_NO_FIND_PACKAGE_CONFIG_FILE`` # Set to a true value to skip trying to find ``hdf5-config.cmake``. @@ -400,15 +410,23 @@ if(NOT HDF5_FOUND AND NOT HDF5_NO_FIND_PACKAGE_CONFIG_FILE) ${_HDF5_SEARCH_OPTS} ) if( HDF5_FOUND) + if(HDF5_FIND_DEBUG) + message(STATUS "Found HDF5 at ${HDF5_DIR} via NO_MODULE. Now trying to extract locations etc.") + endif() set(HDF5_IS_PARALLEL ${HDF5_ENABLE_PARALLEL}) set(HDF5_INCLUDE_DIRS ${HDF5_INCLUDE_DIR}) set(HDF5_LIBRARIES) - set(HDF5_C_TARGET hdf5) - set(HDF5_C_HL_TARGET hdf5_hl) - set(HDF5_CXX_TARGET hdf5_cpp) - set(HDF5_CXX_HL_TARGET hdf5_hl_cpp) - set(HDF5_Fortran_TARGET hdf5_fortran) - set(HDF5_Fortran_HL_TARGET hdf5_hl_fortran) + if (NOT TARGET hdf5 AND NOT TARGET hdf5-static AND NOT TARGET hdf5-shared) + # Some HDF5 versions (e.g. 1.8.18) used hdf5::hdf5 etc + set(_target_prefix "hdf5::") + endif() + set(HDF5_C_TARGET ${_target_prefix}hdf5) + set(HDF5_C_HL_TARGET ${_target_prefix}hdf5_hl) + set(HDF5_CXX_TARGET ${_target_prefix}hdf5_cpp) + set(HDF5_CXX_HL_TARGET ${_target_prefix}hdf5_hl_cpp) + set(HDF5_Fortran_TARGET ${_target_prefix}hdf5_fortran) + set(HDF5_Fortran_HL_TARGET ${_target_prefix}hdf5_hl_fortran) + set(HDF5_DEFINITIONS "") if(HDF5_USE_STATIC_LIBRARIES) set(_suffix "-static") else() @@ -420,7 +438,7 @@ if(NOT HDF5_FOUND AND NOT HDF5_NO_FIND_PACKAGE_CONFIG_FILE) #if we detect that occurrence clear the suffix if(_suffix AND NOT TARGET ${HDF5_${_lang}_TARGET}${_suffix}) if(NOT TARGET ${HDF5_${_lang}_TARGET}) - #cant find this component with our without the suffix + #cant find this component with or without the suffix #so bail out, and let the following locate HDF5 set(HDF5_FOUND FALSE) break() @@ -428,21 +446,29 @@ if(NOT HDF5_FOUND AND NOT HDF5_NO_FIND_PACKAGE_CONFIG_FILE) set(_suffix "") endif() - get_target_property(_lang_location ${HDF5_${_lang}_TARGET}${_suffix} LOCATION) + if(HDF5_FIND_DEBUG) + message(STATUS "Trying to get properties of target ${HDF5_${_lang}_TARGET}${_suffix}") + endif() + # Find library for this target. Complicated as on Windows with a DLL, we need to search for the import-lib. + get_target_property(_imported_conf ${HDF5_${_lang}_TARGET}${_suffix} IMPORTED_CONFIGURATIONS) + get_target_property(_lang_location ${HDF5_${_lang}_TARGET}${_suffix} IMPORTED_IMPLIB_${_imported_conf} ) + if (NOT _lang_location) + # no import lib, just try LOCATION + get_target_property(_lang_location ${HDF5_${_lang}_TARGET}${_suffix} LOCATION) + endif() if( _lang_location ) - set(HDF5_${_lang}_LIBRARY ${_lang_location} CACHE PATH - "HDF5 ${_lang} library" ) - mark_as_advanced(HDF5_${_lang}_LIBRARY) + set(HDF5_${_lang}_LIBRARY ${_lang_location}) list(APPEND HDF5_LIBRARIES ${HDF5_${_lang}_TARGET}${_suffix}) set(HDF5_${_lang}_LIBRARIES ${HDF5_${_lang}_TARGET}${_suffix}) set(HDF5_${_lang}_FOUND True) endif() if(FIND_HL) - get_target_property(_lang_hl_location ${HDF5_${_lang}_HL_TARGET}${_suffix} LOCATION) + get_target_property(__lang_hl_location ${HDF5_${_lang}_HL_TARGET}${_suffix} IMPORTED_IMPLIB_${_imported_conf} ) + if (NOT _lang_hl_location) + get_target_property(_lang_hl_location ${HDF5_${_lang}_HL_TARGET}${_suffix} LOCATION) + endif() if( _lang_hl_location ) - set(HDF5_${_lang}_HL_LIBRARY ${_lang_hl_location} CACHE PATH - "HDF5 ${_lang} HL library" ) - mark_as_advanced(HDF5_${_lang}_HL_LIBRARY) + set(HDF5_${_lang}_HL_LIBRARY ${_lang_hl_location}) list(APPEND HDF5_HL_LIBRARIES ${HDF5_${_lang}_TARGET}${_suffix}) set(HDF5_${_lang}_HL_LIBRARIES ${HDF5_${_lang}_TARGET}${_suffix}) set(HDF5_HL_FOUND True) @@ -487,10 +513,6 @@ if(NOT HDF5_FOUND) set(HDF5_${__lang}_HL_LIBRARIES) mark_as_advanced(HDF5_${__lang}_COMPILER_EXECUTABLE_NO_INTERROGATE) - mark_as_advanced(HDF5_${__lang}_DEFINITIONS) - mark_as_advanced(HDF5_${__lang}_INCLUDE_DIRS) - mark_as_advanced(HDF5_${__lang}_LIBRARIES) - mark_as_advanced(HDF5_${__lang}_HL_LIBRARIES) set(HDF5_${__lang}_FOUND True) set(HDF5_HL_FOUND True) @@ -580,9 +602,6 @@ if(NOT HDF5_FOUND) endif() set(HDF5_${__lang}_FOUND True) - mark_as_advanced(HDF5_${__lang}_DEFINITIONS) - mark_as_advanced(HDF5_${__lang}_INCLUDE_DIRS) - mark_as_advanced(HDF5_${__lang}_LIBRARIES) _HDF5_remove_duplicates_from_beginning(HDF5_${__lang}_DEFINITIONS) _HDF5_remove_duplicates_from_beginning(HDF5_${__lang}_INCLUDE_DIRS) _HDF5_remove_duplicates_from_beginning(HDF5_${__lang}_LIBRARIES) @@ -685,6 +704,8 @@ if( NOT HDF5_FOUND ) ${_HDF5_SEARCH_OPTS} ) mark_as_advanced(HDF5_${__lang}_INCLUDE_DIR) + # set the _DIRS variable as this is what the user will normally use + set(HDF5_${__lang}_INCLUDE_DIRS ${HDF5_${__lang}_INCLUDE_DIR}) list(APPEND HDF5_INCLUDE_DIRS ${HDF5_${__lang}_INCLUDE_DIR}) # find the HDF5 libraries @@ -826,3 +847,23 @@ find_package_handle_standard_args(HDF5 ) unset(_HDF5_SEARCH_OPTS) + +if( HDF5_FOUND AND NOT HDF5_DIR) + # hide HDF5_DIR for the non-advanced user to avoid confusion with + # HDF5_DIR-NOT_FOUND while HDF5 was found. + mark_as_advanced(HDF5_DIR) +endif() + +if (HDF5_FIND_DEBUG) + message(STATUS "HDF5_DIR: ${HDF5_DIR}") + message(STATUS "HDF5_DEFINITIONS: ${HDF5_DEFINITIONS}") + message(STATUS "HDF5_INCLUDE_DIRS: ${HDF5_INCLUDE_DIRS}") + message(STATUS "HDF5_LIBRARIES: ${HDF5_LIBRARIES}") + foreach(__lang IN LISTS HDF5_LANGUAGE_BINDINGS) + message(STATUS "HDF5_${__lang}_DEFINITIONS: ${HDF5_${__lang}_DEFINITIONS}") + message(STATUS "HDF5_${__lang}_INCLUDE_DIR: ${HDF5_${__lang}_INCLUDE_DIR}") + message(STATUS "HDF5_${__lang}_INCLUDE_DIRS: ${HDF5_${__lang}_INCLUDE_DIRS}") + message(STATUS "HDF5_${__lang}_LIBRARY: ${HDF5_${__lang}_LIBRARY}") + message(STATUS "HDF5_${__lang}_LIBRARIES: ${HDF5_${__lang}_LIBRARIES}") + endforeach() +endif() diff --git a/Modules/FindIce.cmake b/Modules/FindIce.cmake index a61d4a8..e0286ee 100644 --- a/Modules/FindIce.cmake +++ b/Modules/FindIce.cmake @@ -198,7 +198,7 @@ function(_Ice_FIND) endif() # Generic 64-bit and 32-bit directories list(APPEND ice_binary_suffixes "bin${_x64}" "bin") - list(APPEND ice_library_suffixes "${_lib64}" "lib${_x64}" "lib") + list(APPEND ice_library_suffixes "libx32" "${_lib64}" "lib${_x64}" "lib") list(APPEND ice_include_suffixes "include") list(APPEND ice_slice_suffixes "slice") diff --git a/Modules/FindKDE3.cmake b/Modules/FindKDE3.cmake index 62e2a50..03216a5 100644 --- a/Modules/FindKDE3.cmake +++ b/Modules/FindKDE3.cmake @@ -221,6 +221,8 @@ get_filename_component(KDE3_LIB_DIR ${KDE3_KDECORE_LIBRARY} PATH ) if(NOT KDE3_LIBTOOL_DIR) if(KDE3_KDECORE_LIBRARY MATCHES lib64) set(KDE3_LIBTOOL_DIR /lib64/kde3) + elseif(KDE3_KDECORE_LIBRARY MATCHES libx32) + set(KDE3_LIBTOOL_DIR /libx32/kde3) else() set(KDE3_LIBTOOL_DIR /lib/kde3) endif() diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index ff2c4de..3e8be5b 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -29,6 +29,12 @@ # MPI_<lang>_LINK_FLAGS Linking flags for MPI programs # MPI_<lang>_LIBRARIES All libraries to link MPI programs against # +# Additionally, the following :prop_tgt:`IMPORTED` targets are defined: +# +# :: +# +# MPI::MPI_<lang> Target for using MPI from <lang> +# # Additionally, FindMPI sets the following variables for running MPI # programs from the command line: # @@ -621,6 +627,29 @@ foreach (lang C CXX Fortran) else() find_package_handle_standard_args(MPI_${lang} DEFAULT_MSG MPI_${lang}_LIBRARIES MPI_${lang}_INCLUDE_PATH) endif() + + if(MPI_${lang}_FOUND) + if(NOT TARGET MPI::MPI_${lang}) + add_library(MPI::MPI_${lang} INTERFACE IMPORTED) + endif() + if(MPI_${lang}_COMPILE_FLAGS) + set(_MPI_${lang}_COMPILE_OPTIONS "${MPI_${lang}_COMPILE_FLAGS}") + separate_arguments(_MPI_${lang}_COMPILE_OPTIONS) + set_property(TARGET MPI::MPI_${lang} PROPERTY + INTERFACE_COMPILE_OPTIONS "${_MPI_${lang}_COMPILE_OPTIONS}") + endif() + + unset(_MPI_${lang}_LINK_LINE) + if(MPI_${lang}_LINK_FLAGS) + list(APPEND _MPI_${lang}_LINK_LINE "${MPI_${lang}_LINK_FLAGS}") + endif() + list(APPEND _MPI_${lang}_LINK_LINE "${MPI_${lang}_LIBRARIES}") + set_property(TARGET MPI::MPI_${lang} PROPERTY + INTERFACE_LINK_LIBRARIES "${_MPI_${lang}_LINK_LINE}") + + set_property(TARGET MPI::MPI_${lang} PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${MPI_${lang}_INCLUDE_PATH}") + endif() endif() endforeach() @@ -660,6 +689,7 @@ if (MPI_NUMLIBS GREATER 1) else() set(MPI_EXTRA_LIBRARY "MPI_EXTRA_LIBRARY-NOTFOUND" CACHE STRING "Extra MPI libraries to link against" FORCE) endif() +mark_as_advanced(MPI_LIBRARY MPI_EXTRA_LIBRARY) #============================================================================= # unset these vars to cleanup namespace diff --git a/Modules/FindOpenAL.cmake b/Modules/FindOpenAL.cmake index 8622b4c..c3d202e 100644 --- a/Modules/FindOpenAL.cmake +++ b/Modules/FindOpenAL.cmake @@ -79,7 +79,7 @@ find_library(OPENAL_LIBRARY NAMES OpenAL al openal OpenAL32 HINTS ENV OPENALDIR - PATH_SUFFIXES lib64 lib libs64 libs ${_OpenAL_ARCH_DIR} + PATH_SUFFIXES libx32 lib64 lib libs64 libs ${_OpenAL_ARCH_DIR} PATHS ~/Library/Frameworks /Library/Frameworks diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake index 2ee9439..f399836 100644 --- a/Modules/FindOpenMP.cmake +++ b/Modules/FindOpenMP.cmake @@ -48,6 +48,7 @@ function(_OPENMP_FLAG_CANDIDATES LANG) #GNU "-fopenmp" #Clang + "-fopenmp=libiomp5" "-fopenmp=libomp" #Microsoft Visual Studio "/openmp" diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index 6259ce1..1209560 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -145,6 +145,7 @@ if(WIN32 AND NOT CYGWIN) find_library(LIB_EAY_DEBUG NAMES libcrypto${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d + libcrypto${_OPENSSL_MSVC_RT_MODE}d libcryptod libeay32${_OPENSSL_MSVC_RT_MODE}d libeay32d @@ -157,9 +158,11 @@ if(WIN32 AND NOT CYGWIN) find_library(LIB_EAY_RELEASE NAMES libcrypto${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE} + libcrypto${_OPENSSL_MSVC_RT_MODE} libcrypto libeay32${_OPENSSL_MSVC_RT_MODE} libeay32 + crypto NAMES_PER_DIR ${_OPENSSL_ROOT_HINTS_AND_PATHS} PATH_SUFFIXES @@ -169,6 +172,7 @@ if(WIN32 AND NOT CYGWIN) find_library(SSL_EAY_DEBUG NAMES libssl${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d + libssl${_OPENSSL_MSVC_RT_MODE}d libssld ssleay32${_OPENSSL_MSVC_RT_MODE}d ssleay32d @@ -181,6 +185,7 @@ if(WIN32 AND NOT CYGWIN) find_library(SSL_EAY_RELEASE NAMES libssl${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE} + libssl${_OPENSSL_MSVC_RT_MODE} libssl ssleay32${_OPENSSL_MSVC_RT_MODE} ssleay32 diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index 1958f4b..54572f0 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -312,6 +312,10 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma if(uselib64 AND CMAKE_SIZEOF_VOID_P EQUAL 8) list(APPEND _lib_dirs "lib64/pkgconfig") endif() + get_property(uselibx32 GLOBAL PROPERTY FIND_LIBRARY_USE_LIBX32_PATHS) + if(uselibx32 AND CMAKE_INTERNAL_PLATFORM_ABI STREQUAL "ELF X32") + list(APPEND _lib_dirs "libx32/pkgconfig") + endif() endif() endif() list(APPEND _lib_dirs "lib/pkgconfig") @@ -360,38 +364,25 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma set(_pkg_check_modules_pkg_ver) endif() - # handle the operands - if (_pkg_check_modules_pkg_op STREQUAL ">=") - list(APPEND _pkg_check_modules_exist_query --atleast-version) - endif() - - if (_pkg_check_modules_pkg_op STREQUAL "=") - list(APPEND _pkg_check_modules_exist_query --exact-version) - endif() + _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_VERSION) + _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_PREFIX) + _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_INCLUDEDIR) + _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_LIBDIR) - if (_pkg_check_modules_pkg_op STREQUAL "<=") - list(APPEND _pkg_check_modules_exist_query --max-version) - endif() + list(APPEND _pkg_check_modules_packages "${_pkg_check_modules_pkg_name}") # create the final query which is of the format: - # * --atleast-version <version> <pkg-name> - # * --exact-version <version> <pkg-name> - # * --max-version <version> <pkg-name> + # * <pkg-name> >= <version> + # * <pkg-name> = <version> + # * <pkg-name> <= <version> # * --exists <pkg-name> + list(APPEND _pkg_check_modules_exist_query --print-errors --short-errors) if (_pkg_check_modules_pkg_op) - list(APPEND _pkg_check_modules_exist_query "${_pkg_check_modules_pkg_ver}") + list(APPEND _pkg_check_modules_exist_query "${_pkg_check_modules_pkg_name} ${_pkg_check_modules_pkg_op} ${_pkg_check_modules_pkg_ver}") else() list(APPEND _pkg_check_modules_exist_query --exists) + list(APPEND _pkg_check_modules_exist_query "${_pkg_check_modules_pkg_name}") endif() - list(APPEND _pkg_check_modules_exist_query --print-errors --short-errors) - - _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_VERSION) - _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_PREFIX) - _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_INCLUDEDIR) - _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_LIBDIR) - - list(APPEND _pkg_check_modules_exist_query "${_pkg_check_modules_pkg_name}") - list(APPEND _pkg_check_modules_packages "${_pkg_check_modules_pkg_name}") # execute the query execute_process( diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake index 3ffd5a7..102ed42 100644 --- a/Modules/FindProtobuf.cmake +++ b/Modules/FindProtobuf.cmake @@ -20,6 +20,9 @@ # imported .proto files. # ``Protobuf_DEBUG`` # Show debug messages. +# ``Protobuf_USE_STATIC_LIBS`` +# Set to ON to force the use of the static libraries. +# Default is OFF. # # Defines the following variables: # @@ -218,6 +221,14 @@ function(PROTOBUF_GENERATE_PYTHON SRCS) set(${SRCS} ${${SRCS}} PARENT_SCOPE) endfunction() + +if(Protobuf_DEBUG) + # Output some of their choices + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "Protobuf_USE_STATIC_LIBS = ${Protobuf_USE_STATIC_LIBS}") +endif() + + # Backwards compatibility # Define camel case versions of input variables foreach(UPPER @@ -245,6 +256,17 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 8) set(_PROTOBUF_ARCH_DIR x64/) endif() + +# Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES +if( Protobuf_USE_STATIC_LIBS ) + set( _protobuf_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + if(WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + else() + set(CMAKE_FIND_LIBRARY_SUFFIXES .a ) + endif() +endif() + include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) # Internal function: search for normal library as well as a debug one @@ -399,6 +421,11 @@ if(Protobuf_FOUND) set(Protobuf_INCLUDE_DIRS ${Protobuf_INCLUDE_DIR}) endif() +# Restore the original find library ordering +if( Protobuf_USE_STATIC_LIBS ) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${_protobuf_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) +endif() + # Backwards compatibility # Define upper case versions of output variables foreach(Camel diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake index f255246..64b98a8 100644 --- a/Modules/FindPythonInterp.cmake +++ b/Modules/FindPythonInterp.cmake @@ -91,12 +91,15 @@ unset(_PYTHON3_VERSIONS) if(NOT PYTHON_EXECUTABLE) foreach(_CURRENT_VERSION IN LISTS _Python_VERSIONS) set(_Python_NAMES python${_CURRENT_VERSION}) - if(WIN32) + if(CMAKE_HOST_WIN32) list(APPEND _Python_NAMES python) endif() find_program(PYTHON_EXECUTABLE NAMES ${_Python_NAMES} - PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath] + PATHS + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath] + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-32\\InstallPath] + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-64\\InstallPath] ) endforeach() endif() diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake index bc906e5..af4daf0 100644 --- a/Modules/FindwxWidgets.cmake +++ b/Modules/FindwxWidgets.cmake @@ -893,6 +893,28 @@ else() endif() endif() +# Check that all libraries are present, as wx-config does not check it +set(_wx_lib_missing "") +foreach(_wx_lib_ ${wxWidgets_LIBRARIES}) + if("${_wx_lib_}" MATCHES "^-l(.*)") + set(_wx_lib_name "${CMAKE_MATCH_1}") + unset(_wx_lib_found CACHE) + find_library(_wx_lib_found NAMES ${_wx_lib_name} HINTS ${wxWidgets_LIBRARY_DIRS}) + if(_wx_lib_found STREQUAL _wx_lib_found-NOTFOUND) + list(APPEND _wx_lib_missing ${_wx_lib_name}) + endif() + unset(_wx_lib_found CACHE) + endif() +endforeach() + +if (_wx_lib_missing) + string(REPLACE ";" " " _wx_lib_missing "${_wx_lib_missing}") + DBG_MSG_V("wxWidgets not found due to following missing libraries: ${_wx_lib_missing}") + set(wxWidgets_FOUND FALSE) + unset(wxWidgets_LIBRARIES) +endif() +unset(_wx_lib_missing) + # Check if a specfic version was requested by find_package(). if(wxWidgets_FOUND) find_file(_filename wx/version.h PATHS ${wxWidgets_INCLUDE_DIRS} NO_DEFAULT_PATH) diff --git a/Modules/GNUInstallDirs.cmake b/Modules/GNUInstallDirs.cmake index 9599f27..64bd09e 100644 --- a/Modules/GNUInstallDirs.cmake +++ b/Modules/GNUInstallDirs.cmake @@ -45,6 +45,8 @@ # modifiable architecture-independent data (``com``) # ``LOCALSTATEDIR`` # modifiable single-machine data (``var``) +# ``RUNSTATEDIR`` +# run-time variable data (``LOCALSTATEDIR/run``) # ``LIBDIR`` # object code libraries (``lib`` or ``lib64`` # or ``lib/<multiarch-tuple>`` on Debian) @@ -75,10 +77,10 @@ # # ``/`` # -# For ``<dir>`` other than the ``SYSCONFDIR`` and ``LOCALSTATEDIR``, -# the value of ``CMAKE_INSTALL_<dir>`` is prefixed with ``usr/`` if -# it is not user-specified as an absolute path. For example, the -# ``INCLUDEDIR`` value ``include`` becomes ``usr/include``. +# For ``<dir>`` other than the ``SYSCONFDIR``, ``LOCALSTATEDIR`` and +# ``RUNSTATEDIR``, the value of ``CMAKE_INSTALL_<dir>`` is prefixed +# with ``usr/`` if it is not user-specified as an absolute path. +# For example, the ``INCLUDEDIR`` value ``include`` becomes ``usr/include``. # This is required by the `GNU Coding Standards`_, which state: # # When building the complete GNU system, the prefix will be empty @@ -86,20 +88,21 @@ # # ``/usr`` # -# For ``<dir>`` equal to ``SYSCONFDIR`` or ``LOCALSTATEDIR``, the -# ``CMAKE_INSTALL_FULL_<dir>`` is computed by prepending just ``/`` -# to the value of ``CMAKE_INSTALL_<dir>`` if it is not user-specified -# as an absolute path. For example, the ``SYSCONFDIR`` value ``etc`` -# becomes ``/etc``. This is required by the `GNU Coding Standards`_. +# For ``<dir>`` equal to ``SYSCONFDIR``, ``LOCALSTATEDIR`` or +# ``RUNSTATEDIR``, the ``CMAKE_INSTALL_FULL_<dir>`` is computed by +# prepending just ``/`` to the value of ``CMAKE_INSTALL_<dir>`` +# if it is not user-specified as an absolute path. +# For example, the ``SYSCONFDIR`` value ``etc`` becomes ``/etc``. +# This is required by the `GNU Coding Standards`_. # # ``/opt/...`` # -# For ``<dir>`` equal to ``SYSCONFDIR`` or ``LOCALSTATEDIR``, the -# ``CMAKE_INSTALL_FULL_<dir>`` is computed by *appending* the prefix -# to the value of ``CMAKE_INSTALL_<dir>`` if it is not user-specified -# as an absolute path. For example, the ``SYSCONFDIR`` value ``etc`` -# becomes ``/etc/opt/...``. This is defined by the -# `Filesystem Hierarchy Standard`_. +# For ``<dir>`` equal to ``SYSCONFDIR``, ``LOCALSTATEDIR`` or +# ``RUNSTATEDIR``, the ``CMAKE_INSTALL_FULL_<dir>`` is computed by +# *appending* the prefix to the value of ``CMAKE_INSTALL_<dir>`` +# if it is not user-specified as an absolute path. +# For example, the ``SYSCONFDIR`` value ``etc`` becomes ``/etc/opt/...``. +# This is defined by the `Filesystem Hierarchy Standard`_. # # .. _`Filesystem Hierarchy Standard`: https://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html # @@ -287,6 +290,9 @@ _GNUInstallDirs_cache_path_fallback(CMAKE_INSTALL_LOCALEDIR "${CMAKE_INSTALL_DAT _GNUInstallDirs_cache_path_fallback(CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME}" "Documentation root (DATAROOTDIR/doc/PROJECT_NAME)") +_GNUInstallDirs_cache_path_fallback(CMAKE_INSTALL_RUNSTATEDIR "${CMAKE_INSTALL_LOCALSTATEDIR}/run" + "Run-time variable data (LOCALSTATEDIR/run)") + #----------------------------------------------------------------------------- mark_as_advanced( @@ -296,6 +302,7 @@ mark_as_advanced( CMAKE_INSTALL_SYSCONFDIR CMAKE_INSTALL_SHAREDSTATEDIR CMAKE_INSTALL_LOCALSTATEDIR + CMAKE_INSTALL_RUNSTATEDIR CMAKE_INSTALL_LIBDIR CMAKE_INSTALL_INCLUDEDIR CMAKE_INSTALL_OLDINCLUDEDIR @@ -314,7 +321,7 @@ macro(GNUInstallDirs_get_absolute_install_dir absvar var) # - CMAKE_INSTALL_PREFIX == /usr # - CMAKE_INSTALL_PREFIX == /opt/... if("${CMAKE_INSTALL_PREFIX}" STREQUAL "/") - if("${dir}" STREQUAL "SYSCONFDIR" OR "${dir}" STREQUAL "LOCALSTATEDIR") + if("${dir}" STREQUAL "SYSCONFDIR" OR "${dir}" STREQUAL "LOCALSTATEDIR" OR "${dir}" STREQUAL "RUNSTATEDIR") set(${absvar} "/${${var}}") else() if (NOT "${${var}}" MATCHES "^usr/") @@ -323,13 +330,13 @@ macro(GNUInstallDirs_get_absolute_install_dir absvar var) set(${absvar} "/${${var}}") endif() elseif("${CMAKE_INSTALL_PREFIX}" MATCHES "^/usr/?$") - if("${dir}" STREQUAL "SYSCONFDIR" OR "${dir}" STREQUAL "LOCALSTATEDIR") + if("${dir}" STREQUAL "SYSCONFDIR" OR "${dir}" STREQUAL "LOCALSTATEDIR" OR "${dir}" STREQUAL "RUNSTATEDIR") set(${absvar} "/${${var}}") else() set(${absvar} "${CMAKE_INSTALL_PREFIX}/${${var}}") endif() elseif("${CMAKE_INSTALL_PREFIX}" MATCHES "^/opt/.*") - if("${dir}" STREQUAL "SYSCONFDIR" OR "${dir}" STREQUAL "LOCALSTATEDIR") + if("${dir}" STREQUAL "SYSCONFDIR" OR "${dir}" STREQUAL "LOCALSTATEDIR" OR "${dir}" STREQUAL "RUNSTATEDIR") set(${absvar} "/${${var}}${CMAKE_INSTALL_PREFIX}") else() set(${absvar} "${CMAKE_INSTALL_PREFIX}/${${var}}") @@ -351,6 +358,7 @@ foreach(dir SYSCONFDIR SHAREDSTATEDIR LOCALSTATEDIR + RUNSTATEDIR LIBDIR INCLUDEDIR OLDINCLUDEDIR diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 6d1b4ed..4573c2e 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -215,9 +215,6 @@ macro(_test_compiler_hidden_visibility) check_cxx_compiler_flag(-fvisibility=hidden COMPILER_HAS_HIDDEN_VISIBILITY) check_cxx_compiler_flag(-fvisibility-inlines-hidden COMPILER_HAS_HIDDEN_INLINE_VISIBILITY) - option(USE_COMPILER_HIDDEN_VISIBILITY - "Use HIDDEN visibility support if available." ON) - mark_as_advanced(USE_COMPILER_HIDDEN_VISIBILITY) endif() endmacro() @@ -267,7 +264,7 @@ macro(_DO_SET_MACRO_VALUES TARGET_LIBRARY) if(WIN32 OR CYGWIN) set(DEFINE_EXPORT "__declspec(dllexport)") set(DEFINE_IMPORT "__declspec(dllimport)") - elseif(COMPILER_HAS_HIDDEN_VISIBILITY AND USE_COMPILER_HIDDEN_VISIBILITY) + elseif(COMPILER_HAS_HIDDEN_VISIBILITY) set(DEFINE_EXPORT "__attribute__((visibility(\"default\")))") set(DEFINE_IMPORT "__attribute__((visibility(\"default\")))") set(DEFINE_NO_EXPORT "__attribute__((visibility(\"hidden\")))") @@ -388,6 +385,9 @@ function(add_compiler_export_flags) _test_compiler_hidden_visibility() _test_compiler_has_deprecated() + option(USE_COMPILER_HIDDEN_VISIBILITY + "Use HIDDEN visibility support if available." ON) + mark_as_advanced(USE_COMPILER_HIDDEN_VISIBILITY) if(NOT (USE_COMPILER_HIDDEN_VISIBILITY AND COMPILER_HAS_HIDDEN_VISIBILITY)) # Just return if there are no flags to add. return() diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake index 1b23800..a3b97ab 100644 --- a/Modules/GetPrerequisites.cmake +++ b/Modules/GetPrerequisites.cmake @@ -399,6 +399,11 @@ function(gp_resolve_item context item exepath dirs resolved_item_var) set(ri "ri-NOTFOUND") find_file(ri "${item}" ${exepath} ${dirs} NO_DEFAULT_PATH) find_file(ri "${item}" ${exepath} ${dirs} /usr/lib) + + get_filename_component(basename_item "${item}" NAME) + find_file(ri "${basename_item}" PATHS ${exepath} ${dirs} NO_DEFAULT_PATH) + find_file(ri "${basename_item}" PATHS /usr/lib) + if(ri) #message(STATUS "info: 'find_file' in exepath/dirs (${ri})") set(resolved 1) @@ -516,7 +521,7 @@ function(gp_resolved_file_type original_file file exepath dirs type_var) string(TOLOWER "${resolved_file}" lower) if(UNIX) - if(resolved_file MATCHES "^(/lib/|/lib32/|/lib64/|/usr/lib/|/usr/lib32/|/usr/lib64/|/usr/X11R6/|/usr/bin/)") + if(resolved_file MATCHES "^(/lib/|/lib32/|/libx32/|/lib64/|/usr/lib/|/usr/lib32/|/usr/libx32/|/usr/lib64/|/usr/X11R6/|/usr/bin/)") set(is_system 1) endif() endif() diff --git a/Modules/GoogleTest.cmake b/Modules/GoogleTest.cmake new file mode 100644 index 0000000..91a3a25 --- /dev/null +++ b/Modules/GoogleTest.cmake @@ -0,0 +1,73 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +GoogleTest +---------- + +This module defines functions to help use the Google Test infrastructure. + +.. command:: gtest_add_tests + + Automatically add tests with CTest by scanning source code for Google test + macros. + + :: + + gtest_add_tests(<exe> <args> <files>...) + + ``<exe>`` + The path to the test executable. + ``<args>`` + A ;-list of extra arguments to be passed to executable. The entire + list must be passed as a single argument. Enclose it in quotes, + or pass ``""`` for no arguments. + ``<files>...`` + A list of source files to search for tests and test fixtures. + Alternatively, use ``AUTO`` to specify that ``<exe>`` is the name + of a CMake executable target whose sources should be scanned. + +Example +^^^^^^^ + +.. code-block:: cmake + + include(GoogleTest) + set(FooTestArgs --foo 1 --bar 2) + add_executable(FooTest FooUnitTest.cc) + gtest_add_tests(FooTest "${FooTestArgs}" AUTO) + +#]=======================================================================] + +function(gtest_add_tests executable extra_args) + if(NOT ARGN) + message(FATAL_ERROR "Missing ARGN: Read the documentation for GTEST_ADD_TESTS") + endif() + if(ARGN STREQUAL "AUTO") + # obtain sources used for building that executable + get_property(ARGN TARGET ${executable} PROPERTY SOURCES) + endif() + set(gtest_case_name_regex ".*\\( *([A-Za-z_0-9]+) *, *([A-Za-z_0-9]+) *\\).*") + set(gtest_test_type_regex "(TYPED_TEST|TEST_?[FP]?)") + foreach(source ${ARGN}) + set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${source}) + file(READ "${source}" contents) + string(REGEX MATCHALL "${gtest_test_type_regex} *\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents}) + foreach(hit ${found_tests}) + string(REGEX MATCH "${gtest_test_type_regex}" test_type ${hit}) + + # Parameterized tests have a different signature for the filter + if("x${test_type}" STREQUAL "xTEST_P") + string(REGEX REPLACE ${gtest_case_name_regex} "*/\\1.\\2/*" test_name ${hit}) + elseif("x${test_type}" STREQUAL "xTEST_F" OR "x${test_type}" STREQUAL "xTEST") + string(REGEX REPLACE ${gtest_case_name_regex} "\\1.\\2" test_name ${hit}) + elseif("x${test_type}" STREQUAL "xTYPED_TEST") + string(REGEX REPLACE ${gtest_case_name_regex} "\\1/*.\\2" test_name ${hit}) + else() + message(WARNING "Could not parse GTest ${hit} for adding to CTest.") + continue() + endif() + add_test(NAME ${test_name} COMMAND ${executable} --gtest_filter=${test_name} ${extra_args}) + endforeach() + endforeach() +endfunction() diff --git a/Modules/InstallRequiredSystemLibraries.cmake b/Modules/InstallRequiredSystemLibraries.cmake index a3478a3..6d33fc6 100644 --- a/Modules/InstallRequiredSystemLibraries.cmake +++ b/Modules/InstallRequiredSystemLibraries.cmake @@ -31,6 +31,11 @@ # app-local deployment (e.g. to Windows XP). This is meaningful # only with MSVC from Visual Studio 2015 or higher. # +# One may set a ``CMAKE_WINDOWS_KITS_10_DIR`` *environment variable* +# to an absolute path to tell CMake to look for Windows 10 SDKs in +# a custom location. The specified directory is expected to contain +# ``Redist/ucrt/DLLs/*`` directories. +# # ``CMAKE_INSTALL_MFC_LIBRARIES`` # Set to TRUE to install the MSVC MFC runtime libraries. # @@ -258,6 +263,7 @@ if(MSVC) set(programfilesx86 "ProgramFiles(x86)") find_path(WINDOWS_KITS_DIR NAMES Redist/ucrt/DLLs/${CMAKE_MSVC_ARCH}/ucrtbase.dll PATHS + $ENV{CMAKE_WINDOWS_KITS_10_DIR} "${windows_kits_dir}" "$ENV{ProgramFiles}/Windows Kits/10" "$ENV{${programfilesx86}}/Windows Kits/10" diff --git a/Modules/MacOSXBundleInfo.plist.in b/Modules/MacOSXBundleInfo.plist.in index a4009bc..e06b17e 100644 --- a/Modules/MacOSXBundleInfo.plist.in +++ b/Modules/MacOSXBundleInfo.plist.in @@ -30,5 +30,9 @@ <true/> <key>NSHumanReadableCopyright</key> <string>${MACOSX_BUNDLE_COPYRIGHT}</string> + <key>NSPrincipalClass</key> + <string>NSApplication</string> + <key>NSHighResolutionCapable</key> + <string>True</string> </dict> </plist> diff --git a/Modules/Platform/CYGWIN.cmake b/Modules/Platform/CYGWIN.cmake index 22816e7..9b897bd 100644 --- a/Modules/Platform/CYGWIN.cmake +++ b/Modules/Platform/CYGWIN.cmake @@ -62,3 +62,13 @@ set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a" ".a") set(CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION 1) include(Platform/UnixPaths) + +# Windows API on Cygwin +list(APPEND CMAKE_SYSTEM_INCLUDE_PATH + /usr/include/w32api + ) + +# Windows API on Cygwin +list(APPEND CMAKE_SYSTEM_LIBRARY_PATH + /usr/lib/w32api + ) diff --git a/Modules/Platform/Linux-GNU.cmake b/Modules/Platform/Linux-GNU.cmake index 6878254..ce30a26 100644 --- a/Modules/Platform/Linux-GNU.cmake +++ b/Modules/Platform/Linux-GNU.cmake @@ -12,4 +12,5 @@ macro(__linux_compiler_gnu lang) # We pass this for historical reasons. Projects may have # executables that use dlopen but do not set ENABLE_EXPORTS. set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-rdynamic") + set(CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "${CMAKE_${lang}_COMPILER}" "-dM" "-E" "-c" "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp") endmacro() diff --git a/Modules/Platform/Linux-Intel.cmake b/Modules/Platform/Linux-Intel.cmake index 85a0772..6e2978a 100644 --- a/Modules/Platform/Linux-Intel.cmake +++ b/Modules/Platform/Linux-Intel.cmake @@ -30,12 +30,18 @@ macro(__linux_compiler_intel lang) # executables that use dlopen but do not set ENABLE_EXPORTS. set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-rdynamic") + set(_CMAKE_IPO_SUPPORTED_BY_CMAKE YES) + if(XIAR) # INTERPROCEDURAL_OPTIMIZATION set(CMAKE_${lang}_COMPILE_OPTIONS_IPO -ipo) set(CMAKE_${lang}_CREATE_STATIC_LIBRARY_IPO "${XIAR} cr <TARGET> <LINK_FLAGS> <OBJECTS> " "${XIAR} -s <TARGET> ") + set(_CMAKE_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES) + set(_CMAKE_IPO_LEGACY_BEHAVIOR YES) + else() + set(_CMAKE_IPO_MAY_BE_SUPPORTED_BY_COMPILER NO) endif() if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 12.0) diff --git a/Modules/Platform/Linux-TinyCC-C.cmake b/Modules/Platform/Linux-TinyCC-C.cmake index f78e708..9409d8b 100644 --- a/Modules/Platform/Linux-TinyCC-C.cmake +++ b/Modules/Platform/Linux-TinyCC-C.cmake @@ -2,3 +2,4 @@ set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "") set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP "") set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "") set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-soname ") +set(CMAKE_EXE_EXPORTS_C_FLAG "-rdynamic ") diff --git a/Modules/Platform/SunOS.cmake b/Modules/Platform/SunOS.cmake index 58398c0..e19e89a 100644 --- a/Modules/Platform/SunOS.cmake +++ b/Modules/Platform/SunOS.cmake @@ -9,6 +9,11 @@ endif() include(Platform/UnixPaths) +list(APPEND CMAKE_SYSTEM_PREFIX_PATH + /opt/csw + /opt/openwin + ) + # The Sun linker needs to find transitive shared library dependencies # in the -L path. set(CMAKE_LINK_DEPENDENT_LIBRARY_DIRS 1) diff --git a/Modules/Platform/UnixPaths.cmake b/Modules/Platform/UnixPaths.cmake index b216d03..5687653 100644 --- a/Modules/Platform/UnixPaths.cmake +++ b/Modules/Platform/UnixPaths.cmake @@ -41,35 +41,22 @@ if (NOT CMAKE_FIND_NO_INSTALL_PREFIX) endif() endif() +# Non "standard" but common install prefixes +list(APPEND CMAKE_SYSTEM_PREFIX_PATH + /usr/X11R6 + /usr/pkg + /opt + ) + # List common include file locations not under the common prefixes. list(APPEND CMAKE_SYSTEM_INCLUDE_PATH - # Windows API on Cygwin - /usr/include/w32api - # X11 - /usr/X11R6/include /usr/include/X11 - - # Other - /usr/pkg/include - /opt/csw/include /opt/include - /usr/openwin/include + /usr/include/X11 ) list(APPEND CMAKE_SYSTEM_LIBRARY_PATH - # Windows API on Cygwin - /usr/lib/w32api - # X11 - /usr/X11R6/lib /usr/lib/X11 - - # Other - /usr/pkg/lib - /opt/csw/lib /opt/lib - /usr/openwin/lib - ) - -list(APPEND CMAKE_SYSTEM_PROGRAM_PATH - /usr/pkg/bin + /usr/lib/X11 ) list(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES @@ -86,3 +73,4 @@ list(APPEND CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES # Enable use of lib32 and lib64 search path variants by default. set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS TRUE) set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE) +set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIBX32_PATHS TRUE) diff --git a/Modules/Platform/Windows-df.cmake b/Modules/Platform/Windows-df.cmake index b31cb11..c59be45 100644 --- a/Modules/Platform/Windows-df.cmake +++ b/Modules/Platform/Windows-df.cmake @@ -30,7 +30,7 @@ set(CMAKE_Fortran_LINK_EXECUTABLE set(CMAKE_CREATE_WIN32_EXE /winapp) set(CMAKE_CREATE_CONSOLE_EXE ) -if(CMAKE_GENERATOR MATCHES "Visual Studio 7" OR CMAKE_GENERATOR MATCHES "Visual Studio 8") +if(CMAKE_GENERATOR MATCHES "Visual Studio 8") set (CMAKE_NO_BUILD_TYPE 1) endif() # does the compiler support pdbtype and is it the newer compiler diff --git a/Modules/TestBigEndian.cmake b/Modules/TestBigEndian.cmake index 085be22..cc627d0 100644 --- a/Modules/TestBigEndian.cmake +++ b/Modules/TestBigEndian.cmake @@ -19,21 +19,29 @@ macro(TEST_BIG_ENDIAN VARIABLE) message(STATUS "Check if the system is big endian") message(STATUS "Searching 16 bit integer") + if(CMAKE_C_COMPILER_LOADED) + set(_test_language "C") + elseif(CMAKE_CXX_COMPILER_LOADED) + set(_test_language "CXX") + else() + message(FATAL_ERROR "TEST_BIG_ENDIAN needs either C or CXX language enabled") + endif() + include(CheckTypeSize) - CHECK_TYPE_SIZE("unsigned short" CMAKE_SIZEOF_UNSIGNED_SHORT) + CHECK_TYPE_SIZE("unsigned short" CMAKE_SIZEOF_UNSIGNED_SHORT LANGUAGE ${_test_language}) if(CMAKE_SIZEOF_UNSIGNED_SHORT EQUAL 2) message(STATUS "Using unsigned short") set(CMAKE_16BIT_TYPE "unsigned short") else() - CHECK_TYPE_SIZE("unsigned int" CMAKE_SIZEOF_UNSIGNED_INT) + CHECK_TYPE_SIZE("unsigned int" CMAKE_SIZEOF_UNSIGNED_INT LANGUAGE ${_test_language}) if(CMAKE_SIZEOF_UNSIGNED_INT) message(STATUS "Using unsigned int") set(CMAKE_16BIT_TYPE "unsigned int") else() - CHECK_TYPE_SIZE("unsigned long" CMAKE_SIZEOF_UNSIGNED_LONG) + CHECK_TYPE_SIZE("unsigned long" CMAKE_SIZEOF_UNSIGNED_LONG LANGUAGE ${_test_language}) if(CMAKE_SIZEOF_UNSIGNED_LONG) message(STATUS "Using unsigned long") set(CMAKE_16BIT_TYPE "unsigned long") @@ -45,17 +53,21 @@ macro(TEST_BIG_ENDIAN VARIABLE) endif() + if(_test_language STREQUAL "CXX") + set(_test_file "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/TestEndianess.cpp") + else() + set(_test_file "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/TestEndianess.c") + endif() configure_file("${CMAKE_ROOT}/Modules/TestEndianess.c.in" - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/TestEndianess.c" + ${_test_file} @ONLY) - file(READ "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/TestEndianess.c" - TEST_ENDIANESS_FILE_CONTENT) + file(READ ${_test_file} TEST_ENDIANESS_FILE_CONTENT) try_compile(HAVE_${VARIABLE} "${CMAKE_BINARY_DIR}" - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/TestEndianess.c" + ${_test_file} OUTPUT_VARIABLE OUTPUT COPY_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestEndianess.bin" ) diff --git a/Modules/WriteCompilerDetectionHeader.cmake b/Modules/WriteCompilerDetectionHeader.cmake index 0b16aa4..362099e 100644 --- a/Modules/WriteCompilerDetectionHeader.cmake +++ b/Modules/WriteCompilerDetectionHeader.cmake @@ -503,10 +503,19 @@ function(write_compiler_detection_header if (feature STREQUAL cxx_static_assert) set(def_value "${prefix_arg}_STATIC_ASSERT(X)") set(def_value_msg "${prefix_arg}_STATIC_ASSERT_MSG(X, MSG)") - set(static_assert_struct "template<bool> struct ${prefix_arg}StaticAssert;\ntemplate<> struct ${prefix_arg}StaticAssert<true>{};\n") - set(def_standard "# define ${def_value} static_assert(X, #X)\n# define ${def_value_msg} static_assert(X, MSG)") - set(def_alternative "${static_assert_struct}# define ${def_value} sizeof(${prefix_arg}StaticAssert<X>)\n# define ${def_value_msg} sizeof(${prefix_arg}StaticAssert<X>)") - string(APPEND file_content "# if defined(${def_name}) && ${def_name}\n${def_standard}\n# else\n${def_alternative}\n# endif\n\n") + set(def_fallback "enum { ${prefix_arg}_STATIC_ASSERT_JOIN(${prefix_arg}StaticAssertEnum, __LINE__) = sizeof(${prefix_arg}StaticAssert<X>) }") + string(APPEND file_content "# if defined(${def_name}) && ${def_name} +# define ${def_value} static_assert(X, #X) +# define ${def_value_msg} static_assert(X, MSG) +# else +# define ${prefix_arg}_STATIC_ASSERT_JOIN(X, Y) ${prefix_arg}_STATIC_ASSERT_JOIN_IMPL(X, Y) +# define ${prefix_arg}_STATIC_ASSERT_JOIN_IMPL(X, Y) X##Y +template<bool> struct ${prefix_arg}StaticAssert; +template<> struct ${prefix_arg}StaticAssert<true>{}; +# define ${def_value} ${def_fallback} +# define ${def_value_msg} ${def_fallback} +# endif +\n") endif() if (feature STREQUAL cxx_alignas) set(def_value "${prefix_arg}_ALIGNAS(X)") |