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 | |
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')
3 files changed, 48 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() diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckCXXCompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckCXXCompilerFlag.cmake new file mode 100644 index 0000000..eb20eb4 --- /dev/null +++ b/Tests/RunCMake/CheckCompilerFlag/CheckCXXCompilerFlag.cmake @@ -0,0 +1,19 @@ + +enable_language (CXX) +include(CheckCXXCompilerFlag) + +set(CXX 1) # test that this is tolerated + +if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "PathScale") + set(DD --) +endif() + +check_cxx_compiler_flag("${DD}-_this_is_not_a_flag_" CXX_BOGUS_FLAG) +if(CXX_BOGUS_FLAG) + message(SEND_ERROR "CHECK_CXX_COMPILER_FLAG() succeeded, but should have failed") +endif() +unset(CXX_BOGUS_FLAG CACHE) +if(DEFINED CXX_BOGUS_FLAG) + # Verify that CHECK_CXX_COMPILER_FLAG didn't construct a normal variable + message(SEND_ERROR "CHECK_CXX_COMPILER_FLAG shouldn't construct CXX_BOGUS_FLAG as a normal variable") +endif() diff --git a/Tests/RunCMake/CheckCompilerFlag/RunCMakeTest.cmake b/Tests/RunCMake/CheckCompilerFlag/RunCMakeTest.cmake index dce93a5..b0e025c 100644 --- a/Tests/RunCMake/CheckCompilerFlag/RunCMakeTest.cmake +++ b/Tests/RunCMake/CheckCompilerFlag/RunCMakeTest.cmake @@ -3,6 +3,8 @@ include(RunCMake) run_cmake(NotEnabledLanguage) run_cmake(NonExistentLanguage) +run_cmake(CheckCCompilerFlag) +run_cmake(CheckCXXCompilerFlag) run_cmake(CheckCompilerFlagC) run_cmake(CheckCompilerFlagCXX) |