[tepl/master.msvc: 1/8] meson: Check for Visual Studio-specific warning items



commit 9f30a7200a2622e339ec59b71fdb6a489fc04085
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Tue Apr 28 16:06:08 2020 +0800

    meson: Check for Visual Studio-specific warning items
    
    We want to force-include msvc_recommended_pragmas.h that is shipped with
    Windows builds of GLib so that we can filter out warnings that we don't
    really need to care much about, but also let the ones that we should be
    wary of stand (error) out.

 meson.build | 98 ++++++++++++++++++++++++++++++++++---------------------------
 1 file changed, 55 insertions(+), 43 deletions(-)
---
diff --git a/meson.build b/meson.build
index 4750e0a..1f8f7ae 100644
--- a/meson.build
+++ b/meson.build
@@ -78,50 +78,62 @@ add_project_arguments(
 # even at the maximum level.
 # The following warning_cflags suppose that warning_level=2.
 
-warning_cflags = [
-  '-fno-strict-aliasing',
-  '-Wundef',
-  '-Wnested-externs',
-  '-Wwrite-strings',
-  '-Wpointer-arith',
-  '-Wmissing-declarations',
-  '-Wmissing-prototypes',
-  '-Wstrict-prototypes',
-  '-Wredundant-decls',
-  '-Wno-unused-parameter',
-  '-Wno-missing-field-initializers',
-  '-Wdeclaration-after-statement',
-  '-Wformat=2',
-  '-Wold-style-definition',
-  '-Wcast-align',
-  '-Wformat-nonliteral',
-  '-Wformat-security',
-  '-Wsign-compare',
-  '-Wstrict-aliasing',
-  '-Wshadow',
-  '-Winline',
-  '-Wpacked',
-  '-Wmissing-format-attribute',
-  '-Wmissing-noreturn',
-  '-Winit-self',
-  '-Wredundant-decls',
-  '-Wmissing-include-dirs',
-  '-Wunused-but-set-variable',
-  '-Warray-bounds',
-  '-Wimplicit-function-declaration',
-  '-Wreturn-type',
-  '-Wswitch-enum',
-  '-Wswitch-default',
-  '-Wduplicated-cond',
-  '-Wduplicated-branches',
-  '-Wlogical-op',
-  '-Wrestrict',
-  '-Wnull-dereference',
-  '-Wjump-misses-init',
-  '-Wdouble-promotion'
-]
-
 c_compiler = meson.get_compiler('c')
+
+warning_cflags = []
+
+if c_compiler.get_id() == 'msvc'
+  # Use GLib's msvc_recommended_pragmas.h to filter out
+  # the warnings we don't really need to worry about,
+  # but do make the ones we want to be wary stand out
+  warning_cflags += [
+    '-FImsvc_recommended_pragmas.h',
+  ]
+else
+  warning_cflags += [
+    '-fno-strict-aliasing',
+    '-Wundef',
+    '-Wnested-externs',
+    '-Wwrite-strings',
+    '-Wpointer-arith',
+    '-Wmissing-declarations',
+    '-Wmissing-prototypes',
+    '-Wstrict-prototypes',
+    '-Wredundant-decls',
+    '-Wno-unused-parameter',
+    '-Wno-missing-field-initializers',
+    '-Wdeclaration-after-statement',
+    '-Wformat=2',
+    '-Wold-style-definition',
+    '-Wcast-align',
+    '-Wformat-nonliteral',
+    '-Wformat-security',
+    '-Wsign-compare',
+    '-Wstrict-aliasing',
+    '-Wshadow',
+    '-Winline',
+    '-Wpacked',
+    '-Wmissing-format-attribute',
+    '-Wmissing-noreturn',
+    '-Winit-self',
+    '-Wredundant-decls',
+    '-Wmissing-include-dirs',
+    '-Wunused-but-set-variable',
+    '-Warray-bounds',
+    '-Wimplicit-function-declaration',
+    '-Wreturn-type',
+    '-Wswitch-enum',
+    '-Wswitch-default',
+    '-Wduplicated-cond',
+    '-Wduplicated-branches',
+    '-Wlogical-op',
+    '-Wrestrict',
+    '-Wnull-dereference',
+    '-Wjump-misses-init',
+    '-Wdouble-promotion'
+  ]
+endif
+
 supported_warning_cflags = c_compiler.get_supported_arguments(warning_cflags)
 add_project_arguments(supported_warning_cflags, language: 'c')
 ##### end CFLAGS


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]