[tepl] meson: Check for Visual Studio-specific warning items
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tepl] meson: Check for Visual Studio-specific warning items
- Date: Wed, 29 Apr 2020 18:52:39 +0000 (UTC)
commit 2bbde46a28cb7332093aba2bee02ba5b0dcdef81
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.
Also use the -utf-8 compiler flag if it is available, as it avoids
unicode handling issues when attempting to build on East Asian locales.
meson.build | 101 ++++++++++++++++++++++++++++++++++--------------------------
1 file changed, 58 insertions(+), 43 deletions(-)
---
diff --git a/meson.build b/meson.build
index 4750e0a..1a2b9d9 100644
--- a/meson.build
+++ b/meson.build
@@ -78,50 +78,65 @@ 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',
+ '-utf-8', # Available in Visual Studio 2015 or later,
+ # to prevent unicode handling issues in the
+ # compiler
+ ]
+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]