diff options
author | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2022-05-19 15:19:41 +0200 |
---|---|---|
committer | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2022-05-19 15:19:41 +0200 |
commit | 670ccb6ef406dbf72a7a0a9bfd5cc478606ad654 (patch) | |
tree | 1ce9509295a09af3e827ca0b12c2326141d128cb | |
parent | 06364968a006e69b603f9470a2a21b4b67abc407 (diff) |
meson.build: Avoid configuration warnings
-rw-r--r-- | .gitlab-ci.yml | 8 | ||||
-rw-r--r-- | meson.build | 41 |
2 files changed, 27 insertions, 22 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9bb9ef2..cd96e55 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,6 @@ -# 2022-03-18: ubuntu:latest = 20.04, ubuntu:rolling = 21.10, ubuntu:devel = 22.04 +# 2022-05-19: ubuntu:latest = 22.04, ubuntu:rolling = 22.04, ubuntu:devel = 22.10 # See https://hub.docker.com/_/ubuntu -image: ubuntu:devel +image: ubuntu:rolling stages: - deps @@ -68,7 +68,7 @@ release_gcc_build: - cp -r installdir/usr / - mkdir _build && cd _build # -Ddebug=false + -Doptimization=3 correspond to -Dbuildtype=release - - meson --prefix=/usr --libdir=lib -Ddebug=false -Doptimization=3 -Dwarnings=fatal + - meson --prefix=/usr --libdir=lib -Ddebug=false -Doptimization=3 -Dwarnings=fatal -Dwarning_level=3 -Dwerror=true - meson compile - meson test - meson install @@ -86,7 +86,7 @@ release_clang_build: - cp -r installdir/usr / - mkdir _build && cd _build # -Ddebug=false + -Doptimization=3 correspond to -Dbuildtype=release - - CC=clang CXX=clang++ meson --prefix=/usr --libdir=lib -Ddebug=false -Doptimization=3 -Dwarnings=fatal + - CC=clang CXX=clang++ meson --prefix=/usr --libdir=lib -Ddebug=false -Doptimization=3 -Dwarnings=fatal -Dwarning_level=3 -Dwerror=true - meson compile - meson test - meson install diff --git a/meson.build b/meson.build index 4d1a625..193978a 100644 --- a/meson.build +++ b/meson.build @@ -5,6 +5,7 @@ project('cairomm', 'cpp', license: 'LGPLv2+', default_options: [ 'cpp_std=c++17', + 'warning_level=1', ], meson_version: '>= 0.55.0', # required for meson.add_dist_script(python3, ...) # and meson.add_install_script(python3, ...) @@ -73,10 +74,12 @@ maintainer_mode = maintainer_mode_opt == 'true' or \ if is_dist_check message('Looks like a tarball is being tested. ' + \ 'Option "dist-warnings" is used instead of "warnings".') - warning_level = get_option('dist-warnings') + cpp_warnings = get_option('dist-warnings') else - warning_level = get_option('warnings') + cpp_warnings = get_option('warnings') endif +warning_level = get_option('warning_level').to_int() +werror = get_option('werror') build_deprecated_api = get_option('build-deprecated-api') build_exceptions_api = get_option('build-exceptions-api') build_documentation_opt = get_option('build-documentation') @@ -205,24 +208,25 @@ if not (doc_perl_prop.returncode() == 0 and doc_perl_prop.stdout() == 'false') endif # Set compiler warnings. +# Meson warns if any of the /W1, /W2, /W3, /W4, /Wall, -Wall, -Wextra, -Werror +# compiler options are added with add_project_arguments(). +# Avoid such warnings, when possible. +# See _warn_about_builtin_args() in meson/mesonbuild/interpreter/interpreter.py. warning_flags = [] -if warning_level == 'min' - if is_msvc - warning_flags = ['/W3'] - else - warning_flags = ['-Wall'] +if cpp_warnings == 'min' + if warning_level == 0 + warning_flags = is_msvc ? ['/W2'] : ['-Wall'] endif -elif warning_level == 'max' or warning_level == 'fatal' - if is_msvc - warning_flags = ['/W4'] - else - warning_flags = '-pedantic -Wall -Wextra -Wformat-security -Wsuggest-override -Wzero-as-null-pointer-constant'.split() +elif cpp_warnings == 'max' or cpp_warnings == 'fatal' + if warning_level < 3 + warning_flags = is_msvc ? ['/W4'] : ['-pedantic', '-Wall', '-Wextra'] endif - if warning_level == 'fatal' - if is_msvc - warning_flags += ['/WX'] - else - warning_flags += ['-Werror'] + if not is_msvc + warning_flags += '-Wformat-security -Wsuggest-override -Wzero-as-null-pointer-constant'.split() + endif + if cpp_warnings == 'fatal' + if not werror + warning_flags += is_msvc ? ['/WX'] : ['-Werror'] endif warning_flags += ['-DSIGCXX_DISABLE_DEPRECATED'] endif @@ -348,7 +352,8 @@ summary = [ meson.project_name() + ' ' + meson.project_version(), '', ' Maintainer mode: @0@@1@'.format(maintainer_mode_opt, real_maintainer_mode), - ' Compiler warnings: @0@'.format(warning_level), + ' Compiler warnings: @0@ (warning_level: @1@, werror: @2@)'. \ + format(cpp_warnings, warning_level, werror), ' Build deprecated API: @0@'.format(build_deprecated_api), 'Build HTML documentation: @0@@1@'.format(build_documentation_opt, real_build_documentation), ' Build example programs: @0@'.format(build_examples), |