@@ -74,10 +74,12 @@ maintainer_mode = maintainer_mode_opt == 'true' or \
74
74
if is_dist_check
75
75
message (' Looks like a tarball is being tested. ' + \
76
76
' Option "dist-warnings" is used instead of "warnings".' )
77
- warning_level = get_option (' dist-warnings' )
77
+ cpp_warnings = get_option (' dist-warnings' )
78
78
else
79
- warning_level = get_option (' warnings' )
79
+ cpp_warnings = get_option (' warnings' )
80
80
endif
81
+ warning_level = get_option (' warning_level' ).to_int()
82
+ werror = get_option (' werror' )
81
83
build_deprecated_api = get_option (' build-deprecated-api' )
82
84
build_documentation_opt = get_option (' build-documentation' )
83
85
build_documentation = build_documentation_opt == ' true' or \
@@ -227,14 +229,31 @@ endif
227
229
xmlxx_libname = ' xml++' + msvc14x_toolset_ver + ' -' + xmlxx_api_version
228
230
229
231
# 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.
230
236
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()
236
255
endif
237
- if warning_level == ' fatal'
256
+ if cpp_warnings == ' fatal' and not werror
238
257
if is_msvc
239
258
warning_flags += [' /WX' ]
240
259
else
@@ -387,7 +406,8 @@ summary = [
387
406
meson .project_name() + ' ' + meson .project_version(),
388
407
'' ,
389
408
' 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),
391
411
' Build deprecated API: @0@' .format(build_deprecated_api),
392
412
' Build HTML documentation: @0@@1@' .format(build_documentation_opt, real_build_documentation),
393
413
' XML validation: @0@@1@' .format(validate, explain_val),
0 commit comments