Using CMake in a Project¶
This short guide covers the common CMake workflow used in projects, including building static or shared libraries, passing macro definitions, and choosing a compiler.
For more detail, see the CMake manual in Chinese.
Environment¶
- Ubuntu
- Linux kernel:
5.4.0-150-generic
Basic Build Flow¶
From the project root, create a separate build directory and generate the build files:
Keeping generated build files in a dedicated build directory prevents them from mixing with source files and makes it easy to remove and rebuild the project.