-
Just getting into Meson via its Manual. Given that I'll want to default to debug builds (or rather, to the fastest build possible) during development but also have the option to occasionally but straightforwardly make a Release build from the same overall build-system setup and sources.. As I grok things so far, I'd have something like this: project('myapp', 'c', default_options: ['buildtype=debug'])
executable(
'myapp', 'main.c', dependencies: [dependency('sdl2')]
)
executable(
'myapp_shipping',
'main.c',
override_options: ['buildtype=release'],
dependencies: [dependency('sdl2')],
) But this way, I see duplication of Furthermore, to speed up build times, in "debug mode" I'd want to build (and link) lib targets as shared libs (ie dynamically linked ie at runtime/startup), and only statically link for "release mode". Will this be very rocket-sciency to formulate? Does anyone do things similarly, what's your general "template of approach" here? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Generally Meson steers you to have two build directories configured differently, so you'd have: project('myapp', 'c') # debug is already the default build type
executable('myapp', 'main.c', dependencies : [dependency('sdl2')]) Then you'd configure two separate build directories in your project: meson setup builddir/debug
ninja -C builddir/debug
meson setup builddir/release -Dbuildtype=release -Dprefer_static=true
ninja -C builddir/release This is advantageous because you probably don't want to ship both a debug and a release build, and you don't end up compiling the same files twice when you probably are only going to test one binary. edit: Eli's suggestion to use prefer_static is the correct one, and I've removed the original answer I had. |
Beta Was this translation helpful? Give feedback.
-
I don't really understand what you're trying to do here. :) The default buildtype is already debug: https://mesonbuild.com/Builtin-options.html#core-options You can build a release version by configuring a second build directory using |
Beta Was this translation helpful? Give feedback.
-
There is a core option |
Beta Was this translation helpful? Give feedback.
-
Thanks, you two, glad to see my needs are so well (and succinctly) covered by Meson =) |
Beta Was this translation helpful? Give feedback.
Generally Meson steers you to have two build directories configured differently, so you'd have:
Then you'd configure two separate build directories in your project:
This is advantageous because you probably don't want to ship both a debug and a release build, and you don't end up compiling the same files twice when you probably are only going to test one binary.
edit: Eli's suggestion to use prefer_static is the c…