Add fail regex to detect supported warning flags correctly.

On Apple's gcc, the compiler emits a warning such as "warning: command
line option "-Wno-deprecated" is valid for C++/ObjC++ but not for C"
when it is passed that flag on its command line.

When testing for that flag with a plain C file, we should report that
the flag is unsupported for C files. The new FAIL_REGEX option added
here produces this behavior.
This commit is contained in:
David Cole 2011-07-27 15:01:50 -04:00
parent 49a00ec2de
commit b7f3f7cdb6
1 changed files with 2 additions and 1 deletions

View File

@ -27,6 +27,8 @@ MACRO (CHECK_C_COMPILER_FLAG _FLAG _RESULT)
SET(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}")
CHECK_C_SOURCE_COMPILES("int main(void) { return 0; }" ${_RESULT}
# Some compilers do not fail with a bad flag
FAIL_REGEX "warning: command line option .* is valid for .* but not for C"
# Apple gcc
FAIL_REGEX "unrecognized .*option" # GNU
FAIL_REGEX "ignoring unknown option" # MSVC
FAIL_REGEX "warning D9002" # MSVC, any lang
@ -36,4 +38,3 @@ MACRO (CHECK_C_COMPILER_FLAG _FLAG _RESULT)
)
SET (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
ENDMACRO (CHECK_C_COMPILER_FLAG)