Skip to content

Commit fb8038c

Browse files
committed
meson.build: Avoid configuration warnings
1 parent 7f9e836 commit fb8038c

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++11',
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 \
@@ -155,25 +157,24 @@ if not (doc_perl_prop.returncode() == 0 and doc_perl_prop.stdout() == 'false')
155157
endif
156158

157159
# Set compiler warnings.
160+
# Meson warns if any of the /W1, /W2, /W3, /W4, /Wall, -Wall, -Wextra, -Werror
161+
# compiler options are added with add_project_arguments().
162+
# Avoid such warnings, when possible.
163+
# See _warn_about_builtin_args() in meson/mesonbuild/interpreter/interpreter.py.
158164
warning_flags = []
159-
if warning_level == 'min'
160-
if is_msvc
161-
warning_flags = ['/W3']
162-
else
163-
warning_flags = ['-Wall']
165+
if cpp_warnings == 'min'
166+
if warning_level == 0
167+
warning_flags = is_msvc ? ['/W2'] : ['-Wall']
168+
endif
169+
elif cpp_warnings == 'max' or cpp_warnings == 'fatal'
170+
if warning_level < 3
171+
warning_flags = is_msvc ? ['/W4'] : ['-pedantic', '-Wall', '-Wextra']
164172
endif
165-
elif warning_level == 'max' or warning_level == 'fatal'
166-
if is_msvc
167-
warning_flags = ['/W4']
168-
else
169-
warning_flags = '-pedantic -Wall -Wextra -Wsuggest-override -Wshadow -Wzero-as-null-pointer-constant -Wformat-security'.split()
173+
if not is_msvc
174+
warning_flags += '-Wsuggest-override -Wshadow -Wzero-as-null-pointer-constant -Wformat-security'.split()
170175
endif
171-
if warning_level == 'fatal'
172-
if is_msvc
173-
warning_flags += ['/WX']
174-
else
175-
warning_flags += ['-Werror']
176-
endif
176+
if cpp_warnings == 'fatal' and not werror
177+
warning_flags += is_msvc ? ['/WX'] : ['-Werror']
177178
endif
178179
endif
179180

@@ -310,7 +311,8 @@ summary = [
310311
meson.project_name() + ' ' + meson.project_version(),
311312
'',
312313
' Maintainer mode: @0@@1@'.format(maintainer_mode_opt, real_maintainer_mode),
313-
' Compiler warnings: @0@'.format(warning_level),
314+
' Compiler warnings: @0@ (warning_level: @1@, werror: @2@)'. \
315+
format(cpp_warnings, warning_level, werror),
314316
' Build deprecated API: @0@'.format(build_deprecated_api),
315317
'Build HTML documentation: @0@@1@'.format(build_documentation_opt, real_build_documentation),
316318
' XML validation: @0@@1@'.format(validate, explain_val),

0 commit comments

Comments
 (0)