3 include(CheckCompilerFlag)
5 set(C 1) # test that this is tolerated
7 # test that the check uses an isolated locale
8 set(_env_LC_ALL "${LC_ALL}")
11 check_compiler_flag(C "-_this_is_not_a_flag_" SHOULD_FAIL)
13 message(SEND_ERROR "invalid C compile flag didn't fail.")
16 if(CMAKE_C_COMPILER_ID MATCHES "GNU|LCC|Clang" AND NOT "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC")
17 check_compiler_flag(C "-x c" SHOULD_WORK)
19 message(SEND_ERROR "${CMAKE_C_COMPILER_ID} compiler flag '-x c' check failed")
23 if(CMAKE_C_COMPILER_ID STREQUAL "GNU") # LCC C compiler silently ignore -frtti instead of failing, so skip it here.
24 check_compiler_flag(C "-frtti" SHOULD_FAIL_RTTI)
26 message(SEND_ERROR "${CMAKE_C_COMPILER_ID} compiler flag '-frtti' check passed but should have failed")
30 if(NOT "$ENV{LC_ALL}" STREQUAL "BAD")
31 message(SEND_ERROR "ENV{LC_ALL} was not preserved by check_compiler_flag")
33 set(ENV{LC_ALL} ${_env_LC_ALL})