Fix CHECK_(C|CXX)_COMPILER_FLAG for XL and SunPro
These compilers warn and return 0 for unrecognized flags. We fix the compiler flag check macros by looking for a warning in the output. We also update the regex for GNU on older Macs. See issue #9516.
This commit is contained in:
parent
b872d09ea2
commit
83957d9e0d
|
@ -19,9 +19,11 @@ MACRO (CHECK_C_COMPILER_FLAG _FLAG _RESULT)
|
||||||
SET(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}")
|
SET(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}")
|
||||||
CHECK_C_SOURCE_COMPILES("int main() { return 0;}" ${_RESULT}
|
CHECK_C_SOURCE_COMPILES("int main() { return 0;}" ${_RESULT}
|
||||||
# Some compilers do not fail with a bad flag
|
# Some compilers do not fail with a bad flag
|
||||||
FAIL_REGEX "unrecognized option" # GNU
|
FAIL_REGEX "unrecognized .*option" # GNU
|
||||||
FAIL_REGEX "ignoring unknown option" # MSVC
|
FAIL_REGEX "ignoring unknown option" # MSVC
|
||||||
FAIL_REGEX "[Uu]nknown option" # HP
|
FAIL_REGEX "[Uu]nknown option" # HP
|
||||||
|
FAIL_REGEX "[Ww]arning: [Oo]ption" # SunPro
|
||||||
|
FAIL_REGEX "command option .* is not recognized" # XL
|
||||||
)
|
)
|
||||||
SET (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
|
SET (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
|
||||||
ENDMACRO (CHECK_C_COMPILER_FLAG)
|
ENDMACRO (CHECK_C_COMPILER_FLAG)
|
||||||
|
|
|
@ -19,9 +19,11 @@ MACRO (CHECK_CXX_COMPILER_FLAG _FLAG _RESULT)
|
||||||
SET(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}")
|
SET(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}")
|
||||||
CHECK_CXX_SOURCE_COMPILES("int main() { return 0;}" ${_RESULT}
|
CHECK_CXX_SOURCE_COMPILES("int main() { return 0;}" ${_RESULT}
|
||||||
# Some compilers do not fail with a bad flag
|
# Some compilers do not fail with a bad flag
|
||||||
FAIL_REGEX "unrecognized option" # GNU
|
FAIL_REGEX "unrecognized .*option" # GNU
|
||||||
FAIL_REGEX "ignoring unknown option" # MSVC
|
FAIL_REGEX "ignoring unknown option" # MSVC
|
||||||
FAIL_REGEX "[Uu]nknown option" # HP
|
FAIL_REGEX "[Uu]nknown option" # HP
|
||||||
|
FAIL_REGEX "[Ww]arning: [Oo]ption" # SunPro
|
||||||
|
FAIL_REGEX "command option .* is not recognized" # XL
|
||||||
)
|
)
|
||||||
SET (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
|
SET (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
|
||||||
ENDMACRO (CHECK_CXX_COMPILER_FLAG)
|
ENDMACRO (CHECK_CXX_COMPILER_FLAG)
|
||||||
|
|
Loading…
Reference in New Issue