summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjell Ahlstedt <kjellahlstedt@gmail.com>2022-05-13 15:36:34 +0200
committerKjell Ahlstedt <kjellahlstedt@gmail.com>2022-05-13 15:36:34 +0200
commit3379d0809c55560638ee7ed1336337d4dfc86992 (patch)
tree27120c557e61c61a73b4a7209fa3b0b1a1b4b0e7
parent1e163f565e907d71cbec98728aaa74ce2241adaf (diff)
downloadmm-common-3379d0809c55560638ee7ed1336337d4dfc86992.tar.gz
skeletonmm/meson.build: Avoid configuration warnings
-rw-r--r--skeletonmm/meson.build35
1 files changed, 25 insertions, 10 deletions
diff --git a/skeletonmm/meson.build b/skeletonmm/meson.build
index c60c9b2..d1e89d4 100644
--- a/skeletonmm/meson.build
+++ b/skeletonmm/meson.build
@@ -4,7 +4,8 @@ project('skeletonmm', 'cpp',
version: '0.1.0',
license: 'LGPLv2.1+',
default_options: [
- 'cpp_std=c++17'
+ 'cpp_std=c++17',
+ 'warning_level=1',
],
meson_version: '>= 0.56.0', # required for executable(..., win_subsystem: ...)
)
@@ -68,10 +69,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 \
@@ -164,13 +167,24 @@ perl = find_program('perl', required: maintainer_mode or \
cpp_compiler = meson.get_compiler('cpp')
# 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'
- warning_flags = ['-Wall']
-elif warning_level == 'max' or warning_level == 'fatal'
- warning_flags = '-pedantic -Wall -Wextra -Wformat-security -Wsuggest-override -Wshadow -Wno-long-long'.split()
- if warning_level == 'fatal'
- warning_flags += ['-Werror']
+if cpp_warnings == 'min'
+ if warning_level == 0
+ warning_flags = ['-Wall']
+ endif
+elif cpp_warnings == 'max' or cpp_warnings == 'fatal'
+ if warning_level < 3
+ warning_flags = ['-pedantic', '-Wall', '-Wextra']
+ endif
+ warning_flags += '-Wformat-security -Wsuggest-override -Wshadow -Wno-long-long'.split()
+ if cpp_warnings == 'fatal'
+ if not werror
+ warning_flags += ['-Werror']
+ endif
deprecations = 'G SKELETON GLIBMM SIGCXX'.split()
foreach d : deprecations
warning_flags += '-D@0@_DISABLE_DEPRECATED'.format(d)
@@ -243,7 +257,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),