File: Check-Wno-flags.patch

package info (click to toggle)
range-v3 0.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 4,624 kB
  • sloc: cpp: 62,181; xml: 198; sh: 78; python: 37; makefile: 18
file content (30 lines) | stat: -rw-r--r-- 1,252 bytes parent folder | download
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()