This is your reference guide when you need to write or fix CMakeLists.txt files for C/C++ projects. It pushes modern, target-first CMake practices (target_link_libraries, target_compile_options) and explicitly tells you to avoid the old global commands. You get concrete patterns for out-of-source builds, FetchContent for pulling in dependencies, find_package for system libraries, and toolchain files for cross-compilation. The sanitizer integration and CMake Presets sections are especially handy if you're setting up CI or trying to standardize builds across a team. The error table at the end covers the usual "can't find package" headaches. It assumes CMake 3.20 or newer, so if you're stuck on an older version, some syntax won't work.

skills.sh installs
1.8K
GitHub stars
279
last updated
Aug 21, 2026

Install

$ npx -y skills add mohitmishra786/low-level-dev-skills --skill cmake --agent claude-code

Installs into .claude/skills of the current project.

Files

CMake

Purpose

Guide agents through modern (target-first) CMake for C/C++ projects: out-of-source builds, dependency management, generator selection, and integration with CI and IDEs.

Triggers

  • "How do I write a CMakeLists.txt for my project?"
  • "How do I add an external library with CMake?"
  • "CMake can't find my package / library"
  • "How do I enable sanitizers in CMake?"
  • "How do I cross-compile with CMake?"
  • "How do I use CMake Presets?"

Workflow

1. Modern CMake principles

  • Define targets, not variables. Use target_* commands.
  • Use PUBLIC/PRIVATE/INTERFACE to control property propagation.
  • Never use include_directories() or link_libraries() (legacy).
  • Minimum CMake version: cmake_minimum_required(VERSION 3.20) for most features.

2. Minimal project

cmake_minimum_required(VERSION 3.20)
project(MyApp VERSION 1.0 LANGUAGES C CXX)

set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_executable(myapp
    src/main.c
    src/utils.c
)

target_include_directories(myapp PRIVATE include)
target_compile_options(myapp PRIVATE -Wall -Wextra)

Sponsors

Details

Repository
github.com/mohitmishra786/low-level-dev-skills
Categories
DevOps & CI/CD, Documentation, Code Review & Quality
First seen
May 16, 2026

More from mohitmishra786/low-level-dev-skills

All 54
1hubspot avatarsales-reportinghubspot/agent-cli-skillsDaily briefings, pipeline snapshots, and win/loss analysis from the terminal — closing-this-week, open pipeline by stage/owner, and closed-won vs closed-lost ov1.8Kskills.sh installs
2mblode avatarmulti-tenant-architecturemblode/agent-skillsProvides architecture guidance for multi-tenant SaaS platforms on Cloudflare or Vercel. Covers platform choice, domain strategy, tenant identification and isola1.8Kskills.sh installs
3github avatargtm-product-led-growthgithub/awesome-copilotBuild self-serve acquisition and expansion motions. Use when deciding PLG vs sales-led, optimizing activation, driving freemium conversion, building growth equa1.8Kskills.sh installs
4colbymchenry avataragent-evalcolbymchenry/codegraphBenchmark CodeGraph retrieval quality on a real codebase by comparing agent behavior with vs without CodeGraph. Use when the user runs /agent-eval or asks to te1.8Kskills.sh installs
5nvidia avatarmcore-run-on-slurmnvidia/skillsHow to launch distributed Megatron-LM training jobs on a SLURM cluster. Covers a minimal sbatch skeleton, environment-variable setup for torch.distributed.run, 1.8Kskills.sh installs
6manutej avatarpostgresql-database-engineeringmanutej/luxor-claude-marketplaceComprehensive PostgreSQL database engineering skill covering indexing strategies, query optimization, performance tuning, partitioning, replication, backup and 1.8Kskills.sh installs