summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeDetermineCompilerABI.cmake
diff options
context:
space:
mode:
authorChuck Cranor <chuck@ece.cmu.edu>2019-01-14 19:42:22 (GMT)
committerBrad King <brad.king@kitware.com>2019-01-21 16:14:08 (GMT)
commitd751d2d2ed277c1bfb2882fd90b377983ab4700f (patch)
tree6a13e90246e529d788c44e2d5901c7bd21f5aa68 /Modules/CMakeDetermineCompilerABI.cmake
parentc765ae495aa25714023d2cf2bcf6a9873da06184 (diff)
downloadCMake-d751d2d2ed277c1bfb2882fd90b377983ab4700f.zip
CMake-d751d2d2ed277c1bfb2882fd90b377983ab4700f.tar.gz
CMake-d751d2d2ed277c1bfb2882fd90b377983ab4700f.tar.bz2
CMakeDetermineCompilerABI: set locale to C for try_compile()
Have CMakeDetermineCompilerABI set the locale to C before calling try_compile(). This is for the implicit include path parser to keep all the verbose compiler messages in English so we can parse it. See #18784 for discussion.
Diffstat (limited to 'Modules/CMakeDetermineCompilerABI.cmake')
-rw-r--r--Modules/CMakeDetermineCompilerABI.cmake17
1 files changed, 17 insertions, 0 deletions
diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake
index 14f4da0..1dbd44f 100644
--- a/Modules/CMakeDetermineCompilerABI.cmake
+++ b/Modules/CMakeDetermineCompilerABI.cmake
@@ -30,6 +30,17 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src)
list(APPEND CMAKE_FLAGS "-DCMAKE_${lang}_STANDARD_LIBRARIES=")
endif()
__TestCompiler_setTryCompileTargetType()
+
+ # Save the current LC_ALL, LC_MESSAGES, and LANG environment variables
+ # and set them to "C" that way GCC's "search starts here" text is in
+ # English and we can grok it.
+ set(_orig_lc_all $ENV{LC_ALL})
+ set(_orig_lc_messages $ENV{LC_MESSAGES})
+ set(_orig_lang $ENV{LANG})
+ set(ENV{LC_ALL} C)
+ set(ENV{LC_MESSAGES} C)
+ set(ENV{LANG} C)
+
try_compile(CMAKE_${lang}_ABI_COMPILED
${CMAKE_BINARY_DIR} ${src}
CMAKE_FLAGS ${CMAKE_FLAGS}
@@ -40,6 +51,12 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src)
COPY_FILE "${BIN}"
COPY_FILE_ERROR _copy_error
)
+
+ # Restore original LC_ALL, LC_MESSAGES, and LANG
+ set(ENV{LC_ALL} ${_orig_lc_all})
+ set(ENV{LC_MESSAGES} ${_orig_lc_messages})
+ set(ENV{LANG} ${_orig_lang})
+
# Move result from cache to normal variable.
set(CMAKE_${lang}_ABI_COMPILED ${CMAKE_${lang}_ABI_COMPILED})
unset(CMAKE_${lang}_ABI_COMPILED CACHE)