diff options
author | Brad King <brad.king@kitware.com> | 2013-04-22 12:50:08 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2013-04-22 12:50:08 (GMT) |
commit | 52723722c78d0fe474e6f03890d70283e9340bab (patch) | |
tree | de8c076bbcb1ff44955edfdc07acc70dfb353674 /Modules/CheckCCompilerFlag.cmake | |
parent | e6c3595fde100b62f021ddb253b81fe3ecc9328b (diff) | |
download | CMake-52723722c78d0fe474e6f03890d70283e9340bab.zip CMake-52723722c78d0fe474e6f03890d70283e9340bab.tar.gz CMake-52723722c78d0fe474e6f03890d70283e9340bab.tar.bz2 |
Check{C,CXX}CompilerFlag: Test using C locale (#14102)
Set the locale to C while running the compiler for these checks because
we match the resulting warning messages in English only.
Suggested-by: Marco Nolden <m.nolden@dkfz-heidelberg.de>
Diffstat (limited to 'Modules/CheckCCompilerFlag.cmake')
-rw-r--r-- | Modules/CheckCCompilerFlag.cmake | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Modules/CheckCCompilerFlag.cmake b/Modules/CheckCCompilerFlag.cmake index 08e80f7..02f7cb6 100644 --- a/Modules/CheckCCompilerFlag.cmake +++ b/Modules/CheckCCompilerFlag.cmake @@ -26,6 +26,12 @@ include(CheckCSourceCompiles) macro (CHECK_C_COMPILER_FLAG _FLAG _RESULT) set(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}") + # Normalize locale during test compilation. + set(_CheckCCompilerFlag_LOCALE_VARS LC_ALL LC_MESSAGES LANG) + foreach(v ${_CheckCCompilerFlag_LOCALE_VARS}) + set(_CheckCCompilerFlag_SAVED_${v} "$ENV{${v}}") + set(ENV{${v}} C) + endforeach() CHECK_C_SOURCE_COMPILES("int main(void) { return 0; }" ${_RESULT} # Some compilers do not fail with a bad flag FAIL_REGEX "command line option .* is valid for .* but not for C" # GNU @@ -41,5 +47,11 @@ macro (CHECK_C_COMPILER_FLAG _FLAG _RESULT) FAIL_REGEX "command option .* is not recognized" # XL FAIL_REGEX "WARNING: unknown flag:" # Open64 ) + foreach(v ${_CheckCCompilerFlag_LOCALE_VARS}) + set(ENV{${v}} ${_CheckCCompilerFlag_SAVED_${v}}) + unset(_CheckCCompilerFlag_SAVED_${v}) + endforeach() + unset(_CheckCCompilerFlag_LOCALE_VARS) + set (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}") endmacro () |