meson: Fix check for builtype arguments

`get_option('buildtype')` will return `'custom'` for most combinations
of `-Doptimization` and `-Ddebug`, but those two will always be set
correctly if only `-Dbuildtype` is set. So we should look at those
options directly.

For the two-way mapping between `buildtype` and `optimization`
+ `debug`, see this table:
https://mesonbuild.com/Builtin-options.html#build-type-options
This commit is contained in:
Nirbheek Chauhan 2020-03-05 00:36:50 +05:30
parent b4d6849c83
commit e7cfe62e73

View File

@ -214,11 +214,15 @@ glibconfig_conf.set('glib_os', glib_os)
# for dependencies that don't normally come with pkg-config files for Visual Studio builds
buildtype = get_option('buildtype')
# Use debug/optimization flags to determine whether to enable debug or disable
# cast checks
glib_debug_cflags = []
if buildtype.startswith('debug')
if get_option('debug')
glib_debug_cflags += ['-DG_ENABLE_DEBUG']
elif buildtype == 'release'
message('Enabling various debug infrastructure')
elif get_option('optimization') in ['2', '3', 's']
glib_debug_cflags += ['-DG_DISABLE_CAST_CHECKS']
message('Disabling cast checks')
endif
add_project_arguments(glib_debug_cflags, language: 'c')