2021-08-05 19:59:29 +08:00
|
|
|
# 使用 CMake 构建项目
|
|
|
|
|
2021-10-16 17:50:51 +08:00
|
|
|
## 1. 基本使用
|
2021-08-05 19:59:29 +08:00
|
|
|
|
|
|
|
CMake 会生成各种临时文件,用下面命令可将这些临时文件集中在 build 文件夹下:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
cmake -S . -B build
|
|
|
|
```
|
|
|
|
|
2021-10-16 17:50:51 +08:00
|
|
|
## 2. 宏
|
2021-08-05 19:59:29 +08:00
|
|
|
|
2021-10-16 17:50:51 +08:00
|
|
|
CMake 宏可通过编译参数指定,也可以写在 CMakeLists.txt 文件中:
|
2021-08-05 19:59:29 +08:00
|
|
|
|
|
|
|
```bash
|
2021-10-16 17:50:51 +08:00
|
|
|
cmake -DCMAKE_INSTALL_PREFIX=/opt/demo -DCMAKE_SKIP_RPATH=TRUE
|
2021-08-05 19:59:29 +08:00
|
|
|
```
|