-
|
Hey, I want to enable the sanitizers in debug only. How would I acchive this? The method I tried doesn't work and I can't find any references in the manual or online. This is what I am trying to do: project(
'Foo',
'c',
version: '0.0.1',
license: 'GPL-3.0-or-later',
meson_version: '>= 0.64.0',
default_options: [
'c_std=c2x',
'warning_level=everything',
],
)
# This is the relevant part
if get_option('buildtype').startswith('debug')
message('Building a debug release')
add_project_arguments('b_sanitize=address,undefined', language: 'c')
else
add_project_arguments(['werror=true'], language: 'c')
endif
ce_sources = file('src/main.c')
executable(
meson.project_name().to_lower(),
ce_sources,
)Meson tries to add it as a link argument |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Meson doesn't support setting global options inside the build definitions, since it mixes policy with build logic. The easiest way to handle this is to use a set of profile configurations: debug.ini: then have a As an aside, I've had to professionally deal with third party code that mixes policy and logic like this, and as the downstream having to carry patches to pull that kind of policy out to get the project to build as the upstream continues to make changes to the code is incredibly frustrating. |
Beta Was this translation helpful? Give feedback.
Meson doesn't support setting global options inside the build definitions, since it mixes policy with build logic. The easiest way to handle this is to use a set of profile configurations:
debug.ini:
``ini
[built-in options]
buildtype = 'debug'
b_sanitize = 'address,undefined'
then have a
profiles/directory, you can runmeson setup builddir/debug --native-file profiles/debug.iniandmeson setup builddir/release --native-file profiles/release.iniAs an aside, I've had to professionally deal with third party code that mixes policy and logic like this, and as the downstream having to carry patches to pull that kind of policy out to get…