diff options
author | David Robillard <d@drobilla.net> | 2022-05-28 21:08:59 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-05-28 22:06:25 -0400 |
commit | 574bf1e11d73059ec5e6099e6806d919e1ac22b0 (patch) | |
tree | 58501a867689c2a02da561503f995adde832e202 | |
parent | 460b036a8b87f5fb939088a56e3fadc5395ec90a (diff) | |
download | pugl-574bf1e11d73059ec5e6099e6806d919e1ac22b0.tar.gz pugl-574bf1e11d73059ec5e6099e6806d919e1ac22b0.tar.bz2 pugl-574bf1e11d73059ec5e6099e6806d919e1ac22b0.zip |
Clean up and strengthen warning flags
-rw-r--r-- | examples/meson.build | 15 | ||||
-rw-r--r-- | examples/pugl_vulkan_cpp_demo.cpp | 2 | ||||
-rw-r--r-- | examples/shaders/meson.build | 6 | ||||
-rw-r--r-- | meson.build | 316 | ||||
-rw-r--r-- | meson/meson.build | 124 | ||||
-rw-r--r-- | meson_options.txt | 5 | ||||
-rw-r--r-- | test/meson.build | 9 | ||||
-rw-r--r-- | test/test_inline_cpp.cpp | 23 |
8 files changed, 304 insertions, 196 deletions
diff --git a/examples/meson.build b/examples/meson.build index a981cdd..db93f64 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -38,13 +38,12 @@ if get_option('strict') if cc.get_id() == 'clang' example_c_args += [ '-Wno-float-equal', - '-Wno-padded', '-Wno-reserved-id-macro', + '-Wno-reserved-identifier', ] elif cc.get_id() == 'gcc' example_c_args += [ '-Wno-float-equal', - '-Wno-padded', ] endif @@ -53,25 +52,29 @@ endif # Suppress some additional C++ warnings in examples example_cpp_args = [] -if is_variable('cpp') +if get_option('strict') and is_variable('cpp') if cpp.get_id() == 'clang' example_cpp_args += [ '-Wno-documentation', # Cairo '-Wno-documentation-unknown-command', # Cairo '-Wno-old-style-cast', - '-Wno-padded', '-Wno-switch-enum', ] elif cpp.get_id() == 'gcc' example_cpp_args += [ '-Wno-effc++', '-Wno-old-style-cast', - '-Wno-padded', '-Wno-switch-default', '-Wno-switch-enum', '-Wno-unused-const-variable', '-Wno-useless-cast', ] + elif cpp.get_id() == 'msvc' + example_cpp_args += [ + '/wd4355', # 'this' used in base member initializer list + '/wd4868', # may not enforce left-to-right evaluation order + '/wd5246', # subobject initialization should be wrapped in braces + ] endif example_cpp_args = cpp.get_supported_arguments(example_cpp_args) @@ -150,7 +153,7 @@ else target = example.split('.')[0] executable(target, example, include_directories: includes, - c_args: example_defines + example_c_args, + c_args: example_defines + example_c_args + cairo_args, dependencies: [pugl_dep, cairo_backend_dep]) endforeach endif diff --git a/examples/pugl_vulkan_cpp_demo.cpp b/examples/pugl_vulkan_cpp_demo.cpp index fe86c30..69f360d 100644 --- a/examples/pugl_vulkan_cpp_demo.cpp +++ b/examples/pugl_vulkan_cpp_demo.cpp @@ -1716,7 +1716,7 @@ run(const char* const programPath, app.world.setClassName("PuglVulkanCppDemo"); app.view.setWindowTitle("Pugl Vulkan C++ Demo"); app.view.setSizeHint(pugl::SizeHint::defaultSize, width, height); - app.view.setSizeHint(pugl::SizeHint::minSize, width / 4, height / 4); + app.view.setSizeHint(pugl::SizeHint::minSize, width / 4u, height / 4u); app.view.setBackend(pugl::vulkanBackend()); app.view.setHint(pugl::ViewHint::resizable, opts.resizable); const pugl::Status st = app.view.realize(); diff --git a/examples/shaders/meson.build b/examples/shaders/meson.build index 2fdd946..9121e97 100644 --- a/examples/shaders/meson.build +++ b/examples/shaders/meson.build @@ -32,17 +32,19 @@ if vulkan_dep.found() build_by_default: true, capture: true) + glslang_command = [glslang, '-V', '-o', '@OUTPUT@', '@INPUT@'] + rect_vert_spv = custom_target('rect.vert.spv', output: 'rect.vert.spv', input: rect_vulkan_vert, - command: [glslang, '-V', '-o', '@OUTPUT@', '@INPUT@'], + command: glslang_command, build_by_default: true, install: false) rect_frag_spv = custom_target('rect.frag.spv', output: 'rect.frag.spv', input: rect_vulkan_frag, - command: [glslang, '-V', '-o', '@OUTPUT@', '@INPUT@'], + command: glslang_command, build_by_default: true, install: false) endif diff --git a/meson.build b/meson.build index e84bde1..727a1a4 100644 --- a/meson.build +++ b/meson.build @@ -6,9 +6,10 @@ project('pugl', ['c'], license: 'ISC', meson_version: '>= 0.49.2', default_options: [ + 'b_ndebug=if-release', + 'buildtype=release', 'c_std=c99', 'cpp_std=c++14', - 'default_library=shared' ]) pugl_src_root = meson.current_source_dir() @@ -16,7 +17,11 @@ major_version = meson.project_version().split('.')[0] version_suffix = '-@0@'.format(major_version) versioned_name = 'pugl' + version_suffix -# Load build tools +####################### +# Compilers and Flags # +####################### + +# Required tools pkg = import('pkgconfig') cc = meson.get_compiler('c') @@ -35,17 +40,16 @@ endif # Set ultra strict warnings for developers, if requested # These are for the implementation, tests and examples add more suppressions +c_warnings = [] if get_option('strict') subdir('meson') + # C warnings c_warnings = all_c_warnings if cc.get_id() == 'clang' c_warnings += [ '-Wno-bad-function-cast', - '-Wno-documentation', # Cairo - '-Wno-documentation-unknown-command', # Cairo '-Wno-padded', - '-Wno-reserved-identifier', # Cairo, FD_ZERO '-Wno-switch-default', '-Wno-switch-enum', ] @@ -68,6 +72,7 @@ if get_option('strict') '-Wno-float-equal', '-Wno-inline', '-Wno-padded', + '-Wno-pedantic', '-Wno-suggest-attribute=const', '-Wno-suggest-attribute=malloc', '-Wno-suggest-attribute=pure', @@ -78,34 +83,80 @@ if get_option('strict') if host_machine.system() == 'windows' c_warnings += [ + '-Wno-cast-function-type', '-Wno-suggest-attribute=format', ] endif elif cc.get_id() == 'msvc' c_warnings += [ - '/wd4061', # enumerator in switch is not explicitly handled - '/wd4191', # unsafe conversion from type to type - '/wd4514', # unreferenced inline function has been removed - '/wd4706', # assignment within conditional expression - '/wd4710', # function not inlined - '/wd4711', # function selected for automatic inline expansion - '/wd4820', # padding added after construct - '/wd4996', # POSIX name for this item is deprecated - '/wd5045', # will insert Spectre mitigation for memory load + '/wd4061', # enumerator in switch is not explicitly handled + '/wd4191', # unsafe conversion from type to type + '/wd4514', # unreferenced inline function has been removed + '/wd4706', # assignment within conditional expression + '/wd4710', # function not inlined + '/wd4711', # function selected for automatic inline expansion + '/wd4820', # padding added after construct + '/wd4996', # POSIX name for this item is deprecated + '/wd5045', # will insert Spectre mitigation for memory load + '/wd5246', # subobject initialization should be wrapped in braces ] endif add_project_arguments(cc.get_supported_arguments(c_warnings), - language: ['c', 'objc']) + language: ['c']) + + # C++ warnings + if is_variable('cpp') + cpp_warnings = all_cpp_warnings + + if cpp.get_id() == 'clang' + cpp_warnings += [ + '-Wno-inline', + '-Wno-padded', + ] + + if host_machine.system() == 'darwin' + cpp_warnings += [ + '-Wno-poison-system-directories', + ] + endif + + elif cpp.get_id() == 'gcc' + cpp_warnings += [ + '-Wno-inline', + '-Wno-padded', + ] + elif cpp.get_id() == 'msvc' + cpp_warnings += [ + '/wd4061', # enumerator in switch is not explicitly handled + '/wd4191', # unsafe conversion from type to type + '/wd4514', # unreferenced inline function has been removed + '/wd4625', # copy constructor implicitly deleted + '/wd4626', # copy assignment operator implicitly deleted + '/wd4706', # assignment within conditional expression + '/wd4710', # function not inlined + '/wd4711', # function selected for automatic inline expansion + '/wd4800', # implicit conversion to bool + '/wd4820', # padding added after construct + '/wd5026', # move constructor implicitly deleted + '/wd5027', # move assignment operator implicitly deleted + '/wd5039', # pointer to potentially throwing function passed to C + '/wd5045', # will insert Spectre mitigation for memory load + ] + endif + + add_project_arguments(cpp.get_supported_arguments(cpp_warnings), + language: ['cpp']) + endif # Objective C warnings if is_variable('objcc') - objc_warnings = all_objc_warnings - - objc_warnings += [ - '-Wno-deprecated-declarations', + objc_warnings = all_objc_warnings + [ + '-Wno-bad-function-cast', '-Wno-direct-ivar-access', + '-Wno-padded', '-Wno-pedantic', + '-Wno-poison-system-directories', ] add_project_arguments(objcc.get_supported_arguments(objc_warnings), @@ -117,24 +168,12 @@ endif add_project_arguments(['-DPUGL_DISABLE_DEPRECATED'], language: ['c', 'cpp', 'objc']) -# System libraries -m_dep = cc.find_library('m', required: false) -dl_dep = cc.find_library('dl', required: false) -thread_dep = dependency('threads') - -# Cairo (optional backend) -cairo_dep = dependency('cairo', - required: get_option('cairo')) - -# OpenGL (optional backend) -opengl_dep = dependency('GL', - required: get_option('opengl')) - -# Vulkan (optional backend) -vulkan_dep = dependency('vulkan', - required: get_option('vulkan')) +############# +# Platforms # +############# core_args = [] +dl_dep = cc.find_library('dl', required: false) # MacOS if host_machine.system() == 'darwin' @@ -146,11 +185,9 @@ if host_machine.system() == 'darwin' core_deps = [cocoa_dep, corevideo_dep] extension = '.m' - add_project_arguments(['-DGL_SILENCE_DEPRECATION'], - language: ['c', 'objc']) - - add_project_link_arguments(['-Wl,-framework,Cocoa'], - language: ['c', 'objc']) + add_project_arguments(['-Wno-deprecated-declarations'], language: ['c', 'objc']) + add_project_arguments(['-DGL_SILENCE_DEPRECATION'], language: ['c', 'objc']) + add_project_link_arguments(['-Wl,-framework,Cocoa'], language: ['c', 'objc']) # Windows elif host_machine.system() == 'windows' @@ -204,16 +241,28 @@ else # X11 endif endif + x11_args = [] + if cc.get_id() == 'clang' + x11_args += [ + '-Wno-reserved-identifier', # FD_ZERO + ] + endif + + core_args += cc.get_supported_arguments(x11_args) + platform = 'x11' platform_sources = files('src/x11.c') core_deps = [x11_dep, xcursor_dep, xrandr_dep, xext_dep] extension = '.c' endif -# Build core library +################ +# Core Library # +################ -core_deps += [m_dep] +core_deps += [cc.find_library('m', required: false)] core_name = 'pugl_@0@@1@'.format(platform, version_suffix) +includes = include_directories(['include']) # Determine library type and set up defines for building them library_args = ['-DPUGL_INTERNAL'] @@ -230,12 +279,11 @@ else add_project_arguments(['-DPUGL_STATIC'], language: ['c', 'cpp', 'objc']) endif -# Build core library libpugl = build_target( core_name, files('src/implementation.c') + platform_sources, version: meson.project_version(), - include_directories: include_directories(['include']), + include_directories: includes, c_args: library_args + core_args, dependencies: core_deps, gnu_symbol_visibility: 'hidden', @@ -244,7 +292,6 @@ libpugl = build_target( pugl_dep = declare_dependency(link_with: libpugl, dependencies: core_deps) -# Build pkg-config file pkg.generate(libpugl, name: 'Pugl', filebase: versioned_name, @@ -252,44 +299,49 @@ pkg.generate(libpugl, version: meson.project_version(), description: 'Pugl GUI library core') -# Build stub backend - -name = 'pugl_' + platform + '_stub' + version_suffix -sources = files('src/' + platform + '_stub' + extension) - -stub_backend = build_target( - name, sources, - version: meson.project_version(), - include_directories: include_directories(['include']), - c_args: library_args, - dependencies: [pugl_dep], - gnu_symbol_visibility: 'hidden', - install: true, - target_type: library_type) - -stub_backend_dep = declare_dependency(link_with: stub_backend) - -pkg.generate(stub_backend, - name: 'Pugl Stub', - filebase: 'pugl-stub-@0@'.format(major_version), - subdirs: [versioned_name], - version: meson.project_version(), - description: 'Native window pugl graphics backend') +############ +# Backends # +############ + +# Stub +if get_option('stub') + name = 'pugl_' + platform + '_stub' + version_suffix + sources = files('src/' + platform + '_stub' + extension) + + stub_backend = build_target(name, sources, + version: meson.project_version(), + include_directories: includes, + c_args: library_args, + dependencies: [pugl_dep], + gnu_symbol_visibility: 'hidden', + install: true, + target_type: library_type) + + stub_backend_dep = declare_dependency(link_with: stub_backend, + dependencies: [pugl_dep]) + + pkg.generate(stub_backend, + name: 'Pugl Stub', + filebase: 'pugl-stub-@0@'.format(major_version), + subdirs: [versioned_name], + version: meson.project_version(), + description: 'Native window pugl graphics backend') +endif -# Build GL backend +# OpenGL +opengl_dep = dependency('GL', required: get_option('opengl')) if opengl_dep.found() name = 'pugl_' + platform + '_gl' + version_suffix sources = files('src/' + platform + '_gl' + extension) - gl_backend = build_target( - name, sources, - version: meson.project_version(), - include_directories: include_directories(['include']), - c_args: library_args, - dependencies: [pugl_dep, opengl_dep], - gnu_symbol_visibility: 'hidden', - install: true, - target_type: library_type) + gl_backend = build_target(name, sources, + version: meson.project_version(), + include_directories: includes, + c_args: library_args, + dependencies: [pugl_dep, opengl_dep], + gnu_symbol_visibility: 'hidden', + install: true, + target_type: library_type) gl_backend_dep = declare_dependency(link_with: gl_backend, dependencies: [pugl_dep, opengl_dep]) @@ -302,24 +354,34 @@ if opengl_dep.found() description: 'Pugl GUI library with OpenGL backend') endif -# Build Cairo backend +# Cairo +cairo_dep = dependency('cairo', required: get_option('cairo')) if cairo_dep.found() name = 'pugl_' + platform + '_cairo' + version_suffix sources = files('src/' + platform + '_cairo' + extension) - cairo_backend = build_target( - name, sources, - version: meson.project_version(), - include_directories: include_directories(['include']), - c_args: library_args, - dependencies: [pugl_dep, cairo_dep], - gnu_symbol_visibility: 'hidden', - install: true, - target_type: library_type) + cairo_args = [] + if cc.get_id() == 'clang' + cairo_args += [ + '-Wno-documentation', + '-Wno-documentation-unknown-command', + '-Wno-reserved-identifier', + ] + endif + + cairo_args = cc.get_supported_arguments(cairo_args) + + cairo_backend = build_target(name, sources, + version: meson.project_version(), + include_directories: includes, + c_args: library_args + cairo_args, + dependencies: [pugl_dep, cairo_dep], + gnu_symbol_visibility: 'hidden', + install: true, + target_type: library_type) - cairo_backend_dep = declare_dependency( - link_with: cairo_backend, - dependencies: [pugl_dep, cairo_dep]) + cairo_backend_dep = declare_dependency(link_with: cairo_backend, + dependencies: [pugl_dep, cairo_dep]) pkg.generate(cairo_backend, name: 'Pugl Cairo', @@ -329,30 +391,32 @@ if cairo_dep.found() description: 'Pugl GUI library with Cairo backend') endif -# Build Vulkan backend +# Vulkan +vulkan_dep = dependency('vulkan', required: get_option('vulkan')) if vulkan_dep.found() name = 'pugl_' + platform + '_vulkan' + version_suffix sources = files('src/' + platform + '_vulkan' + extension) + thread_dep = dependency('threads') + vulkan_deps = [pugl_dep, vulkan_dep, dl_dep] vulkan_c_args = library_args vulkan_link_args = [] if platform == 'mac' - metal_dep = dependency('Metal', modules: 'foundation') - quartzcore_dep = dependency('QuartzCore', modules: 'foundation') - - vulkan_deps += [metal_dep, quartzcore_dep] + vulkan_deps += [ + dependency('Metal', modules: 'foundation'), + dependency('QuartzCore', modules: 'foundation'), + ] endif - vulkan_backend = build_target( - name, sources, - version: meson.project_version(), - include_directories: include_directories(['include']), - c_args: library_args, - dependencies: vulkan_deps, - gnu_symbol_visibility: 'hidden', - install: true, - target_type: library_type) + vulkan_backend = build_target(name, sources, + version: meson.project_version(), + include_directories: includes, + c_args: library_args, + dependencies: vulkan_deps, + gnu_symbol_visibility: 'hidden', + install: true, + target_type: library_type) vulkan_backend_dep = declare_dependency( link_with: vulkan_backend, @@ -366,38 +430,52 @@ if vulkan_dep.found() description: 'Pugl GUI library with Vulkan backend') endif -# Process all headers first so they are available for building documentation +############################### +# Public Headers and Bindings # +############################### + subdir('include') subdir('bindings/cpp') -if not get_option('docs').disabled() - subdir('doc') -else - build_docs = false +###################### +# Tests and Examples # +###################### + +if get_option('tests') + subdir('test') endif if get_option('examples') subdir('examples') endif -if get_option('tests') - subdir('test') +################# +# Documentation # +################# + +if not get_option('docs').disabled() + subdir('doc') +else + build_docs = false endif if meson.version().version_compare('>=0.53.0') summary('Platform', platform) - summary('Cairo backend', cairo_dep.found(), bool_yn: true) - summary('OpenGL backend', opengl_dep.found(), bool_yn: true) - summary('Vulkan backend', vulkan_dep.found(), bool_yn: true) + + summary('Cairo', cairo_dep.found(), section: 'Backends', bool_yn: true) + summary('OpenGL', opengl_dep.found(), section: 'Backends', bool_yn: true) + summary('Stub', get_option('stub'), section: 'Backends', bool_yn: true) + summary('Vulkan', vulkan_dep.found(), section: 'Backends', bool_yn: true) + summary('Tests', get_option('tests'), bool_yn: true) summary('Examples', get_option('examples'), bool_yn: true) summary('Documentation', build_docs, bool_yn: true) - summary('Install prefix', get_option('prefix')) - summary('Headers', get_option('prefix') / get_option('includedir')) - summary('Libraries', get_option('prefix') / get_option('libdir')) + summary('Prefix', get_option('prefix'), section: 'Paths') + summary('Headers', get_option('prefix') / get_option('includedir'), section: 'Paths') + summary('Libraries', get_option('prefix') / get_option('libdir'), section: 'Paths') if get_option('examples') - summary('Executables', get_option('prefix') / get_option('bindir')) + summary('Executables', get_option('prefix') / get_option('bindir'), section: 'Paths') endif endif diff --git a/meson/meson.build b/meson/meson.build index 87de44d..8973b7a 100644 --- a/meson/meson.build +++ b/meson/meson.build @@ -1,15 +1,20 @@ -# Copyright 2021 David Robillard <d@drobilla.net> +# Copyright 2020-2022 David Robillard <d@drobilla.net> # SPDX-License-Identifier: CC0-1.0 OR ISC -# General code to enable approximately all warnings. +# General code to enable approximately all warnings in GCC 12, clang, and MSVC. # -# This is trivial for clang and MSVC, but GCC does not have such an option, and -# has several esoteric warnings, so we need to enable everything we want -# explicitly. We enable everything that does not require a value argument, -# except for warnings that are only relevant for very old languages (earlier -# than C99 or C++11) or non-standard extensions. +# This is trivial for clang and MSVC, but GCC doesn't have an "everything" +# option, so we need to enable everything we want explicitly. Wall is assumed, +# but Wextra is not, for stability. # -# Omitted common warnings: +# These are collected from common.opt and c.opt in the GCC source, and manually +# curated with the help of the GCC documentation. Warnings that are +# application-specific, historical, or about compatibility between specific +# language revisions are omitted. The intent here is to have roughly the same +# meaning as clang's Weverything: extremely strict, but general. Specifically +# omitted are: +# +# General: # # Wabi= # Waggregate-return @@ -24,15 +29,21 @@ # Wtrampolines # Wvla-larger-than=BYTES # -# Omitted C warnings: +# C Specific: # +# Wc11-c2x-compat # Wc90-c99-compat +# Wc99-c11-compat # Wdeclaration-after-statement # Wtraditional # Wtraditional-conversion # -# Omitted C++ warnings: +# C++ Specific: # +# Wc++0x-compat +# Wc++1z-compat +# Wc++2a-compat +# Wctad-maybe-unsupported # Wnamespaces # Wtemplates @@ -43,39 +54,50 @@ gcc_common_warnings = [ '-Warith-conversion', '-Warray-bounds=2', '-Wattribute-alias=2', + '-Wbidi-chars=ucn', '-Wcast-align=strict', + '-Wcast-function-type', '-Wcast-qual', + '-Wclobbered', '-Wconversion', '-Wdate-time', '-Wdisabled-optimization', '-Wdouble-promotion', '-Wduplicated-branches', '-Wduplicated-cond', + '-Wempty-body', + '-Wendif-labels', '-Wfloat-equal', '-Wformat-overflow=2', '-Wformat-signedness', '-Wformat-truncation=2', '-Wformat=2', - '-Wimplicit-fallthrough=2', + '-Wignored-qualifiers', + '-Wimplicit-fallthrough=3', '-Winit-self', '-Winline', '-Winvalid-pch', '-Wlogical-op', '-Wmissing-declarations', + '-Wmissing-field-initializers', '-Wmissing-include-dirs', '-Wmultichar', '-Wnormalized=nfc', '-Wnull-dereference', + '-Wopenacc-parallelism', + '-Woverlength-strings', '-Wpacked', + '-Wpacked-bitfield-compat', '-Wpadded', + '-Wpointer-arith', '-Wredundant-decls', - '-Wscalar-storage-order', '-Wshadow', + '-Wshift-negative-value', '-Wshift-overflow=2', - '-Wsizeof-array-argument', '-Wstack-protector', '-Wstrict-aliasing=3', '-Wstrict-overflow=5', + '-Wstring-compare', '-Wstringop-overflow=3', '-Wsuggest-attribute=cold', '-Wsuggest-attribute=const', @@ -85,78 +107,75 @@ gcc_common_warnings = [ '-Wsuggest-attribute=pure', '-Wswitch-default', '-Wswitch-enum', - '-Wsync-nand', + '-Wtrampolines', + '-Wtrivial-auto-var-init', + '-Wtype-limits', '-Wundef', + '-Wuninitialized', + '-Wunsafe-loop-optimizations', + '-Wunused', '-Wunused-const-variable=2', '-Wunused-macros', - '-Wvarargs', '-Wvector-operation-performance', '-Wvla', '-Wwrite-strings', ] -gcc_c_warnings = [ - '-Wbad-function-cast', - '-Wc++-compat', - '-Wc99-c11-compat', - '-Wdesignated-init', - '-Wdiscarded-array-qualifiers', - '-Wdiscarded-qualifiers', - '-Wincompatible-pointer-types', - '-Wjump-misses-init', - '-Wmissing-prototypes', - '-Wnested-externs', - '-Wold-style-definition', - '-Wstrict-prototypes', - '-Wunsuffixed-float-constants', -] - # Set all_c_warnings for the current C compiler -if is_variable('cc') +if is_variable('cc') and not is_variable('all_c_warnings') + all_c_warnings = [] if cc.get_id() == 'clang' - all_c_warnings = ['-Weverything'] + all_c_warnings += ['-Weverything'] elif cc.get_id() == 'gcc' - all_c_warnings = gcc_common_warnings + [ + all_c_warnings += gcc_common_warnings + [ + '-Wabsolute-value', '-Wbad-function-cast', '-Wc++-compat', - '-Wc99-c11-compat', - '-Wdesignated-init', - '-Wdiscarded-array-qualifiers', - '-Wdiscarded-qualifiers', - '-Wincompatible-pointer-types', + '-Wenum-conversion', '-Wjump-misses-init', + '-Wmissing-parameter-type', '-Wmissing-prototypes', '-Wnested-externs', + '-Wold-style-declaration', '-Wold-style-definition', + '-Woverride-init', + '-Wsign-compare', '-Wstrict-prototypes', '-Wunsuffixed-float-constants', ] elif cc.get_id() == 'msvc' - all_c_warnings = ['/Wall'] - else - all_c_warnings = [] + all_c_warnings += ['/Wall'] endif endif # Set all_cpp_warnings for the current C++ compiler -if is_variable('cpp') +if is_variable('cpp') and not is_variable('all_cpp_warnings') + all_cpp_warnings = [] if cpp.get_id() == 'clang' - all_cpp_warnings = [ + all_cpp_warnings += [ '-Weverything', '-Wno-c++98-compat', '-Wno-c++98-compat-pedantic' ] elif cpp.get_id() == 'gcc' - all_cpp_warnings = gcc_common_warnings + [ + all_cpp_warnings += gcc_common_warnings + [ '-Wabi-tag', '-Waligned-new=all', '-Wcatch-value=3', '-Wcomma-subscript', '-Wconditionally-supported', '-Wctor-dtor-privacy', + '-Wdelete-non-virtual-dtor', + '-Wdeprecated', + '-Wdeprecated-copy', '-Wdeprecated-copy-dtor', + '-Wdeprecated-enum-enum-conversion', + '-Wdeprecated-enum-float-conversion', '-Weffc++', + '-Wexpansion-to-defined', '-Wextra-semi', + '-Wimport', + '-Winvalid-imported-macros', '-Wmismatched-tags', '-Wmultiple-inheritance', '-Wnoexcept', @@ -165,9 +184,12 @@ if is_variable('cpp') '-Wold-style-cast', '-Woverloaded-virtual', '-Wplacement-new=2', + '-Wredundant-move', '-Wredundant-tags', '-Wregister', + '-Wsign-compare', '-Wsign-promo', + '-Wsized-deallocation', '-Wstrict-null-sentinel', '-Wsuggest-final-methods', '-Wsuggest-final-types', @@ -178,22 +200,18 @@ if is_variable('cpp') '-Wzero-as-null-pointer-constant', ] elif cpp.get_id() == 'msvc' - all_cpp_warnings = ['/Wall'] - else - all_cpp_warnings = [] + all_cpp_warnings += ['/Wall'] endif endif # Set all_objc_warnings for the current Objective C compiler -if is_variable('objcc') +if is_variable('objcc') and not is_variable('all_objc_warnings') all_objc_warnings = [] if objcc.get_id() == 'clang' - all_objc_warnings = ['-Weverything'] + all_objc_warnings += ['-Weverything'] elif objc.get_id() == 'gcc' - all_objc_warnings = gcc_common_warnings + [ + all_objc_warnings += gcc_common_warnings + [ '-Wno-direct-ivar-access', ] - else - all_objc_warnings = [] endif endif diff --git a/meson_options.txt b/meson_options.txt index dd6ea8c..40dfa3a 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -11,7 +11,10 @@ option('opengl', type: 'feature', value: 'auto', description : 'Enable support for the OpenGL graphics API') option('strict', type: 'boolean', value: false, - description: 'Enable ultra-strict warnings') + description: 'Enable ultra-strict warnings for developers') + +option('stub', type: 'boolean', value: true, + description: 'Build stub backend') option('tests', type: 'boolean', value: true, description: 'Build tests') diff --git a/test/meson.build b/test/meson.build index e16e818..56ec0d7 100644 --- a/test/meson.build +++ b/test/meson.build @@ -27,11 +27,6 @@ if get_option('strict') and is_variable('cpp') '-Wno-documentation', # Cairo '-Wno-documentation-unknown-command', # Cairo '-Wno-old-style-cast', - '-Wno-padded', - ] - elif cpp.get_id() == 'gcc' - test_cpp_args += [ - '-Wno-padded', ] endif @@ -102,7 +97,7 @@ if cairo_dep.found() foreach test : cairo_tests test(test, executable('test_' + test, 'test_@0@.c'.format(test), - c_args: test_c_args, + c_args: test_c_args + cairo_args, include_directories: include_directories(includes), dependencies: [pugl_dep, cairo_backend_dep]), suite: 'unit') @@ -181,7 +176,7 @@ elif is_variable('cpp') ] elif cpp.get_id() == 'msvc' unified_args += [ - '/wd4464' # relative include path contains '..' + '/wd4464', # relative include path contains '..' ] endif diff --git a/test/test_inline_cpp.cpp b/test/test_inline_cpp.cpp index b08656c..5b5278e 100644 --- a/test/test_inline_cpp.cpp +++ b/test/test_inline_cpp.cpp @@ -7,10 +7,19 @@ #if defined(__clang__) # pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" +# pragma clang diagnostic ignored "-Wmissing-field-initializers" # pragma clang diagnostic ignored "-Wold-style-cast" +# pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" +# if __has_warning("-Wreserved-identifier") +# pragma clang diagnostic ignored "-Wreserved-identifier" +# endif #elif defined(__GNUC__) # pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wconversion" +# pragma GCC diagnostic ignored "-Wmissing-field-initializers" +# pragma GCC diagnostic ignored "-Wredundant-tags" +# pragma GCC diagnostic ignored "-Wsuggest-attribute=const" +# pragma GCC diagnostic ignored "-Wsuggest-attribute=pure" # pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" #endif @@ -44,14 +53,14 @@ # endif #endif -#if defined(__clang__) -# pragma clang diagnostic pop -#elif defined(__GNUC__) -# pragma GCC diagnostic pop -#endif - int main() { return 0; } + +#if defined(__clang__) +# pragma clang diagnostic pop +#elif defined(__GNUC__) +# pragma GCC diagnostic pop +#endif |