meson setup: Configure a Build Directory
meson setup creates and configures an out-of-source build directory from your meson.build files.
Meson always builds out of source, so the first step in any pipeline is meson setup builddir. Getting the build type and options right here avoids reconfiguring later.
What it does
meson setup reads meson.build, resolves dependencies and options, and writes a build directory containing a Ninja manifest. Project options are set with -Dname=value and built-in options like buildtype and prefix control optimization and install layout.
Common usage
meson setup build # default configuration
meson setup build --buildtype=release # optimized build
meson setup build -Dprefix=/usr -Dwerror=true
meson setup build --reconfigure # re-run on an existing dirOptions
| Flag | What it does |
|---|---|
| <builddir> | Directory to create and configure |
| --buildtype <type> | plain, debug, debugoptimized, release, minsize |
| -D<opt>=<value> | Set a project or built-in option |
| --prefix <dir> | Install prefix (default /usr/local) |
| --reconfigure | Reconfigure an existing build directory |
| --wipe | Recreate the build dir reusing saved options |
In CI
Set --buildtype explicitly in pipelines; the default is debug, which is rarely what release artifacts want. Configure into a directory you then build with meson compile -C build (or ninja -C build). Pass -Dwerror=true if you want CI to fail on warnings that pass locally.
Common errors in CI
"Directory is not empty and does not contain a previous build" means builddir holds non-Meson files; use a fresh name or --wipe. "ERROR: Neither directory contains a build file meson.build" means you ran setup from the wrong path. "Unknown options: 'foo'" means a -D option not declared in meson_options.txt/meson.options.