$linuxjunkies
>

meson(1)

Meson is a modern build system designed to be fast, user-friendly, and language-agnostic for compiling software projects.

UbuntuDebianFedoraArch

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

FlagWhat it does
setupInitialize a build directory with configuration (creates meson-private, compdb.json, etc.)
compileBuild the project using the configured backend (Ninja, Make, etc.)
testRun tests defined in meson.build files
-C BUILDDIRSpecify the build directory to operate on
-Doption=valueSet a project option (e.g., -Dprefix=/usr, -Dbuildtype=debug)
--prefix PREFIXSet installation prefix directory
--default-library shared|staticSet default library type (shared or static)
--buildtype plain|debug|debugoptimized|releaseSet build optimization level
--wipeClear build directory before reconfiguring
installInstall the built project to the prefix directory
--no-rebuildSkip rebuilding when running other commands
-v, --verboseShow detailed output during build

Examples

Configure the project and create a build directory with default options

meson setup builddir

Configure with custom installation prefix and release optimization

meson setup builddir -Dprefix=/opt/myapp -Dbuildtype=release

Build the project in the builddir directory

meson compile -C builddir

Build using 4 parallel jobs for faster compilation

meson compile -C builddir -j4

Run all unit tests defined in the meson.build

meson test -C builddir

Run only tests tagged with the 'integration' suite

meson test -C builddir --suite integration

Install built binaries and libraries to the prefix directory

meson install -C builddir

Clean reconfigure for static library build

meson setup builddir --wipe -Ddefault-library=static

Related commands