diff options
author | Brad King <brad.king@kitware.com> | 2022-10-06 13:46:42 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-10-06 14:29:42 (GMT) |
commit | 90aa0bb30543cde2c3f58a090735904e17092c44 (patch) | |
tree | 8d19578f1df8747652e5ffcfe19ab57b7f5f5a1b /Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake | |
parent | 64ac01451dad389bb4ca00019a38fbb8bd68308e (diff) | |
download | CMake-90aa0bb30543cde2c3f58a090735904e17092c44.zip CMake-90aa0bb30543cde2c3f58a090735904e17092c44.tar.gz CMake-90aa0bb30543cde2c3f58a090735904e17092c44.tar.bz2 |
Tests: Move TryCompile check module cases to RunCMake.Check*
The latter already have similar checks for similar modules.
Diffstat (limited to 'Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake')
-rw-r--r-- | Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake new file mode 100644 index 0000000..bfb6f72 --- /dev/null +++ b/Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake @@ -0,0 +1,27 @@ + +enable_language (C) +include(CheckCCompilerFlag) + +set(C 1) # test that this is tolerated + +if(NOT CMAKE_C_COMPILER_ID STREQUAL "PathScale") + set(DD --) +endif() + +check_c_compiler_flag("${DD}-_this_is_not_a_flag_" C_BOGUS_FLAG) +if(C_BOGUS_FLAG) + message(SEND_ERROR "CHECK_C_COMPILER_FLAG() succeeded, but should have failed") +endif() +unset(C_BOGUS_FLAG CACHE) +if(DEFINED C_BOGUS_FLAG) + # Verify that CHECK_C_COMPILER_FLAG didn't construct a normal variable + message(SEND_ERROR "CHECK_C_COMPILER_FLAG shouldn't construct C_BOGUS_FLAG as a normal variable") +endif() + +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "LCC") + unset(C_STRICT_PROTOTYPES CACHE) + CHECK_C_COMPILER_FLAG("-Werror;-Wstrict-prototypes" C_STRICT_PROTOTYPES) + if(NOT C_STRICT_PROTOTYPES) + message(SEND_ERROR "CHECK_C_COMPILER_FLAG failed -Werror -Wstrict-prototypes") + endif() +endif() |