aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-05-28 16:25:52 -0400
committerDavid Robillard <d@drobilla.net>2021-05-28 17:26:38 -0400
commit55f9506e4fe172cd5376ad9d95a99440a90b3c43 (patch)
tree3da847c441e1020528e49feddd7ea3c77e645fc3
parent3342e618b59e8c35f387bb27153fccf141670ef9 (diff)
downloadpugl-55f9506e4fe172cd5376ad9d95a99440a90b3c43.tar.gz
pugl-55f9506e4fe172cd5376ad9d95a99440a90b3c43.tar.bz2
pugl-55f9506e4fe172cd5376ad9d95a99440a90b3c43.zip
Split up warning suppression flags more finely
This avoids polluting the main list of suppressions with things that are only triggered in tests or examples, making it clearer which warning are present in pugl itself.
-rw-r--r--examples/meson.build57
-rw-r--r--meson.build69
-rw-r--r--test/meson.build65
3 files changed, 116 insertions, 75 deletions
diff --git a/examples/meson.build b/examples/meson.build
index be4091a..6984033 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -1,5 +1,5 @@
data_dir = get_option('prefix') / get_option('datadir') / 'pugl-0'
-example_args = ['-DPUGL_DATA_DIR="@0@"'.format(data_dir)]
+example_defines = ['-DPUGL_DATA_DIR="@0@"'.format(data_dir)]
gl_examples = [
'pugl_cpp_demo.cpp',
@@ -24,6 +24,51 @@ includes = include_directories(
'../include',
)
+# Suppress some additional C warnings in examples
+example_c_args = []
+if get_option('strict')
+ if cc.get_id() == 'clang'
+ example_c_args += [
+ '-Wno-float-equal',
+ '-Wno-padded',
+ ]
+ elif cc.get_id() == 'gcc'
+ example_c_args += [
+ '-Wno-float-equal',
+ '-Wno-padded',
+ ]
+ endif
+
+ example_c_args = cc.get_supported_arguments(example_c_args)
+endif
+
+# Suppress some additional C++ warnings in examples
+example_cpp_args = []
+if 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-reserved-id-macro',
+ '-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',
+ ]
+ endif
+
+ example_cpp_args = cpp.get_supported_arguments(example_cpp_args)
+endif
+
subdir('shaders')
# Build GL examples
@@ -42,8 +87,8 @@ if opengl_dep.found()
executable(target, source,
include_directories: includes,
- c_args: example_args,
- cpp_args: example_args,
+ c_args: example_defines + example_c_args,
+ cpp_args: example_defines + example_cpp_args,
dependencies: dependencies)
endforeach
endif
@@ -54,7 +99,7 @@ if cairo_dep.found()
target = example.split('.')[0]
executable(target, example,
include_directories: includes,
- c_args: example_args,
+ c_args: example_defines + example_c_args,
dependencies: [pugl_dep, cairo_backend_dep])
endforeach
endif
@@ -72,8 +117,8 @@ if vulkan_dep.found()
executable(target, source,
include_directories: includes,
- c_args: example_args,
- cpp_args: example_args,
+ c_args: example_defines + example_c_args,
+ cpp_args: example_defines + example_cpp_args,
dependencies: dependencies)
endforeach
endif
diff --git a/meson.build b/meson.build
index 5dd60be..2952378 100644
--- a/meson.build
+++ b/meson.build
@@ -18,7 +18,7 @@ pkg = import('pkgconfig')
cc = meson.get_compiler('c')
# Enable C++ support if we're building the examples
-if get_option('examples')
+if get_option('examples') or get_option('tests')
add_languages(['cpp'])
cpp = meson.get_compiler('cpp')
endif
@@ -30,31 +30,26 @@ if host_machine.system() == 'darwin'
endif
# Set ultra strict warnings for developers, if requested
+# These are for the implementation, tests and examples add more suppressions
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-float-equal',
- '-Wno-implicit-fallthrough',
'-Wno-padded',
'-Wno-reserved-id-macro',
'-Wno-switch-default',
'-Wno-switch-enum',
- '-Wno-unused-macros', # Mac
]
elif cc.get_id() == 'gcc'
c_warnings += [
'-Wno-bad-function-cast',
'-Wno-float-equal',
- '-Wno-inline',
'-Wno-padded',
- '-Wno-pedantic',
'-Wno-suggest-attribute=const',
'-Wno-suggest-attribute=malloc',
'-Wno-suggest-attribute=pure',
@@ -81,64 +76,6 @@ if get_option('strict')
add_project_arguments(cc.get_supported_arguments(c_warnings),
language: ['c', 'objc'])
- # C++ warnings
- if is_variable('cpp')
- cpp_warnings = all_cpp_warnings
-
- if cpp.get_id() == 'clang'
- cpp_warnings += [
- '-Wno-documentation', # Cairo
- '-Wno-documentation-unknown-command', # Cairo
- '-Wno-old-style-cast',
- '-Wno-padded',
- '-Wno-reserved-id-macro',
- '-Wno-switch-enum',
- '-Wno-unused-macros', # Mac
- ]
- elif cpp.get_id() == 'gcc'
- cpp_warnings += [
- '-Wno-conditionally-supported',
- '-Wno-effc++',
- '-Wno-float-equal',
- '-Wno-inline',
- '-Wno-old-style-cast',
- '-Wno-padded',
- '-Wno-suggest-attribute=const',
- '-Wno-suggest-attribute=malloc',
- '-Wno-suggest-attribute=pure',
- '-Wno-suggest-final-methods',
- '-Wno-switch-default',
- '-Wno-switch-enum',
- '-Wno-unused-const-variable',
- '-Wno-useless-cast',
- ]
- elif cpp.get_id() == 'msvc'
- cpp_warnings += [
- '/wd4061', # enumerator in switch is not explicitly handled
- '/wd4191', # unsafe conversion from type to type
- '/wd4355', # 'this' used in base member initializer list
- '/wd4514', # unreferenced inline function has been removed
- '/wd4571', # structured exceptions (SEH) are no longer caught
- '/wd4625', # copy constructor implicitly deleted
- '/wd4626', # assignment operator implicitly deleted
- '/wd4706', # assignment within conditional expression
- '/wd4710', # function not inlined
- '/wd4711', # function selected for automatic inline expansion
- '/wd4800', # implicit conversion from int to bool
- '/wd4820', # padding added after construct
- '/wd4868', # compiler may not enforce left-to-right evaluation order
- '/wd4996', # function or variable may be unsafe
- '/wd5026', # move constructor implicitly deleted
- '/wd5027', # move assignment operator implicitly deleted
- '/wd5039', # 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
@@ -221,7 +158,7 @@ if host_machine.system() == 'darwin'
# Windows
elif host_machine.system() == 'windows'
- if cpp.get_id() == 'msvc'
+ if cc.get_id() == 'msvc'
msvc_args = [
'/TP',
'/experimental:external',
diff --git a/test/meson.build b/test/meson.build
index bd838f3..a50b6c7 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -1,3 +1,38 @@
+# Suppress some additional C warnings in tests
+test_c_args = []
+if get_option('strict')
+ if cc.get_id() == 'clang'
+ test_c_args += [
+ '-Wno-float-equal',
+ ]
+ elif cc.get_id() == 'gcc'
+ test_c_args += [
+ '-Wno-float-equal',
+ ]
+ endif
+
+ test_c_args = cc.get_supported_arguments(test_c_args)
+endif
+
+# Suppress some additional C++ warnings in tests
+test_cpp_args = []
+if get_option('strict') and is_variable('cpp')
+ if cpp.get_id() == 'clang'
+ test_cpp_args += [
+ '-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
+
+ test_cpp_args = cpp.get_supported_arguments(test_cpp_args)
+endif
+
basic_tests = [
'local_copy_paste',
'realize',
@@ -35,6 +70,7 @@ includes = [
foreach test : basic_tests
test(test,
executable('test_' + test, 'test_@0@.c'.format(test),
+ c_args: test_c_args,
include_directories: include_directories(includes),
dependencies: [pugl_dep, stub_backend_dep]))
endforeach
@@ -43,6 +79,7 @@ if opengl_dep.found()
foreach test : gl_tests
test(test,
executable('test_' + test, 'test_@0@.c'.format(test),
+ c_args: test_c_args,
include_directories: include_directories(includes),
dependencies: [pugl_dep, gl_backend_dep]))
endforeach
@@ -52,6 +89,7 @@ if cairo_dep.found()
foreach test : cairo_tests
test(test,
executable('test_' + test, 'test_@0@.c'.format(test),
+ c_args: test_c_args,
include_directories: include_directories(includes),
dependencies: [pugl_dep, cairo_backend_dep]))
endforeach
@@ -61,6 +99,8 @@ if vulkan_dep.found()
foreach test : vulkan_tests
test(test,
executable('test_' + test, 'test_@0@.c'.format(test),
+ c_args: test_c_args,
+ cpp_args: test_cpp_args,
include_directories: include_directories(includes),
dependencies: [pugl_dep, vulkan_backend_dep]))
endforeach
@@ -88,14 +128,33 @@ if host_machine.system() == 'darwin'
objcpp = meson.get_compiler('objcpp')
unified_args += objcpp.get_supported_arguments(
- c_warnings + cpp_warnings + objc_warnings)
+ c_warnings + test_cpp_args + objc_warnings)
executable('inline_objcpp', 'test_inline_objcpp.mm',
include_directories: include_directories(includes),
dependencies: unified_deps,
objcpp_args: unified_args)
+
elif is_variable('cpp')
- if cpp.get_id() == 'msvc'
+ unified_args = []
+
+ if cpp.get_id() == 'clang'
+ unified_args += [
+ '-Wno-old-style-cast',
+ '-Wno-reserved-id-macro',
+ '-Wno-switch-default',
+ '-Wno-switch-enum',
+ '-Wno-unused-macros', # Mac
+ ]
+ elif cpp.get_id() == 'gcc'
+ unified_args += [
+ '-Wno-conditionally-supported',
+ '-Wno-old-style-cast',
+ '-Wno-switch-default',
+ '-Wno-switch-enum',
+ '-Wno-useless-cast',
+ ]
+ elif cpp.get_id() == 'msvc'
unified_args += [
'/wd4464' # relative include path contains '..'
]
@@ -104,5 +163,5 @@ elif is_variable('cpp')
executable('inline_cpp', 'test_inline_cpp.cpp',
include_directories: include_directories(includes),
dependencies: unified_deps,
- cpp_args: unified_args)
+ cpp_args: test_cpp_args + unified_args)
endif