summaryrefslogtreecommitdiffstats
path: root/Modules/CheckCXXCompilerFlag.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-04-22 12:50:08 (GMT)
committerBrad King <brad.king@kitware.com>2013-04-22 12:50:08 (GMT)
commit52723722c78d0fe474e6f03890d70283e9340bab (patch)
treede8c076bbcb1ff44955edfdc07acc70dfb353674 /Modules/CheckCXXCompilerFlag.cmake
parente6c3595fde100b62f021ddb253b81fe3ecc9328b (diff)
downloadCMake-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/CheckCXXCompilerFlag.cmake')
-rw-r--r--Modules/CheckCXXCompilerFlag.cmake13
1 files changed, 13 insertions, 0 deletions
diff --git a/Modules/CheckCXXCompilerFlag.cmake b/Modules/CheckCXXCompilerFlag.cmake
index 6626403..a872a75 100644
--- a/Modules/CheckCXXCompilerFlag.cmake
+++ b/Modules/CheckCXXCompilerFlag.cmake
@@ -26,6 +26,13 @@ include(CheckCXXSourceCompiles)
macro (CHECK_CXX_COMPILER_FLAG _FLAG _RESULT)
set(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}")
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(ENV{${v}} C)
+ endforeach()
CHECK_CXX_SOURCE_COMPILES("int main() { 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
@@ -43,6 +50,12 @@ macro (CHECK_CXX_COMPILER_FLAG _FLAG _RESULT)
FAIL_REGEX "File with unknown suffix passed to linker" # PGI
FAIL_REGEX "WARNING: unknown flag:" # Open64
)
+ foreach(v ${_CheckCXXCompilerFlag_LOCALE_VARS})
+ set(ENV{${v}} ${_CheckCXXCompilerFlag_SAVED_${v}})
+ unset(_CheckCXXCompilerFlag_SAVED_${v})
+ endforeach()
+ unset(_CheckCXXCompilerFlag_LOCALE_VARS)
+
set (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
endmacro ()