]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - meson.build
build-sys: Use common gcc argument detection for negative warning flags.
[thirdparty/systemd.git] / meson.build
index 48a47f8103a7172241ece96dd53ac86ea9f3e8da..7ffe61246aaebbef956eaeb3965631bd3595bf9b 100644 (file)
@@ -321,6 +321,20 @@ possible_cc_flags = [
         '-Werror=shift-overflow=2',
         '-Wdate-time',
         '-Wnested-externs',
+
+        # negative arguments are correctly detected starting with meson 0.46.
+        '-Wno-unused-parameter',
+        '-Wno-missing-field-initializers',
+        '-Wno-unused-result',
+        '-Wno-format-signedness',
+
+        # work-around for gcc 7.1 turning this on on its own.
+        '-Wno-error=nonnull',
+
+        # Disable -Wmaybe-uninitialized, since it's noisy on gcc 8 with
+        # optimizations enabled, producing essentially false positives.
+        '-Wno-maybe-uninitialized',
+
         '-ffast-math',
         '-fno-common',
         '-fdiagnostics-show-option',
@@ -364,23 +378,6 @@ endif
 add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'c')
 add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language : 'c')
 
-# "negative" arguments: gcc on purpose does not return an error for "-Wno-"
-# arguments, just emits a warning. So test for the "positive" version instead.
-foreach arg : ['unused-parameter',
-               'missing-field-initializers',
-               'unused-result',
-               'format-signedness',
-               'error=nonnull', # work-around for gcc 7.1 turning this on on its own
-
-               # Disable -Wmaybe-uninitialized, since it's noisy on gcc 8 with
-               # optimizations enabled, producing essentially false positives.
-               'maybe-uninitialized',
-              ]
-        if cc.has_argument('-W' + arg)
-                add_project_arguments('-Wno-' + arg, language : 'c')
-        endif
-endforeach
-
 if cc.compiles('''
    #include <time.h>
    #include <inttypes.h>