diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2022-01-16 14:36:23 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2022-01-19 09:49:23 (GMT) |
commit | 4fa105d34ebc8f757f89cf81b746aae6f43605a1 (patch) | |
tree | 0ec82ec29f6780ad23c49232552aa06e97f5123c /Modules | |
parent | 58804d1e58ff3aa6f3b473f8b4739ac7dc547e6a (diff) | |
download | CMake-4fa105d34ebc8f757f89cf81b746aae6f43605a1.zip CMake-4fa105d34ebc8f757f89cf81b746aae6f43605a1.tar.gz CMake-4fa105d34ebc8f757f89cf81b746aae6f43605a1.tar.bz2 |
Check{Compiler,Linker}Flag: Add possibility to retrieve check outputs
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/Internal/CheckCompilerFlag.cmake | 8 | ||||
-rw-r--r-- | Modules/Internal/CheckLinkerFlag.cmake | 8 | ||||
-rw-r--r-- | Modules/Internal/CheckSourceCompiles.cmake | 9 |
3 files changed, 24 insertions, 1 deletions
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) |