Skip to content

Commit f523c0c

Browse files
committed
meson.build: Avoid configuration warnings
1 parent 6952ddd commit f523c0c

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

meson.build

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ project('libsigc++', 'cpp',
55
license: 'LGPLv2.1+',
66
default_options: [
77
'cpp_std=c++17',
8-
'warning_level=0',
8+
'warning_level=1',
99
],
1010
meson_version: '>= 0.55.0', # required for meson.add_dist_script(python3, ...)
1111
# and meson.add_install_script(python3, ...)
@@ -70,10 +70,12 @@ maintainer_mode = maintainer_mode_opt == 'true' or \
7070
if is_dist_check
7171
message('Looks like a tarball is being tested. ' + \
7272
'Option "dist-warnings" is used instead of "warnings".')
73-
warning_level = get_option('dist-warnings')
73+
cpp_warnings = get_option('dist-warnings')
7474
else
75-
warning_level = get_option('warnings')
75+
cpp_warnings = get_option('warnings')
7676
endif
77+
warning_level = get_option('warning_level').to_int()
78+
werror = get_option('werror')
7779
build_deprecated_api = get_option('build-deprecated-api')
7880
build_documentation_opt = get_option('build-documentation')
7981
build_documentation = build_documentation_opt == 'true' or \
@@ -159,25 +161,24 @@ if not (doc_perl_prop.returncode() == 0 and doc_perl_prop.stdout() == 'false')
159161
endif
160162

161163
# Set compiler warnings.
164+
# Meson warns if any of the /W1, /W2, /W3, /W4, /Wall, -Wall, -Wextra, -Werror
165+
# compiler options are added with add_project_arguments().
166+
# Avoid such warnings, when possible.
167+
# See _warn_about_builtin_args() in meson/mesonbuild/interpreter/interpreter.py.
162168
warning_flags = []
163-
if warning_level == 'min'
164-
if is_msvc
165-
warning_flags = ['/W3']
166-
else
167-
warning_flags = ['-Wall']
169+
if cpp_warnings == 'min'
170+
if warning_level == 0
171+
warning_flags = is_msvc ? ['/W2'] : ['-Wall']
172+
endif
173+
elif cpp_warnings == 'max' or cpp_warnings == 'fatal'
174+
if warning_level < 3
175+
warning_flags = is_msvc ? ['/W4'] : ['-pedantic', '-Wall', '-Wextra']
168176
endif
169-
elif warning_level == 'max' or warning_level == 'fatal'
170-
if is_msvc
171-
warning_flags = ['/W4']
172-
else
173-
warning_flags = '-pedantic -Wall -Wextra -Wsuggest-override -Wshadow -Wzero-as-null-pointer-constant -Wformat-security'.split()
177+
if not is_msvc
178+
warning_flags += '-Wsuggest-override -Wshadow -Wzero-as-null-pointer-constant -Wformat-security'.split()
174179
endif
175-
if warning_level == 'fatal'
176-
if is_msvc
177-
warning_flags += ['/WX']
178-
else
179-
warning_flags += ['-Werror']
180-
endif
180+
if cpp_warnings == 'fatal' and not werror
181+
warning_flags += is_msvc ? ['/WX'] : ['-Werror']
181182
endif
182183
endif
183184

@@ -307,7 +308,8 @@ summary = [
307308
meson.project_name() + ' ' + meson.project_version(),
308309
'',
309310
' Maintainer mode: @0@@1@'.format(maintainer_mode_opt, real_maintainer_mode),
310-
' Compiler warnings: @0@'.format(warning_level),
311+
' Compiler warnings: @0@ (warning_level: @1@, werror: @2@)'. \
312+
format(cpp_warnings, warning_level, werror),
311313
' Build deprecated API: @0@'.format(build_deprecated_api),
312314
'Build HTML documentation: @0@@1@'.format(build_documentation_opt, real_build_documentation),
313315
' XML validation: @0@@1@'.format(validate, explain_val),

0 commit comments

Comments
 (0)