@@ -5,7 +5,7 @@ project('libsigc++', 'cpp',
5
5
license : ' LGPLv2.1+' ,
6
6
default_options : [
7
7
' cpp_std=c++17' ,
8
- ' warning_level=0 ' ,
8
+ ' warning_level=1 ' ,
9
9
],
10
10
meson_version : ' >= 0.55.0' , # required for meson.add_dist_script(python3, ...)
11
11
# and meson.add_install_script(python3, ...)
@@ -70,10 +70,12 @@ maintainer_mode = maintainer_mode_opt == 'true' or \
70
70
if is_dist_check
71
71
message (' Looks like a tarball is being tested. ' + \
72
72
' Option "dist-warnings" is used instead of "warnings".' )
73
- warning_level = get_option (' dist-warnings' )
73
+ cpp_warnings = get_option (' dist-warnings' )
74
74
else
75
- warning_level = get_option (' warnings' )
75
+ cpp_warnings = get_option (' warnings' )
76
76
endif
77
+ warning_level = get_option (' warning_level' ).to_int()
78
+ werror = get_option (' werror' )
77
79
build_deprecated_api = get_option (' build-deprecated-api' )
78
80
build_documentation_opt = get_option (' build-documentation' )
79
81
build_documentation = build_documentation_opt == ' true' or \
@@ -159,25 +161,24 @@ if not (doc_perl_prop.returncode() == 0 and doc_perl_prop.stdout() == 'false')
159
161
endif
160
162
161
163
# 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.
162
168
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' ]
168
176
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()
174
179
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' ]
181
182
endif
182
183
endif
183
184
@@ -307,7 +308,8 @@ summary = [
307
308
meson .project_name() + ' ' + meson .project_version(),
308
309
'' ,
309
310
' 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),
311
313
' Build deprecated API: @0@' .format(build_deprecated_api),
312
314
' Build HTML documentation: @0@@1@' .format(build_documentation_opt, real_build_documentation),
313
315
' XML validation: @0@@1@' .format(validate, explain_val),
0 commit comments