CMake from scratch / Chapter 1
What is CMake?
CMake, like many tools in software engineering, solves a problem. The problem CMake solves is cross-platform (Windows, MacOs, *nix)1 C++ compilation and project definition.
What does CMake let you do?
CMake lets you provide a high level description of your C++ project, and hide all of the platform specific shenanigans from you. 2
The basic flow
- You create a
CMakeLists.txtat the root of your project3, write all of your dependencies, source files, and flags. - Tell CMake to configure your project’s
CMakeLists.txt - Tell CMake to build your program
Footnotes
-
Technically, it’s also for cross-toolchain (Eg; gcc & clang on the same host system, Make / Ninja, etc…) ↩
-
In quite a few situations where CMake gets more advanced, you end up having to deal with platform specific code anyways. ↩
-
In reality, CMake doesn’t particularly care about where you place source files / CMakeLists. ↩