summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-10-07 11:12:24 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-10-07 11:12:31 (GMT)
commit026beeb620f8f8c3939e128eb07c879133bf7d1c (patch)
treee50d9180972e68ba293314183c1facab05c7aea1
parent7f1a36deead177e475e113ba36336d038d9ee931 (diff)
parentd66858c8e42c8a07a8bbc15559c21eb917866f46 (diff)
downloadCMake-026beeb620f8f8c3939e128eb07c879133bf7d1c.zip
CMake-026beeb620f8f8c3939e128eb07c879133bf7d1c.tar.gz
CMake-026beeb620f8f8c3939e128eb07c879133bf7d1c.tar.bz2
Merge topic 'CheckCompilerFlag-gcc-10'
d66858c8e4 CheckCompilerFlag: Update the regex used to detect invalid options for GCC 10 Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !5331
-rw-r--r--Modules/CheckCompilerFlag.cmake10
-rw-r--r--Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake7
2 files changed, 12 insertions, 5 deletions
diff --git a/Modules/CheckCompilerFlag.cmake b/Modules/CheckCompilerFlag.cmake
index 9223009..0339225 100644
--- a/Modules/CheckCompilerFlag.cmake
+++ b/Modules/CheckCompilerFlag.cmake
@@ -45,20 +45,20 @@ function(CHECK_COMPILER_FLAG _lang _flag _var)
if(_lang STREQUAL C)
set(_lang_src "int main(void) { return 0; }")
- set(_lang_fail_regex FAIL_REGEX "command line option .* is valid for .* but not for C")
+ set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for C")
elseif(_lang STREQUAL CXX)
set(_lang_src "int main() { return 0; }")
- set(_lang_fail_regex FAIL_REGEX "command line option .* is valid for .* but not for C\\+\\+")
+ set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for C\\+\\+")
elseif(_lang STREQUAL Fortran)
set(_lang_src " program test\n stop\n end program")
- set(_lang_fail_regex FAIL_REGEX "command line option .* is valid for .* but not for Fortran")
+ set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for Fortran")
elseif(_lang STREQUAL OBJC)
set(_lang_src [=[
#ifndef __OBJC__
# error "Not an Objective-C compiler"
#endif
int main(void) { return 0; }]=])
- set(_lang_fail_regex FAIL_REGEX "command line option .* is valid for .* but not for Objective-C" # GNU
+ set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for Objective-C" # GNU
FAIL_REGEX "argument unused during compilation: .*") # Clang
elseif(_lang STREQUAL OBJCXX)
set(_lang_src [=[
@@ -66,7 +66,7 @@ int main(void) { return 0; }]=])
# error "Not an Objective-C++ compiler"
#endif
int main(void) { return 0; }]=])
- set(_lang_fail_regex FAIL_REGEX "command line option .* is valid for .* but not for Objective-C\\+\\+" # GNU
+ set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for Objective-C\\+\\+" # GNU
FAIL_REGEX "argument unused during compilation: .*") # Clang
else()
message (SEND_ERROR "check_compiler_flag: ${_lang}: unknown language.")
diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake
index d268ed2..095fd54 100644
--- a/Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake
+++ b/Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake
@@ -13,3 +13,10 @@ if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang" AND NOT "x${CMAKE_C_SIMULATE_ID}" STR
message(SEND_ERROR "${CMAKE_C_COMPILER_ID} compiler flag '-x c' check failed")
endif()
endif()
+
+if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ check_compiler_flag(C "-frtti" SHOULD_FAIL_RTTI)
+ if(SHOULD_FAIL_RTTI)
+ message(SEND_ERROR "${CMAKE_C_COMPILER_ID} compiler flag '-frtti' check passed but should have failed")
+ endif()
+endif()