From 87cfe7d051441b7a98f4557149daaf7009cb31ec Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Wed, 4 Jul 2018 16:46:32 +1000 Subject: [PATCH] compile_flag: add failure regex --- compile_flag.cmake | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/compile_flag.cmake b/compile_flag.cmake index c6b7007..f6bb622 100644 --- a/compile_flag.cmake +++ b/compile_flag.cmake @@ -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 ()