Skip to content
AgileLogics
4 min read

Build Systems: CMake

Prerequisites: Static & shared libraries

CMake describes a build in a way that then generates the actual Makefile (or an equivalent for another platform/toolchain) for you — the dominant choice for any C project meant to build across Linux, macOS, and Windows alike.

cmake_minimum_required(VERSION 3.20)
project(MyApp C)

add_executable(myapp main.c math_utils.c)
mkdir build && cd build
cmake ..
cmake --build .

Most real, larger C (and C++) projects use CMake rather than a hand-written Makefile, precisely because it abstracts away differences between platforms and compilers.