summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2022-10-10 14:08:54 +0100
committerSimon McVittie <smcv@collabora.com>2022-10-10 14:09:29 +0100
commit45108f1852d329b3a4d10f6d5d3558dca8288dcb (patch)
treeb1ed96ebcf090c0afcd1759cf8e7fecd0a8274cb
parentf780507d5b92005df725ab9b24cf0b23dd9d9bb5 (diff)
downloadlibglnx-45108f1852d329b3a4d10f6d5d3558dca8288dcb.tar.gz
build: Explicitly disable warnings for non-ISO C features
libglnx is intentionally not portable to non-Unix platforms or to compilers that do not implement gcc/clang extensions, so it's counterproductive to warn about these extensions, even if libglnx is used by a parent project that generally (for the parts that don't use libglnx) wants to be portable to any ISO C compiler. Suggested by Will Thompson on !36. Signed-off-by: Simon McVittie <smcv@collabora.com>
-rw-r--r--meson.build5
-rw-r--r--tests/use-as-subproject/meson.build28
-rw-r--r--tests/use-as-subproject/trivial.c15
3 files changed, 46 insertions, 2 deletions
diff --git a/meson.build b/meson.build
index 38ec2ea..db60533 100644
--- a/meson.build
+++ b/meson.build
@@ -14,6 +14,11 @@ project(
add_project_arguments('-D_GNU_SOURCE', language: 'c')
add_project_arguments('-Wno-unused-local-typedefs', language: 'c')
+# We are intentionally using non-ISO features in this (sub)project,
+# even if a parent project wants to use pedantic warnings
+add_project_arguments('-Wno-pedantic', language: 'c')
+add_project_arguments('-Wno-variadic-macros', language: 'c')
+
cc = meson.get_compiler('c')
diff --git a/tests/use-as-subproject/meson.build b/tests/use-as-subproject/meson.build
index 2d08160..59fd736 100644
--- a/tests/use-as-subproject/meson.build
+++ b/tests/use-as-subproject/meson.build
@@ -4,6 +4,10 @@
project(
'use-libglnx-as-subproject',
'c',
+ default_options : [
+ 'c_std=gnu99',
+ 'warning_level=3',
+ ],
version : '0',
meson_version : '>=0.49.0',
)
@@ -20,5 +24,25 @@ libglnx = subproject('libglnx')
libglnx_dep = libglnx.get_variable('libglnx_dep')
libglnx_testlib_dep = libglnx.get_variable('libglnx_testlib_dep')
-executable('use-libglnx', 'use-libglnx.c', dependencies : [libglnx_dep, glib_dep])
-executable('use-testlib', 'use-testlib.c', dependencies : [libglnx_testlib_dep, glib_dep])
+# This executable is compiled at warning_level=3 by default
+executable(
+ 'trivial',
+ 'trivial.c',
+ dependencies : [glib_dep],
+)
+
+# These can't be compiled at warning_level=3 because they use non-ISO
+# compiler features in the libglnx headers, which would be warnings or
+# errors with -Wpedantic
+executable(
+ 'use-libglnx',
+ 'use-libglnx.c',
+ dependencies : [libglnx_dep, glib_dep],
+ override_options : ['warning_level=2'],
+)
+executable(
+ 'use-testlib',
+ 'use-testlib.c',
+ dependencies : [libglnx_testlib_dep, glib_dep],
+ override_options : ['warning_level=2'],
+)
diff --git a/tests/use-as-subproject/trivial.c b/tests/use-as-subproject/trivial.c
new file mode 100644
index 0000000..4b364f1
--- /dev/null
+++ b/tests/use-as-subproject/trivial.c
@@ -0,0 +1,15 @@
+/*
+ * Copyright 2022 Collabora Ltd.
+ * SPDX-License-Identifier: LGPL-2.0-or-later
+ */
+
+#include <glib.h>
+
+int
+main (void)
+{
+ GError *error = NULL;
+
+ g_clear_error (&error);
+ return 0;
+}