[glibmm] meson.build: Avoid configuration warnings



commit 13fbe29e7eea943fb576e5b9c91f57f9d6089cee
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Thu May 19 17:20:35 2022 +0200

    meson.build: Avoid configuration warnings

 .gitlab-ci.yml | 14 ++++++++------
 meson.build    | 43 ++++++++++++++++++++++++-------------------
 2 files changed, 32 insertions(+), 25 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c84ff199..2e5c0ae9 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,6 +1,7 @@
 # Currently we track two versions of gcc: gcc-10 and gcc-11.
-
-image: debian:testing
+# 2022-05-19: ubuntu:latest = 22.04, ubuntu:rolling = 22.04, ubuntu:devel = 22.10
+# See https://hub.docker.com/_/ubuntu
+image: ubuntu:rolling
 
 stages:
   - deps
@@ -96,7 +97,7 @@ debug_build:
     - cp -r installdir/usr /
     - mkdir _build && cd _build
     # -Ddebug=true + -Doptimization=0 correspond to -Dbuildtype=debug
-    - meson --prefix=/usr --libdir=lib -Ddebug=true -Doptimization=0 -Dwarnings=fatal
+    - meson --prefix=/usr --libdir=lib -Ddebug=true -Doptimization=0 -Dwarnings=fatal -Dwarning_level=3 
-Dwerror=true
     - meson compile
     # Must wrap the command in single quotes because of the colon.
     # See https://gitlab.gnome.org/help/ci/yaml/script.md#use-special-characters-with-script
@@ -119,7 +120,7 @@ release_gcc_10_build:
     - cp -r installdir/usr /
     - mkdir _build && cd _build
     # -Ddebug=false + -Doptimization=3 correspond to -Dbuildtype=release
-    - CC=gcc-10 CXX=g++-10 meson --prefix=/usr --libdir=lib -Ddebug=false -Doptimization=3 -Dwarnings=fatal
+    - CC=gcc-10 CXX=g++-10 meson --prefix=/usr --libdir=lib -Ddebug=false -Doptimization=3 -Dwarnings=fatal 
-Dwarning_level=3 -Dwerror=true
     - meson compile
     - 'meson test --suite glibmm:'
     - meson install
@@ -137,7 +138,7 @@ release_gcc_11_build:
     - cp -r installdir/usr /
     - mkdir _build && cd _build
     # -Ddebug=false + -Doptimization=3 correspond to -Dbuildtype=release
-    - CC=gcc-11 CXX=g++-11 meson --prefix=/usr --libdir=lib -Ddebug=false -Doptimization=3 -Dwarnings=fatal
+    - CC=gcc-11 CXX=g++-11 meson --prefix=/usr --libdir=lib -Ddebug=false -Doptimization=3 -Dwarnings=fatal 
-Dwarning_level=3 -Dwerror=true
     - meson compile
     - 'meson test --suite glibmm:'
     - meson install
@@ -158,7 +159,8 @@ release_clang_build:
     - cp -r installdir/usr /
     - mkdir _build && cd _build
     # -Ddebug=false + -Doptimization=3 correspond to -Dbuildtype=release
-    - CC=clang CXX=clang++ meson --prefix=/usr --libdir=lib -Ddebug=false -Doptimization=3 -Dwarnings=max
+    # Accept warnings. See https://gitlab.gnome.org/GNOME/glibmm/-/issues/98
+    - CC=clang CXX=clang++ meson --prefix=/usr --libdir=lib -Ddebug=false -Doptimization=3 -Dwarnings=max 
-Dwarning_level=3
     - meson compile
     - 'meson test --suite glibmm:'
     - meson install
diff --git a/meson.build b/meson.build
index 94b327e3..3ffc451a 100644
--- a/meson.build
+++ b/meson.build
@@ -4,7 +4,8 @@ project('glibmm', 'cpp',
   version: '2.72.1',
   license: 'LGPLv2.1+',
   default_options: [
-    'cpp_std=c++17'
+    'cpp_std=c++17',
+    'warning_level=1',
   ],
   meson_version: '>= 0.55.0', # required for meson.add_dist_script(python3, ...)
                               # and meson.add_install_script(python3, ...)
@@ -76,10 +77,12 @@ maintainer_mode = maintainer_mode_opt == 'true' or \
 if is_dist_check
   message('Looks like a tarball is being tested. ' + \
           'Option "dist-warnings" is used instead of "warnings".')
-  warning_level = get_option('dist-warnings')
+  cpp_warnings = get_option('dist-warnings')
 else
-  warning_level = get_option('warnings')
+  cpp_warnings = get_option('warnings')
 endif
+warning_level = get_option('warning_level').to_int()
+werror = get_option('werror')
 build_deprecated_api = get_option('build-deprecated-api')
 build_documentation_opt = get_option('build-documentation')
 build_documentation = build_documentation_opt == 'true' or \
@@ -194,24 +197,25 @@ dummy_header_py = glibmm_script_dir / 'dummy-header.py'
 compile_schemas_py = glibmm_script_dir / 'compile-schemas.py'
 
 # Set compiler warnings.
+# Meson warns if any of the /W1, /W2, /W3, /W4, /Wall, -Wall, -Wextra, -Werror
+# compiler options are added with add_project_arguments().
+# Avoid such warnings, when possible.
+# See _warn_about_builtin_args() in meson/mesonbuild/interpreter/interpreter.py.
 warning_flags = []
-if warning_level == 'min'
-  if is_msvc
-    warning_flags = ['/W3']
-  else
-    warning_flags = ['-Wall']
+if cpp_warnings == 'min'
+  if warning_level == 0
+    warning_flags = is_msvc ? ['/W2'] : ['-Wall']
   endif
-elif warning_level == 'max' or warning_level == 'fatal'
-  if is_msvc
-    warning_flags = ['/W4']
-  else
-    warning_flags = '-pedantic -Wall -Wextra -Wformat-security -Wsuggest-override -Wshadow 
-Wno-long-long'.split()
+elif cpp_warnings == 'max' or cpp_warnings == 'fatal'
+  if warning_level < 3
+    warning_flags = is_msvc ? ['/W4'] : ['-pedantic', '-Wall', '-Wextra']
   endif
-  if warning_level == 'fatal'
-    if is_msvc
-      warning_flags += ['/WX']
-    else
-      warning_flags += ['-Werror']
+  if not is_msvc
+    warning_flags += '-Wformat-security -Wsuggest-override -Wshadow -Wno-long-long'.split()
+  endif
+  if cpp_warnings == 'fatal'
+    if not werror
+      warning_flags += is_msvc ? ['/WX'] : ['-Werror']
     endif
     deprecations = 'G SIGCXX'.split()
     foreach d : deprecations
@@ -375,7 +379,8 @@ summary = [
   meson.project_name() + ' ' + meson.project_version(),
   '',
   '         Maintainer mode: @0@@1@'.format(maintainer_mode_opt, real_maintainer_mode),
-  '       Compiler warnings: @0@'.format(warning_level),
+  '       Compiler warnings: @0@ (warning_level: @1@, werror: @2@)'. \
+                             format(cpp_warnings, warning_level, werror),
   '    Build deprecated API: @0@'.format(build_deprecated_api),
   'Build HTML documentation: @0@@1@'.format(build_documentation_opt, real_build_documentation),
   '  Build example programs: @0@'.format(build_examples),


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