meson(1)
Meson is a modern build system designed to be fast, user-friendly, and language-agnostic for compiling software projects.
Synopsis
meson [OPTION]... [builddir] [sourcedir]Description
Meson is a build automation tool that generates build files for other backends (Ninja, Visual Studio, Xcode). It uses declarative configuration in meson.build files and emphasizes speed and ease of use compared to autotools or CMake. Meson handles dependency detection, compilation flags, and test execution.
A typical workflow involves running meson setup builddir to configure a project, then meson compile -C builddir to build, and meson test -C builddir to run tests. Meson automatically generates Ninja build files by default on Linux.
Common options
| Flag | What it does |
|---|---|
setup | Initialize a build directory with configuration (creates meson-private, compdb.json, etc.) |
compile | Build the project using the configured backend (Ninja, Make, etc.) |
test | Run tests defined in meson.build files |
-C BUILDDIR | Specify the build directory to operate on |
-Doption=value | Set a project option (e.g., -Dprefix=/usr, -Dbuildtype=debug) |
--prefix PREFIX | Set installation prefix directory |
--default-library shared|static | Set default library type (shared or static) |
--buildtype plain|debug|debugoptimized|release | Set build optimization level |
--wipe | Clear build directory before reconfiguring |
install | Install the built project to the prefix directory |
--no-rebuild | Skip rebuilding when running other commands |
-v, --verbose | Show detailed output during build |
Examples
Configure the project and create a build directory with default options
meson setup builddirConfigure with custom installation prefix and release optimization
meson setup builddir -Dprefix=/opt/myapp -Dbuildtype=releaseBuild the project in the builddir directory
meson compile -C builddirBuild using 4 parallel jobs for faster compilation
meson compile -C builddir -j4Run all unit tests defined in the meson.build
meson test -C builddirRun only tests tagged with the 'integration' suite
meson test -C builddir --suite integrationInstall built binaries and libraries to the prefix directory
meson install -C builddirClean reconfigure for static library build
meson setup builddir --wipe -Ddefault-library=static