Update meson.build
Cleaned up compiler flags in root meson.build, renamed a variable and removed 'c_std=<standard version>' because Meson sets C standard flag to C11 by default.
@@ -15,61 +15,54 @@ project('unity', 'c',
version : '2.4.3',
license : 'MIT',
meson_version : '>=0.50.0',
- default_options :
- [
- 'werror=true',
+ default_options: [
+ 'buildtype=minsize',
'optimization=3',
'warning_level=3',
- 'b_sanitize=address,undefined',
- 'b_lto=true',
- 'b_lundef=true'
- ])
-cc = meson.get_compiler('c')
-args_for_langs = 'c'
+ 'werror=true',
+ ]
+)
+lang = 'c'
+cc = meson.get_compiler(lang)
+
+##
+#
+# Meson: Add compiler flags
+#
+##
if cc.get_id() == 'clang'
- add_project_arguments(
- '-Wweak-vtables',
- '-Wexit-time-destructors',
- '-Wglobal-constructors',
- '-Wmissing-noreturn', language: args_for_langs)
+ add_project_arguments(cc.get_supported_arguments(
+ [
+ '-Wweak-vtables', '-Wexit-time-destructors',
+ '-Wglobal-constructors', '-Wmissing-noreturn'
+ ]
+ ), language: lang)
endif
if cc.get_argument_syntax() == 'gcc'
- add_project_arguments(
- '-Wall',
- '-Wextra',
- '-Wunreachable-code',
- '-Wmissing-declarations',
- '-Wmissing-prototypes',
- '-Wredundant-decls',
- '-Wundef',
- '-Wwrite-strings',
- '-Wformat',
- '-Wformat-nonliteral',
- '-Wformat-security',
- '-Wold-style-definition',
- '-Winit-self',
- '-Wmissing-include-dirs',
- '-Waddress',
- '-Waggregate-return',
- '-Wno-multichar',
- '-Wdeclaration-after-statement',
- '-Wvla',
- '-Wpointer-arith',language: args_for_langs)
+ add_project_arguments(cc.get_supported_arguments(
+ [
+ '-Wformat', '-Waddress', '-Winit-self', '-Wno-multichar',
+ '-Wpointer-arith' , '-Wwrite-strings' ,
+ '-Wno-parentheses' , '-Wno-type-limits' ,
+ '-Wformat-security' , '-Wunreachable-code' ,
+ '-Waggregate-return' , '-Wformat-nonliteral' ,
+ '-Wmissing-prototypes' , '-Wold-style-definition' ,
+ '-Wmissing-declarations', '-Wmissing-include-dirs' ,
+ '-Wno-unused-parameter' , '-Wdeclaration-after-statement'
+ ]
+ ), language: lang)
endif
if cc.get_id() == 'msvc'
- add_project_arguments(
- '/W4',
- '/w44265',
- '/w44061',
- '/w44062',
- '/wd4018', # implicit signed/unsigned conversion
- '/wd4146', # unary minus on unsigned (beware INT_MIN)
- '/wd4244', # lossy type conversion (e.g. double -> int)
- '/wd4305', # truncating type conversion (e.g. double -> float)
- mesno.get_supported_arguments(['/utf-8']), language: args_for_langs)
+ add_project_arguments(cc.get_supported_arguments(
+ [
+ '/w44265', '/w44061', '/w44062',
+ '/wd4018', '/wd4146', '/wd4244',
+ '/wd4305',
+ ]
+ ), language: lang)
endif
subdir('src')
