Skip to content

Commit 5fd04f3

Browse files
committed
meson.build: Avoid configuration warnings
1 parent 164be66 commit 5fd04f3

File tree

3 files changed

+31
-11
lines changed

3 files changed

+31
-11
lines changed

.github/workflows/meson-clang-10.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
sudo pip3 install "meson>=0.55.0"
2121
export CC=clang-10
2222
export CXX=clang++-10
23-
meson -Dwarnings=fatal _build
23+
meson -Dwarnings=fatal -Dwarning_level=3 -Dwerror=true _build
2424
cd _build
2525
meson compile
2626
- name: Test

.github/workflows/meson-gcc-10.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
sudo pip3 install "meson>=0.55.0"
2121
export CC=gcc-10
2222
export CXX=g++-10
23-
meson -Dwarnings=fatal _build
23+
meson -Dwarnings=fatal -Dwarning_level=3 -Dwerror=true _build
2424
cd _build
2525
meson compile
2626
- name: Test

meson.build

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,12 @@ maintainer_mode = maintainer_mode_opt == 'true' or \
7474
if is_dist_check
7575
message('Looks like a tarball is being tested. ' + \
7676
'Option "dist-warnings" is used instead of "warnings".')
77-
warning_level = get_option('dist-warnings')
77+
cpp_warnings = get_option('dist-warnings')
7878
else
79-
warning_level = get_option('warnings')
79+
cpp_warnings = get_option('warnings')
8080
endif
81+
warning_level = get_option('warning_level').to_int()
82+
werror = get_option('werror')
8183
build_deprecated_api = get_option('build-deprecated-api')
8284
build_documentation_opt = get_option('build-documentation')
8385
build_documentation = build_documentation_opt == 'true' or \
@@ -227,14 +229,31 @@ endif
227229
xmlxx_libname = 'xml++' + msvc14x_toolset_ver + '-' + xmlxx_api_version
228230

229231
# Set compiler warnings.
232+
# Meson warns if any of the /W1, /W2, /W3, /W4, /Wall, -Wall, -Wextra, -Werror
233+
# compiler options are added with add_project_arguments().
234+
# Avoid such warnings, when possible.
235+
# See _warn_about_builtin_args() in meson/mesonbuild/interpreter/interpreter.py.
230236
warning_flags = []
231-
if warning_level == 'max' or warning_level == 'fatal'
232-
if is_msvc
233-
warning_flags = ['/W4']
234-
else
235-
warning_flags = '-pedantic -Wall -Wextra -Wformat-security -Wsuggest-override -Wshadow -Wno-long-long'.split()
237+
if cpp_warnings == 'min'
238+
if warning_level == 0
239+
if is_msvc
240+
warning_flags = ['/W2']
241+
else
242+
warning_flags = ['-Wall']
243+
endif
244+
endif
245+
elif cpp_warnings == 'max' or cpp_warnings == 'fatal'
246+
if warning_level < 3
247+
if is_msvc
248+
warning_flags = ['/W4']
249+
else
250+
warning_flags = ['-pedantic', '-Wall', '-Wextra']
251+
endif
252+
endif
253+
if not is_msvc
254+
warning_flags += '-Wformat-security -Wsuggest-override -Wshadow -Wno-long-long'.split()
236255
endif
237-
if warning_level == 'fatal'
256+
if cpp_warnings == 'fatal' and not werror
238257
if is_msvc
239258
warning_flags += ['/WX']
240259
else
@@ -387,7 +406,8 @@ summary = [
387406
meson.project_name() + ' ' + meson.project_version(),
388407
'',
389408
' Maintainer mode: @0@@1@'.format(maintainer_mode_opt, real_maintainer_mode),
390-
' Compiler warnings: @0@'.format(warning_level),
409+
' Compiler warnings: @0@ (warning_level: @1@, werror: @2@)'. \
410+
format(cpp_warnings, warning_level, werror),
391411
' Build deprecated API: @0@'.format(build_deprecated_api),
392412
'Build HTML documentation: @0@@1@'.format(build_documentation_opt, real_build_documentation),
393413
' XML validation: @0@@1@'.format(validate, explain_val),

0 commit comments

Comments
 (0)