diff options
author | Brad King <brad.king@kitware.com> | 2022-01-20 17:01:07 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-01-20 17:01:14 (GMT) |
commit | 74eb6c53167f7bd9ebe3ef29bac745ff83758527 (patch) | |
tree | bbfd9e80af6afca30e03930cd5eb8ab25b5c3ba8 /Modules | |
parent | 8d8a7e0fbe62ca494f16f521bc6a6063428b2905 (diff) | |
parent | 219dde4ea8469a9dea7fddbf5c8b8f0bfc875514 (diff) | |
download | CMake-74eb6c53167f7bd9ebe3ef29bac745ff83758527.zip CMake-74eb6c53167f7bd9ebe3ef29bac745ff83758527.tar.gz CMake-74eb6c53167f7bd9ebe3ef29bac745ff83758527.tar.bz2 |
Merge topic 'CheckPIESUpported-supports-SYSROOT'
219dde4ea8 CheckPIESupported: now uses any SYSROOT settings
4fa105d34e Check{Compiler,Linker}Flag: Add possibility to retrieve check outputs
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !6877
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CheckPIESupported.cmake | 26 | ||||
-rw-r--r-- | Modules/Internal/CheckCompilerFlag.cmake | 8 | ||||
-rw-r--r-- | Modules/Internal/CheckLinkerFlag.cmake | 8 | ||||
-rw-r--r-- | Modules/Internal/CheckSourceCompiles.cmake | 9 |
4 files changed, 40 insertions, 11 deletions
diff --git a/Modules/CheckPIESupported.cmake b/Modules/CheckPIESupported.cmake index fb87822..5919d4b 100644 --- a/Modules/CheckPIESupported.cmake +++ b/Modules/CheckPIESupported.cmake @@ -25,7 +25,8 @@ property for executables will be honored at link time. Set ``<output>`` variable with details about any error. ``LANGUAGES <lang>...`` Check the linkers used for each of the specified languages. - Supported languages are ``C``, ``CXX``, and ``Fortran``. + Supported languages are ``C``, ``CXX``, ``OBJC``, ``OBJCXX``, ``Fortran``, + ``CUDA``, and ``HIP``. It makes no sense to use this module when :policy:`CMP0083` is set to ``OLD``, so the command will return an error in this case. See policy :policy:`CMP0083` @@ -62,7 +63,7 @@ Examples #]=======================================================================] -include (Internal/CMakeTryCompilerOrLinkerFlag) +include (Internal/CheckLinkerFlag) function (check_pie_supported) cmake_policy(GET CMP0083 cmp0083) @@ -86,7 +87,7 @@ function (check_pie_supported) if (CHECK_PIE_LANGUAGES) set (unsupported_languages "${CHECK_PIE_LANGUAGES}") - list (REMOVE_ITEM unsupported_languages "C" "CXX" "Fortran") + list (REMOVE_ITEM unsupported_languages "C" "CXX" "OBJC" "OBJCXX" "Fortran" "CUDA" "HIP") if(unsupported_languages) message(FATAL_ERROR "check_pie_supported: language(s) '${unsupported_languages}' not supported") endif() @@ -97,7 +98,7 @@ function (check_pie_supported) return() endif() - list (FILTER enabled_languages INCLUDE REGEX "^(C|CXX|Fortran)$") + list (FILTER enabled_languages INCLUDE REGEX "^(C|CXX|OBJC|OBJCXX|Fortran|CUDA|HIP)$") if (NOT enabled_languages) return() endif() @@ -105,24 +106,29 @@ function (check_pie_supported) set (CHECK_PIE_LANGUAGES ${enabled_languages}) endif() + set(CMAKE_REQUIRED_QUIET TRUE) set (outputs) foreach(lang IN LISTS CHECK_PIE_LANGUAGES) if(_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER) - cmake_try_compiler_or_linker_flag(${lang} + if(NOT DEFINED CMAKE_${lang}_LINK_PIE_SUPPORTED) + cmake_check_linker_flag(${lang} "${CMAKE_${lang}_LINK_OPTIONS_PIE}" CMAKE_${lang}_LINK_PIE_SUPPORTED OUTPUT_VARIABLE output) - if (NOT CMAKE_${lang}_LINK_PIE_SUPPORTED) - string (APPEND outputs "PIE (${lang}): ${output}\n") + if (NOT CMAKE_${lang}_LINK_PIE_SUPPORTED) + string (APPEND outputs "PIE (${lang}): ${output}\n") + endif() endif() - cmake_try_compiler_or_linker_flag(${lang} + if(NOT DEFINED CMAKE_${lang}_LINK_NO_PIE_SUPPORTED) + cmake_check_linker_flag(${lang} "${CMAKE_${lang}_LINK_OPTIONS_NO_PIE}" CMAKE_${lang}_LINK_NO_PIE_SUPPORTED OUTPUT_VARIABLE output) - if (NOT CMAKE_${lang}_LINK_NO_PIE_SUPPORTED) - string (APPEND outputs "NO_PIE (${lang}): ${output}\n") + if (NOT CMAKE_${lang}_LINK_NO_PIE_SUPPORTED) + string (APPEND outputs "NO_PIE (${lang}): ${output}\n") + endif() endif() else() # no support at link time. Set cache variables to NO diff --git a/Modules/Internal/CheckCompilerFlag.cmake b/Modules/Internal/CheckCompilerFlag.cmake index 3a67691..910f426 100644 --- a/Modules/Internal/CheckCompilerFlag.cmake +++ b/Modules/Internal/CheckCompilerFlag.cmake @@ -7,6 +7,9 @@ include(Internal/CheckSourceCompiles) include(CMakeCheckCompilerFlagCommonPatterns) function(CMAKE_CHECK_COMPILER_FLAG _lang _flag _var) + # Parse extra arguments + cmake_parse_arguments(PARSE_ARGV 3 CHECK_COMPILER_FLAG "" "OUTPUT_VARIABLE" "") + cmake_check_flag_common_init("check_compiler_flag" ${_lang} _lang_src _lang_fail_regex) set(CMAKE_REQUIRED_DEFINITIONS ${_flag}) @@ -17,7 +20,12 @@ function(CMAKE_CHECK_COMPILER_FLAG _lang _flag _var) ${_var} ${_lang_fail_regex} ${_common_patterns} + OUTPUT_VARIABLE _output ) + if (CHECK_COMPILER_FLAG_OUTPUT_VARIABLE) + set(${CHECK_COMPILER_FLAG_OUTPUT_VARIABLE} "${_output}" PARENT_SCOPE) + endif() + cmake_check_flag_common_finish() endfunction() diff --git a/Modules/Internal/CheckLinkerFlag.cmake b/Modules/Internal/CheckLinkerFlag.cmake index 285372a..51d4225 100644 --- a/Modules/Internal/CheckLinkerFlag.cmake +++ b/Modules/Internal/CheckLinkerFlag.cmake @@ -17,6 +17,9 @@ function(CMAKE_CHECK_LINKER_FLAG _lang _flag _var) return() endif() + # Parse extra arguments + cmake_parse_arguments(PARSE_ARGV 3 CHECK_LINKER_FLAG "" "OUTPUT_VARIABLE" "") + cmake_check_flag_common_init("check_linker_flag" ${_lang} _lang_src _lang_fail_regex) set(CMAKE_REQUIRED_LINK_OPTIONS "${_flag}") @@ -27,8 +30,13 @@ function(CMAKE_CHECK_LINKER_FLAG _lang _flag _var) ${_var} ${_lang_fail_regex} ${_common_patterns} + OUTPUT_VARIABLE _output ) + if (CHECK_LINKER_FLAG_OUTPUT_VARIABLE) + set(${CHECK_LINKER_FLAG_OUTPUT_VARIABLE} "${_output}" PARENT_SCOPE) + endif() + cmake_check_flag_common_finish() endfunction() diff --git a/Modules/Internal/CheckSourceCompiles.cmake b/Modules/Internal/CheckSourceCompiles.cmake index 8c3a418..27aa3e0 100644 --- a/Modules/Internal/CheckSourceCompiles.cmake +++ b/Modules/Internal/CheckSourceCompiles.cmake @@ -49,13 +49,16 @@ function(CMAKE_CHECK_SOURCE_COMPILES _lang _source _var) set(_SRC_EXT) set(_key) foreach(arg ${ARGN}) - if("${arg}" MATCHES "^(FAIL_REGEX|SRC_EXT)$") + if("${arg}" MATCHES "^(FAIL_REGEX|SRC_EXT|OUTPUT_VARIABLE)$") set(_key "${arg}") elseif(_key STREQUAL "FAIL_REGEX") list(APPEND _FAIL_REGEX "${arg}") elseif(_key STREQUAL "SRC_EXT") set(_SRC_EXT "${arg}") set(_key "") + elseif(_key STREQUAL "OUTPUT_VARIABLE") + set(_OUTPUT_VARIABLE "${arg}") + set(_key "") else() message(FATAL_ERROR "Unknown argument:\n ${arg}\n") endif() @@ -105,6 +108,10 @@ function(CMAKE_CHECK_SOURCE_COMPILES _lang _source _var) endif() endforeach() + if (_OUTPUT_VARIABLE) + set(${_OUTPUT_VARIABLE} "${OUTPUT}" PARENT_SCOPE) + endif() + if(${_var}) set(${_var} 1 CACHE INTERNAL "Test ${_var}") if(NOT CMAKE_REQUIRED_QUIET) |