跳转至

meson


更新于 2023-09-09

Meson是用户友好的编译工具。
通常会将源码目录与编译输出目录分开。
详见官网

安装

Bash
1
2
3
4
5
6
7
#ubuntu
sudo apt install meson
#redhat
sudo yum install meson ninja-build
#或者通过pip安装
sudo apt-get install python3 python3-pip
pip3 install meson

运行

配置编译目录

Bash
1
2
3
4
5
6
cd /path/to/source/root
# 设置编译输出目录,然后编译
meson setup builddir
meson compile
# 或者在源码目录直接编译
meson compile -C builddir

语法

Text Only
1
meson [command] [arguments] [options]
通过设置参数:--buildtype设置编译参数

value meaning
plain no extra build flags are used, even for compiler warnings, useful for distro packagers and
debug debug info is generated but the result is not optimized, this is the default
debugoptimized debug info is generated and the code is optimized (on most compilers this means -g -O2)
release full optimization, no debug info

修改默认编译器

Text Only
1
2
cd /path/to/source/root
CC=clang CXX=clang++ meson setup buildclang

修改后台编译系统

meson默认使用ninja作为后端编译器,可以使用--backend=xx修改。

Bash
1
meson setup <build dir> --backend=vs
ninja默认会检测处理器个数,开启多核编译。

帮助

Text Only
1
meson --help