Debian Codegraph @

Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake

raw
1
2 enable_language (C)
3 include(CheckCCompilerFlag)
4
5 set(C 1) # test that this is tolerated
6
7 if(NOT CMAKE_C_COMPILER_ID STREQUAL "PathScale")
8 set(DD --)
9 endif()
10
11 check_c_compiler_flag("${DD}-_this_is_not_a_flag_" C_BOGUS_FLAG)
12 if(C_BOGUS_FLAG)
13 message(SEND_ERROR "CHECK_C_COMPILER_FLAG() succeeded, but should have failed")
14 endif()
15 unset(C_BOGUS_FLAG CACHE)
16 if(DEFINED C_BOGUS_FLAG)
17 # Verify that CHECK_C_COMPILER_FLAG didn't construct a normal variable
18 message(SEND_ERROR "CHECK_C_COMPILER_FLAG shouldn't construct C_BOGUS_FLAG as a normal variable")
19 endif()
20
21 if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "LCC")
22 unset(C_STRICT_PROTOTYPES CACHE)
23 CHECK_C_COMPILER_FLAG("-Werror;-Wstrict-prototypes" C_STRICT_PROTOTYPES)
24 if(NOT C_STRICT_PROTOTYPES)
25 message(SEND_ERROR "CHECK_C_COMPILER_FLAG failed -Werror -Wstrict-prototypes")
26 endif()
27 endif()