compile_flag: add failure regex

This commit is contained in:
Danny Robson 2018-07-04 16:46:32 +10:00
parent 26319b51a1
commit 87cfe7d051

View File

@ -1,4 +1,5 @@
include(CheckCXXSourceCompiles)
include(CMakeCheckCompilerFlagCommonPatterns)
# Test if a compiler flag is supported.
#
@ -11,6 +12,12 @@ include(CheckCXXSourceCompiles)
macro (append_compile_flag _flag)
string (MAKE_C_IDENTIFIER ${_flag} _name)
CHECK_COMPILER_FLAG_COMMON_PATTERNS(_append_compile_flag_COMMON_PATTERNS)
set(_append_compile_flag_COMMON_PATTERNS
${_append_compile_flag_COMMON_PATTERNS}
FAIL_REGEX "argument unused during compilation" #clang
)
if (NOT DEFINED compile_flag_${_name})
# If we have an argument of the form "-Wno-foo" then we can't test it
# directly as GCC will unconditioally succeed right up until the
@ -30,7 +37,12 @@ macro (append_compile_flag _flag)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_CXX_FLAGS} -W${_inverse_flag}")
endif ()
check_cxx_source_compiles("int main(int,char**) { return 0; }" compile_flag_${_name})
check_cxx_source_compiles(
"int main(int,char**) { return 0; }"
compile_flag_${_name}
${_append_compile_flag_COMMON_PATTERNS}
)
set(CMAKE_REQUIRED_FLAGS "${_append_compile_flag_REQUIRED_FLAGS}")
endif ()