Skip to content

Commit 75d0c99

Browse files
committed
meson.build: Avoid configuration warnings
1 parent 0f9bdf6 commit 75d0c99

File tree

1 file changed

+35
-18
lines changed

1 file changed

+35
-18
lines changed

meson.build

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ project('libxml++', 'cpp',
44
version: '2.42.1',
55
license: 'LGPLv2.1+',
66
default_options: [
7-
'cpp_std=c++11'
7+
'cpp_std=c++11',
8+
'warning_level=1',
89
],
910
meson_version: '>= 0.55.0', # required for meson.add_dist_script(python3, ...)
1011
# and meson.add_install_script(python3, ...)
@@ -73,10 +74,12 @@ maintainer_mode = maintainer_mode_opt == 'true' or \
7374
if is_dist_check
7475
message('Looks like a tarball is being tested. ' + \
7576
'Option "dist-warnings" is used instead of "warnings".')
76-
warning_level = get_option('dist-warnings')
77+
cpp_warnings = get_option('dist-warnings')
7778
else
78-
warning_level = get_option('warnings')
79+
cpp_warnings = get_option('warnings')
7980
endif
81+
warning_level = get_option('warning_level').to_int()
82+
werror = get_option('werror')
8083
build_deprecated_api = get_option('build-deprecated-api')
8184
build_documentation_opt = get_option('build-documentation')
8285
build_documentation = build_documentation_opt == 'true' or \
@@ -237,24 +240,37 @@ endif
237240
xmlxx_libname = 'xml++' + msvc14x_toolset_ver + '-' + xmlxx_api_version
238241

239242
# Set compiler warnings.
243+
# Meson warns if any of the /W1, /W2, /W3, /W4, /Wall, -Wall, -Wextra, -Werror
244+
# compiler options are added with add_project_arguments().
245+
# Avoid such warnings, when possible.
246+
# See _warn_about_builtin_args() in meson/mesonbuild/interpreter/interpreter.py.
240247
warning_flags = []
241-
if warning_level == 'min'
242-
if is_msvc
243-
warning_flags = ['/W3']
244-
else
245-
warning_flags = ['-Wall']
246-
endif
247-
elif warning_level == 'max' or warning_level == 'fatal'
248-
if is_msvc
249-
warning_flags = ['/W4']
250-
else
251-
warning_flags = '-pedantic -Wall -Wextra -Wformat-security -Wshadow -Wno-long-long'.split()
248+
if cpp_warnings == 'min'
249+
if warning_level == 0
250+
if is_msvc
251+
warning_flags = ['/W2']
252+
else
253+
warning_flags = ['-Wall']
254+
endif
252255
endif
253-
if warning_level == 'fatal'
256+
elif cpp_warnings == 'max' or cpp_warnings == 'fatal'
257+
if warning_level < 3
254258
if is_msvc
255-
warning_flags += ['/WX']
259+
warning_flags = ['/W4']
256260
else
257-
warning_flags += ['-Werror']
261+
warning_flags = ['-pedantic', '-Wall', '-Wextra']
262+
endif
263+
endif
264+
if not is_msvc
265+
warning_flags += '-Wformat-security -Wshadow -Wno-long-long'.split()
266+
endif
267+
if cpp_warnings == 'fatal'
268+
if not werror
269+
if is_msvc
270+
warning_flags += ['/WX']
271+
else
272+
warning_flags += ['-Werror']
273+
endif
258274
endif
259275
deprecations = 'G GLIBMM SIGCXX'.split()
260276
foreach d : deprecations
@@ -404,7 +420,8 @@ summary = [
404420
meson.project_name() + ' ' + meson.project_version(),
405421
'',
406422
' Maintainer mode: @0@@1@'.format(maintainer_mode_opt, real_maintainer_mode),
407-
' Compiler warnings: @0@'.format(warning_level),
423+
' Compiler warnings: @0@ (warning_level: @1@, werror: @2@)'. \
424+
format(cpp_warnings, warning_level, werror),
408425
' Build deprecated API: @0@'.format(build_deprecated_api),
409426
'Build HTML documentation: @0@@1@'.format(build_documentation_opt, real_build_documentation),
410427
' XML validation: @0@@1@'.format(validate, explain_val),

0 commit comments

Comments
 (0)