summaryrefslogtreecommitdiffstats
path: root/meson.build
diff options
context:
space:
mode:
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build146
1 files changed, 141 insertions, 5 deletions
diff --git a/meson.build b/meson.build
index bd81079..22be3d3 100644
--- a/meson.build
+++ b/meson.build
@@ -21,9 +21,9 @@ version_suffix = '-@0@'.format(major_version)
versioned_name = 'suil' + version_suffix
suil_module_dir = get_option('libdir') / versioned_name
-#######################
-# Compilers and Flags #
-#######################
+#############################
+# Compilers and Build Tools #
+#############################
# Load build tools
pkg = import('pkgconfig')
@@ -36,8 +36,144 @@ if host_machine.system() == 'darwin'
objcpp = meson.get_compiler('objcpp')
endif
-# Set global warning flags
-subdir('meson/suppressions')
+########################
+# Warning Suppressions #
+########################
+
+warning_level = get_option('warning_level')
+
+# C
+c_suppressions = []
+if cc.get_id() in ['clang', 'emscripten']
+ if warning_level == 'everything'
+ c_suppressions += [
+ '-Wno-atomic-implicit-seq-cst',
+ '-Wno-cast-function-type-strict',
+ '-Wno-cast-qual',
+ '-Wno-declaration-after-statement',
+ '-Wno-disabled-macro-expansion',
+ '-Wno-padded',
+ '-Wno-reserved-id-macro',
+ '-Wno-unsafe-buffer-usage',
+ '-Wno-variadic-macros',
+ ]
+
+ if not meson.is_cross_build()
+ c_suppressions += ['-Wno-poison-system-directories']
+ endif
+ endif
+
+ if host_machine.system() == 'windows'
+ c_suppressions += [
+ '-Wno-deprecated-declarations',
+ '-Wno-nonportable-system-include-path',
+ ]
+ endif
+
+elif cc.get_id() == 'gcc'
+ if warning_level == 'everything'
+ c_suppressions += [
+ '-Wno-padded',
+ '-Wno-suggest-attribute=const',
+ '-Wno-suggest-attribute=pure',
+ ]
+ endif
+
+elif cc.get_id() == 'msvc'
+ c_suppressions += [
+ '/experimental:external',
+ '/external:W0',
+ '/external:anglebrackets',
+ ]
+
+ if warning_level == 'everything'
+ c_suppressions += [
+ '/wd4191', # unsafe function conversion
+ '/wd4514', # unreferenced inline function has been removed
+ '/wd4710', # function not inlined
+ '/wd4820', # padding added after construct
+ '/wd5045', # will insert Spectre mitigation for memory load
+ ]
+ endif
+
+ if warning_level in ['everything', '3', '2']
+ c_suppressions += [
+ '/wd4996', # function or variable may be unsafe
+ ]
+ endif
+endif
+
+c_suppressions = cc.get_supported_arguments(c_suppressions)
+
+# C++
+if is_variable('cpp')
+ cpp_suppressions = []
+
+ if cpp.get_id() in ['clang', 'emscripten']
+ if warning_level == 'everything'
+ cpp_suppressions += [
+ '-Wno-atomic-implicit-seq-cst',
+ '-Wno-c++98-compat',
+ '-Wno-c++98-compat-pedantic',
+ '-Wno-cast-function-type-strict',
+ '-Wno-cast-qual',
+ '-Wno-disabled-macro-expansion',
+ '-Wno-old-style-cast',
+ '-Wno-padded',
+ '-Wno-reserved-id-macro',
+ '-Wno-unsafe-buffer-usage',
+ '-Wno-variadic-macros',
+ '-Wno-zero-as-null-pointer-constant',
+ ]
+ endif
+ elif cpp.get_id() == 'gcc'
+ if warning_level == 'everything'
+ cpp_suppressions += [
+ '-Wno-arith-conversion',
+ '-Wno-cast-qual',
+ '-Wno-padded',
+ '-Wno-suggest-attribute=const',
+ '-Wno-suggest-attribute=pure',
+ '-Wno-useless-cast',
+ '-Wno-volatile',
+ ]
+ endif
+ endif
+
+ cpp_suppressions = cpp.get_supported_arguments(cpp_suppressions)
+endif
+
+# Objective C++
+if is_variable('objcpp')
+ objcpp_suppressions = []
+
+ if objcpp.get_id() in ['clang', 'emscripten']
+ if warning_level == 'everything'
+ objcpp_suppressions += [
+ '-Wno-c++98-compat-pedantic',
+ '-Wno-deprecated-declarations',
+ '-Wno-old-style-cast',
+ '-Wno-padded',
+ '-Wno-reserved-id-macro',
+ '-Wno-weak-vtables',
+ '-Wno-zero-as-null-pointer-constant',
+ ]
+
+ if not meson.is_cross_build()
+ objcpp_suppressions += ['-Wno-poison-system-directories']
+ endif
+ endif
+
+ elif objcpp.get_id() == 'gcc'
+ if warning_level == 'everything'
+ objcpp_suppressions = (
+ gcc_common_warnings + ['-Wno-direct-ivar-access']
+ )
+ endif
+ endif
+
+ objcpp_suppressions = objcpp.get_supported_arguments(objcpp_suppressions)
+endif
##########################
# Platform Configuration #