diff options
author | Brad King <brad.king@kitware.com> | 2020-09-29 09:44:54 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-09-29 09:45:07 (GMT) |
commit | 0021d24fb3fa8ca6ec16f5b6f44952cc375d499f (patch) | |
tree | ed9bf21351b9f7266f80d29c4e5795f358100333 /Modules/CheckCCompilerFlag.cmake | |
parent | ce6f085f31a094c26d98b873a42bf7a5aa8f5e9d (diff) | |
parent | 90dead024c5adee57e5ea3f3c90aed297d41ce3a (diff) | |
download | CMake-0021d24fb3fa8ca6ec16f5b6f44952cc375d499f.zip CMake-0021d24fb3fa8ca6ec16f5b6f44952cc375d499f.tar.gz CMake-0021d24fb3fa8ca6ec16f5b6f44952cc375d499f.tar.bz2 |
Merge topic 'add_lang_agnostic_check_compile_flag_module'
90dead024c CheckCompilerFlag: unified way to check compiler flags per language
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5281
Diffstat (limited to 'Modules/CheckCCompilerFlag.cmake')
-rw-r--r-- | Modules/CheckCCompilerFlag.cmake | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/Modules/CheckCCompilerFlag.cmake b/Modules/CheckCCompilerFlag.cmake index 1452b51..f835f29 100644 --- a/Modules/CheckCCompilerFlag.cmake +++ b/Modules/CheckCCompilerFlag.cmake @@ -34,24 +34,8 @@ effect or even a specific one is beyond the scope of this module. include_guard(GLOBAL) include(CheckCSourceCompiles) -include(CMakeCheckCompilerFlagCommonPatterns) - -function(check_c_compiler_flag _flag _var) - set(CMAKE_REQUIRED_DEFINITIONS "${_flag}") - - # Normalize locale during test compilation. - set(_locale_vars LC_ALL LC_MESSAGES LANG) - foreach(v IN LISTS _locale_vars) - set(_locale_vars_saved_${v} "$ENV{${v}}") - set(ENV{${v}} C) - endforeach() - check_compiler_flag_common_patterns(_common_patterns) - check_c_source_compiles("int main(void) { return 0; }" ${_var} - # Some compilers do not fail with a bad flag - FAIL_REGEX "command line option .* is valid for .* but not for C" # GNU - ${_common_patterns} - ) - foreach(v IN LISTS _locale_vars) - set(ENV{${v}} ${_locale_vars_saved_${v}}) - endforeach() -endfunction() +include(CheckCompilerFlag) + +macro (CHECK_C_COMPILER_FLAG _FLAG _RESULT) + check_compiler_flag(C "${_FLAG}" ${_RESULT}) +endmacro () |