mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-01-04 12:10:17 +01:00
copy all autotools compiler warnings to meson build
This commit is contained in:
parent
773236010f
commit
ebac15cb04
2 changed files with 62 additions and 2 deletions
9
meson-cc-tests/check-unused-result.c
Normal file
9
meson-cc-tests/check-unused-result.c
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
__attribute__((__warn_unused_result__)) void f (void) {}
|
||||
__attribute__((__warn_unused_result__)) int g;
|
||||
|
||||
int main(int c, char **v)
|
||||
{
|
||||
(void)c;
|
||||
(void)v;
|
||||
return 0;
|
||||
}
|
||||
55
meson.build
55
meson.build
|
|
@ -33,8 +33,61 @@ else
|
|||
cairo_libversion = '@0@.@1@.@2@'.format(cairo_version_sonum, cairo_version, cairo_version_micro)
|
||||
endif
|
||||
|
||||
conf = configuration_data()
|
||||
|
||||
cc = meson.get_compiler('c')
|
||||
|
||||
# Compiler flags
|
||||
cflags = []
|
||||
if cc.get_id() != 'msvc'
|
||||
cflags += [
|
||||
'-Wall',
|
||||
'-Wextra',
|
||||
'-Wmissing-declarations',
|
||||
'-Werror-implicit-function-declaration',
|
||||
'-Wpointer-arith',
|
||||
'-Wwrite-strings',
|
||||
'-Wsign-compare',
|
||||
'-Wpacked',
|
||||
'-Wswitch-enum',
|
||||
'-Wmissing-format-attribute',
|
||||
'-Wvolatile-register-var',
|
||||
'-Wstrict-aliasing=2',
|
||||
'-Winit-self',
|
||||
'-Wunsafe-loop-optimizations',
|
||||
'-Wno-missing-field-initializers',
|
||||
'-Wno-unused-parameter',
|
||||
'-Wno-attributes',
|
||||
'-Wno-long-long',
|
||||
'-Winline'
|
||||
]
|
||||
|
||||
cflags += ['-Wno-unused-but-set-variable',
|
||||
'-Wno-enum-conversion'
|
||||
]
|
||||
|
||||
cflags += [
|
||||
'-fno-strict-aliasing',
|
||||
'-fno-common'
|
||||
]
|
||||
|
||||
cflags += '-Wp,-D_FORTIFY_SOURCE=2'
|
||||
|
||||
supported_cflags = cc.get_supported_arguments(cflags)
|
||||
add_project_arguments(supported_cflags, language: 'c')
|
||||
|
||||
# We only wish to enable attribute(warn_unused_result) if we can prevent
|
||||
# gcc from generating thousands of warnings about the misapplication of the
|
||||
# attribute to void functions and variables.
|
||||
warn_unused_result = ''
|
||||
if supported_cflags.contains('-Wno-attributes')
|
||||
if cc.compiles(files('meson-cc-tests/check-unused-result.c'), args : ['-Wno-attributes', '-Werror'])
|
||||
warn_unused_result = '__attribute__((__warn_unused_result__))'
|
||||
endif
|
||||
endif
|
||||
conf.set('WARN_UNUSED_RESULT', warn_unused_result)
|
||||
endif
|
||||
|
||||
if cc.get_id() == 'msvc'
|
||||
# Basic usage in the cairo type system that causes spammy and useless warnings
|
||||
add_project_arguments('/wd4244', '/wd4146',
|
||||
|
|
@ -137,8 +190,6 @@ test_deps = []
|
|||
internal_deps = []
|
||||
extra_link_args = []
|
||||
|
||||
conf = configuration_data()
|
||||
|
||||
if host_machine.endian() == 'big'
|
||||
conf.set('WORDS_BIGENDIAN', 1)
|
||||
endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue