diff options
author | Alexander Grund <alexander.grund@tu-dresden.de> | 2019-12-09 14:49:31 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-12-09 19:15:42 (GMT) |
commit | cb984c66272f44d27e622e4a2c35f2ae7061d042 (patch) | |
tree | b6eabc0bad0b69ba8487884667f7cad7ebc13a2c /Modules/CheckCXXCompilerFlag.cmake | |
parent | d806263578278e1b9566e086ccceecaefd324106 (diff) | |
download | CMake-cb984c66272f44d27e622e4a2c35f2ae7061d042.zip CMake-cb984c66272f44d27e622e4a2c35f2ae7061d042.tar.gz CMake-cb984c66272f44d27e622e4a2c35f2ae7061d042.tar.bz2 |
Check*CompilerFlag: Modernize modules
- User lower-case names
- Wrap in function instead of macro to avoid set-unset calls
- Use IN LISTS for foreach
Diffstat (limited to 'Modules/CheckCXXCompilerFlag.cmake')
-rw-r--r-- | Modules/CheckCXXCompilerFlag.cmake | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/Modules/CheckCXXCompilerFlag.cmake b/Modules/CheckCXXCompilerFlag.cmake index 5729843..5e07c25 100644 --- a/Modules/CheckCXXCompilerFlag.cmake +++ b/Modules/CheckCXXCompilerFlag.cmake @@ -36,28 +36,23 @@ include_guard(GLOBAL) include(CheckCXXSourceCompiles) include(CMakeCheckCompilerFlagCommonPatterns) -macro (CHECK_CXX_COMPILER_FLAG _FLAG _RESULT) - set(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}") - set(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}") +function(check_cxx_compiler_flag _flag _var) + set(CMAKE_REQUIRED_DEFINITIONS "${_flag}") # Normalize locale during test compilation. - set(_CheckCXXCompilerFlag_LOCALE_VARS LC_ALL LC_MESSAGES LANG) - foreach(v ${_CheckCXXCompilerFlag_LOCALE_VARS}) - set(_CheckCXXCompilerFlag_SAVED_${v} "$ENV{${v}}") + set(_locale_vars LC_ALL LC_MESSAGES LANG) + foreach(v IN LISTS _locale_vars) + set(_locale_vars_saved_${v} "$ENV{${v}}") set(ENV{${v}} C) endforeach() - CHECK_COMPILER_FLAG_COMMON_PATTERNS(_CheckCXXCompilerFlag_COMMON_PATTERNS) - CHECK_CXX_SOURCE_COMPILES("int main() { return 0; }" ${_RESULT} + check_compiler_flag_common_patterns(_common_patterns) + check_cxx_source_compiles("int main() { return 0; }" ${_var} # Some compilers do not fail with a bad flag FAIL_REGEX "command line option .* is valid for .* but not for C\\\\+\\\\+" # GNU - ${_CheckCXXCompilerFlag_COMMON_PATTERNS} + ${_common_patterns} ) - foreach(v ${_CheckCXXCompilerFlag_LOCALE_VARS}) - set(ENV{${v}} ${_CheckCXXCompilerFlag_SAVED_${v}}) - unset(_CheckCXXCompilerFlag_SAVED_${v}) + foreach(v IN LISTS _locale_vars) + set(ENV{${v}} ${_locale_vars_saved_${v}}) endforeach() - unset(_CheckCXXCompilerFlag_LOCALE_VARS) - unset(_CheckCXXCompilerFlag_COMMON_PATTERNS) - - set (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}") -endmacro () + set(${_var} "${${_var}}" PARENT_SCOPE) +endfunction() |