diff options
Diffstat (limited to 'Modules/CheckCXXCompilerFlag.cmake')
-rw-r--r-- | Modules/CheckCXXCompilerFlag.cmake | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/Modules/CheckCXXCompilerFlag.cmake b/Modules/CheckCXXCompilerFlag.cmake index a01e142..5729843 100644 --- a/Modules/CheckCXXCompilerFlag.cmake +++ b/Modules/CheckCXXCompilerFlag.cmake @@ -37,27 +37,27 @@ include(CheckCXXSourceCompiles) include(CMakeCheckCompilerFlagCommonPatterns) 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_COMPILER_FLAG_COMMON_PATTERNS(_CheckCXXCompilerFlag_COMMON_PATTERNS) - 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 - ${_CheckCXXCompilerFlag_COMMON_PATTERNS} - ) - foreach(v ${_CheckCXXCompilerFlag_LOCALE_VARS}) - set(ENV{${v}} ${_CheckCXXCompilerFlag_SAVED_${v}}) - unset(_CheckCXXCompilerFlag_SAVED_${v}) - endforeach() - unset(_CheckCXXCompilerFlag_LOCALE_VARS) - unset(_CheckCXXCompilerFlag_COMMON_PATTERNS) - - set (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}") + 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_COMPILER_FLAG_COMMON_PATTERNS(_CheckCXXCompilerFlag_COMMON_PATTERNS) + 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 + ${_CheckCXXCompilerFlag_COMMON_PATTERNS} + ) + foreach(v ${_CheckCXXCompilerFlag_LOCALE_VARS}) + set(ENV{${v}} ${_CheckCXXCompilerFlag_SAVED_${v}}) + unset(_CheckCXXCompilerFlag_SAVED_${v}) + endforeach() + unset(_CheckCXXCompilerFlag_LOCALE_VARS) + unset(_CheckCXXCompilerFlag_COMMON_PATTERNS) + + set (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}") endmacro () |