mesonbuild/meson
View on GitHubHave the equivalent of AX_COMPILER_FLAGS from Autotools
Open
#2,609 opened on Nov 11, 2017
compilersenhancementhelp wanted
Description
See: https://www.gnu.org/software/autoconf-archive/ax_compiler_flags.html#ax_compiler_flags
This is a macro used in GNOME for example (the *.m4 macro has been written by a GNOME developer).
Currently with Meson I need to copy/paste the following snippet of code from one project to another, and also when new flags are added upstream to AX_COMPILER_FLAGS, I need to update the Meson code in all my projects.
#####
# CFLAGS
# The same as the AX_COMPILER_FLAGS Autotools macro.
warning_cflags = [
'-fno-strict-aliasing',
'-Wall',
'-Wextra',
'-Wundef',
'-Wnested-externs',
'-Wwrite-strings',
'-Wpointer-arith',
'-Wmissing-declarations',
'-Wmissing-prototypes',
'-Wstrict-prototypes',
'-Wredundant-decls',
'-Wno-unused-parameter',
'-Wno-missing-field-initializers',
'-Wdeclaration-after-statement',
'-Wformat=2',
'-Wold-style-definition',
'-Wcast-align',
'-Wformat-nonliteral',
'-Wformat-security',
'-Wsign-compare',
'-Wstrict-aliasing',
'-Wshadow',
'-Winline',
'-Wpacked',
'-Wmissing-format-attribute',
'-Wmissing-noreturn',
'-Winit-self',
'-Wredundant-decls',
'-Wmissing-include-dirs',
'-Wunused-but-set-variable',
'-Warray-bounds',
'-Wimplicit-function-declaration',
'-Wreturn-type',
'-Wswitch-enum',
'-Wswitch-default',
'-Wduplicated-cond',
'-Wduplicated-branches',
'-Wlogical-op',
'-Wrestrict',
'-Wnull-dereference',
'-Wjump-misses-init',
'-Wdouble-promotion'
]
c_compiler = meson.get_compiler('c')
supported_warning_cflags = c_compiler.get_supported_arguments(warning_cflags)
add_global_arguments(supported_warning_cflags, language : 'c')
##### end CFLAGS
Note that this is not an exact copy of what AX_COMPILER_FLAGS does, it's just what I needed from it.