cmake-c

CMake

Specific best practices and architectural patterns when working with CMake.

Details

Language / Topic
cC
Category
framework

Rules

balanced
- Require modern CMake (`cmake_minimum_required(VERSION 3.15+)`) and use **target-based** commands (`target_include_directories`).
- Prefix all custom variables strictly with the project name (e.g., `MYPROJ_SOURCES`) to avoid namespace collisions.
- Avoid using `file(GLOB)` to gather source files; explicitly list them so build systems correctly detect new file additions.
- Declare targets explicitly as `PRIVATE`, `PUBLIC`, or `INTERFACE` strictly to manage include dependencies and linking inheritance.