meson setup: Configure a Meson Build
meson setup <builddir> configures a Meson project into a build directory, detecting the toolchain and applying build options.
Meson always builds out-of-source and pairs with Ninja by default. The setup step reads meson.build, detects compilers and dependencies, and writes a Ninja build.
What it does
meson setup reads meson.build from the source tree, probes the compiler and dependencies, applies build options, and generates a Ninja build in the build directory. Reconfiguring an existing build dir needs --reconfigure.
Common usage
meson setup build --buildtype=release
meson setup build -Dprefix=/usr/local -Dwerror=true
meson setup build --cross-file arm.ini
meson setup --reconfigure buildOptions
| Flag | What it does |
|---|---|
| --buildtype <type> | plain, debug, debugoptimized, release, minsize |
| -D<option>=<value> | Set a built-in or project option (e.g. -Dprefix=) |
| --prefix <path> | Install prefix (same as -Dprefix) |
| --cross-file <file> | Cross-compilation definition file |
| --native-file <file> | Native build machine definition file |
| --reconfigure | Re-run setup on an existing build directory |
| --wipe | Wipe and reconfigure the build directory |
In CI
Set --buildtype=release explicitly (the default is debug). Install a compiler and ninja (apt-get install build-essential ninja-build meson) before running. Use --wipe when a cached build dir was created with a stale toolchain rather than deleting it by hand.
Common errors in CI
"ERROR: Unknown compiler(s): ..." or "ERROR: No such command 'setup'" points at a missing compiler or too-old Meson. "ERROR: Neither a source directory nor a build directory..." means the build dir was already configured; add --reconfigure or --wipe. "ERROR: Dependency 'foo' not found" means a pkg-config dependency is missing; install its -dev package. "Unknown options: -Dbar" means the option name is wrong.