[glib/wip/pwithnall/macos-werror: 2/4] build: Pass warning and warning-disabling arguments to C++ and ObjC too




commit 249e654b961c6e5ed4ee4574dd8e2dada9cb3788
Author: Philip Withnall <pwithnall endlessos org>
Date:   Thu Nov 18 13:53:45 2021 +0000

    build: Pass warning and warning-disabling arguments to C++ and ObjC too
    
    Previously they were only passed to the C compiler, which meant disabled
    warnings were still emitted when (for example) including C headers from
    C++ and ObjC files.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 meson.build | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)
---
diff --git a/meson.build b/meson.build
index c29570f2d..075287ac0 100644
--- a/meson.build
+++ b/meson.build
@@ -425,17 +425,15 @@ endforeach
 
 # Compiler flags
 if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
-  warning_c_args = [
+  warning_common_args = [
     '-Wduplicated-branches',
     '-Wimplicit-fallthrough',
     '-Wmisleading-indentation',
-    '-Wstrict-prototypes',
     '-Wunused',
     # Due to maintained deprecated code, we do not want to see unused parameters
     '-Wno-unused-parameter',
     # Due to pervasive use of things like GPOINTER_TO_UINT(), we do not support
     # building with -Wbad-function-cast.
-    '-Wno-bad-function-cast',
     '-Wno-cast-function-type',
     # Due to function casts through (void*) we cannot support -Wpedantic:
     # https://wiki.gnome.org/Projects/GLib/CompilerRequirements#Function_pointer_conversions.
@@ -444,14 +442,23 @@ if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
     '-Wno-format-zero-length',
     # We explicitly require variadic macros
     '-Wno-variadic-macros',
-    '-Werror=declaration-after-statement',
     '-Werror=format=2',
-    '-Werror=implicit-function-declaration',
     '-Werror=init-self',
     '-Werror=missing-include-dirs',
-    '-Werror=missing-prototypes',
     '-Werror=pointer-arith',
   ]
+
+  warning_c_args = warning_common_args + [
+    '-Wstrict-prototypes',
+    # Due to pervasive use of things like GPOINTER_TO_UINT(), we do not support
+    # building with -Wbad-function-cast.
+    '-Wno-bad-function-cast',
+    '-Werror=declaration-after-statement',
+    '-Werror=implicit-function-declaration',
+    '-Werror=missing-prototypes',
+  ]
+  warning_cxx_args = warning_common_args
+  warning_objc_args = warning_c_args
   warning_c_link_args = [
     '-Wl,-z,nodelete',
   ]
@@ -460,10 +467,13 @@ if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
   endif
 else
   warning_c_args = []
+  warning_cxx_args = []
+  warning_objc_args = []
   warning_c_link_args = []
 endif
 
 add_project_arguments(cc.get_supported_arguments(warning_c_args), language: 'c')
+add_project_arguments(cxx.get_supported_arguments(warning_cxx_args), language: 'cpp')
 
 # FIXME: We cannot build some of the GResource tests with -z nodelete, which
 # means we cannot use that flag in add_project_link_arguments(), and must add
@@ -757,6 +767,8 @@ if host_system == 'darwin'
   add_languages('objc')
   objcc = meson.get_compiler('objc')
 
+  add_project_arguments(objcc.get_supported_arguments(warning_objc_args), language: 'objc')
+
   osx_ldflags += ['-Wl,-framework,CoreFoundation']
 
   # Mac OS X Carbon support


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