@@ -5,7 +5,7 @@ project('libsigc++', 'cpp',
5
5
license : ' LGPLv2.1+' ,
6
6
default_options : [
7
7
' cpp_std=c++11' ,
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 \
@@ -155,25 +157,24 @@ if not (doc_perl_prop.returncode() == 0 and doc_perl_prop.stdout() == 'false')
155
157
endif
156
158
157
159
# 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.
158
164
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' ]
164
172
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()
170
175
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' ]
177
178
endif
178
179
endif
179
180
@@ -310,7 +311,8 @@ summary = [
310
311
meson .project_name() + ' ' + meson .project_version(),
311
312
'' ,
312
313
' 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),
314
316
' Build deprecated API: @0@' .format(build_deprecated_api),
315
317
' Build HTML documentation: @0@@1@' .format(build_documentation_opt, real_build_documentation),
316
318
' XML validation: @0@@1@' .format(validate, explain_val),
0 commit comments