@@ -4,7 +4,8 @@ project('libxml++', 'cpp',
4
4
version : ' 2.42.1' ,
5
5
license : ' LGPLv2.1+' ,
6
6
default_options : [
7
- ' cpp_std=c++11'
7
+ ' cpp_std=c++11' ,
8
+ ' warning_level=1' ,
8
9
],
9
10
meson_version : ' >= 0.55.0' , # required for meson.add_dist_script(python3, ...)
10
11
# and meson.add_install_script(python3, ...)
@@ -73,10 +74,12 @@ maintainer_mode = maintainer_mode_opt == 'true' or \
73
74
if is_dist_check
74
75
message (' Looks like a tarball is being tested. ' + \
75
76
' Option "dist-warnings" is used instead of "warnings".' )
76
- warning_level = get_option (' dist-warnings' )
77
+ cpp_warnings = get_option (' dist-warnings' )
77
78
else
78
- warning_level = get_option (' warnings' )
79
+ cpp_warnings = get_option (' warnings' )
79
80
endif
81
+ warning_level = get_option (' warning_level' ).to_int()
82
+ werror = get_option (' werror' )
80
83
build_deprecated_api = get_option (' build-deprecated-api' )
81
84
build_documentation_opt = get_option (' build-documentation' )
82
85
build_documentation = build_documentation_opt == ' true' or \
@@ -237,24 +240,37 @@ endif
237
240
xmlxx_libname = ' xml++' + msvc14x_toolset_ver + ' -' + xmlxx_api_version
238
241
239
242
# Set compiler warnings.
243
+ # Meson warns if any of the /W1, /W2, /W3, /W4, /Wall, -Wall, -Wextra, -Werror
244
+ # compiler options are added with add_project_arguments().
245
+ # Avoid such warnings, when possible.
246
+ # See _warn_about_builtin_args() in meson/mesonbuild/interpreter/interpreter.py.
240
247
warning_flags = []
241
- if warning_level == ' min'
242
- if is_msvc
243
- warning_flags = [' /W3' ]
244
- else
245
- warning_flags = [' -Wall' ]
246
- endif
247
- elif warning_level == ' max' or warning_level == ' fatal'
248
- if is_msvc
249
- warning_flags = [' /W4' ]
250
- else
251
- warning_flags = ' -pedantic -Wall -Wextra -Wformat-security -Wshadow -Wno-long-long' .split()
248
+ if cpp_warnings == ' min'
249
+ if warning_level == 0
250
+ if is_msvc
251
+ warning_flags = [' /W2' ]
252
+ else
253
+ warning_flags = [' -Wall' ]
254
+ endif
252
255
endif
253
- if warning_level == ' fatal'
256
+ elif cpp_warnings == ' max' or cpp_warnings == ' fatal'
257
+ if warning_level < 3
254
258
if is_msvc
255
- warning_flags + = [' /WX ' ]
259
+ warning_flags = [' /W4 ' ]
256
260
else
257
- warning_flags += [' -Werror' ]
261
+ warning_flags = [' -pedantic' , ' -Wall' , ' -Wextra' ]
262
+ endif
263
+ endif
264
+ if not is_msvc
265
+ warning_flags += ' -Wformat-security -Wshadow -Wno-long-long' .split()
266
+ endif
267
+ if cpp_warnings == ' fatal'
268
+ if not werror
269
+ if is_msvc
270
+ warning_flags += [' /WX' ]
271
+ else
272
+ warning_flags += [' -Werror' ]
273
+ endif
258
274
endif
259
275
deprecations = ' G GLIBMM SIGCXX' .split()
260
276
foreach d : deprecations
@@ -404,7 +420,8 @@ summary = [
404
420
meson .project_name() + ' ' + meson .project_version(),
405
421
'' ,
406
422
' Maintainer mode: @0@@1@' .format(maintainer_mode_opt, real_maintainer_mode),
407
- ' Compiler warnings: @0@' .format(warning_level),
423
+ ' Compiler warnings: @0@ (warning_level: @1@, werror: @2@)' . \
424
+ format(cpp_warnings, warning_level, werror),
408
425
' Build deprecated API: @0@' .format(build_deprecated_api),
409
426
' Build HTML documentation: @0@@1@' .format(build_documentation_opt, real_build_documentation),
410
427
' XML validation: @0@@1@' .format(validate, explain_val),
0 commit comments