summaryrefslogtreecommitdiff
path: root/meson.build
diff options
context:
space:
mode:
authorAdrian Johnson <ajohnson@redneon.com>2021-08-14 07:24:40 +0000
committerAdrian Johnson <ajohnson@redneon.com>2021-08-14 07:24:40 +0000
commitebac15cb047bfc82d359a679d4bc53a37028ad6a (patch)
treea27586ba3dfb87df9cb0db76a56ede1a1f9450d4 /meson.build
parent773236010f45530855c21ae16a5f69e6d7a2d43c (diff)
downloadcairo-ebac15cb047bfc82d359a679d4bc53a37028ad6a.tar.gz
copy all autotools compiler warnings to meson build
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build55
1 files changed, 53 insertions, 2 deletions
diff --git a/meson.build b/meson.build
index ca9d72825..ce7449ffb 100644
--- a/meson.build
+++ b/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