1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
Description: Improve check of -Wno-* compiler flags
The GCC documentation says that unrecognized warning options in the -Wno-* form
do not cause errors unless other diagnostics are issued. And thus unsupported
flags may be appended. This results in a failed build when there are some false
positive warnings.
Author: Nicholas Guriev <guriev-ns@ya.ru>
Bug: https://github.com/ericniebler/range-v3/pull/1163
Bug-Debian: https://bugs.debian.org/926218
Last-Update: Sat, 27 Apr 2019 09:36:39 +0300
--- a/cmake/ranges_flags.cmake
+++ b/cmake/ranges_flags.cmake
@@ -8,10 +8,14 @@
# Compilation flags
include(CheckCXXCompilerFlag)
-macro(ranges_append_flag testname flag ${ARGN})
- check_cxx_compiler_flag("${flag} ${ARGN}" ${testname})
+macro(ranges_append_flag testname flag)
+ # As -Wno-* flags do not lead to build failure when there are no other
+ # diagnostics, we check positive option to determine their applicability.
+ # Of course we set the original flag that is requested in the parameters.
+ string(REGEX REPLACE "^-Wno-" "-W" alt ${flag})
+ check_cxx_compiler_flag(${alt} ${testname})
if (${testname})
- add_compile_options(${flag} ${ARGN})
+ add_compile_options(${flag})
endif()
endmacro()
|