$npx skillfedfor your agent

cmake

Master modern CMake for C/C++ with target-first principles, out-of-source builds, and dependency management via find_package or FetchContent. Configure generators like Ninja and Make, set up sanitizers, cross-compile with toolchain files, and leverage CMake Presets for reproducible builds.

CMake guides you through modern target-first build configuration for C/C++ projects, from dependency management to cross-compilation.

AI-generated summary based on this skill's SKILL.md

148 19 MITupdated by mohitmishra786

Decision gist · record as of 2026-06-27

CMake guides you through modern target-first build configuration for C/C++ projects, from dependency management to cross-compilation. Master modern CMake for C/C++ with target-first principles, out-of-source builds, and dependency management via find_package or FetchContent. Configure generators like Ninja and Make, set up sanitizers, cross-compile with toolchain files, and leverage CMake Presets for reproducible builds.

manual: git clone https://github.com/mohitmishra786/low-level-dev-skills → cp -r low-level-dev-skills/skills/build-systems/cmake ~/.claude/skills/cmake
skills/build-systems/cmake/SKILL.md · version edc54977

Use it when

  • cmake find_package locates pre-installed packages on your system via Find modules or config files, ideal for system libraries.
  • cmake Configure external dependencies via find_package(PackageName) or FetchContent_Declare().

Verify before relying

Read SKILL.md below before installing (2 files). Open directory: indexed for reading, not audited.

Same gist for agents: .md · .json

Install

mohitmishra786/low-level-dev-skills/cmake · repository language: JavaScript

Open directory. Skills are indexed for reading, not audited. Review a skill's body before installing it.

Frequently asked questions

AI-generated answers based on this skill's SKILL.md and metadata

How do I write CMakeLists.txt for a C/C++ project?

cmake uses a target-first approach. Start with cmake_minimum_required() and project(), then define targets using add_executable() or add_library(). Use target_include_directories(), target_link_libraries(), and target_compile_options() to configure each target's properties. Apply PUBLIC, PRIVATE, or INTERFACE keywords to control visibility. cmake supports out-of-source builds—create a separate build directory, run cmake from there, and keep source clean. This modern pattern scales better than older file-level commands.

What's the difference between find_package and fetchcontent in cmake?

cmake find_package locates pre-installed packages on your system via Find modules or config files, ideal for system libraries. FetchContent downloads and builds dependencies at configure time, giving you version control and reproducibility. Use find_package for optional or system-provided libraries; use FetchContent for vendored or tightly-versioned dependencies. cmake Presets can pin both strategies for team consistency.

How do I configure cmake to handle external dependencies and packages?

cmake Configure external dependencies via find_package(PackageName) or FetchContent_Declare(). For find_package, ensure the package's config or Find module is in CMAKE_PREFIX_PATH. Handle missing packages gracefully with REQUIRED or QUIET flags. Use target_link_libraries() to attach dependencies to your targets. For complex setups, cmake Presets define toolchain paths and cache variables, and cpack handles installation rules and distribution.

How do I set up cross-compilation with cmake toolchain files?

cmake cross-compilation requires a toolchain file specifying the target architecture. Create a file (e.g., aarch64-toolchain.cmake) setting CMAKE_SYSTEM_NAME, CMAKE_SYSTEM_PROCESSOR, CMAKE_C_COMPILER, and CMAKE_CXX_COMPILER. Pass it via cmake -DCMAKE_TOOLCHAIN_FILE=aarch64-toolchain.cmake. Define CMAKE_FIND_ROOT_PATH to guide dependency search. cmake Presets can embed toolchain references for reproducible arm or other cross-builds.

How do I enable address sanitizer and configure debug/release builds?

cmake Enable AddressSanitizer by adding compiler flags: target_compile_options(mytarget PRIVATE -fsanitize=address -g). For debug/release, set CMAKE_BUILD_TYPE (single-config) or use multi-config generators like Visual Studio. Use generator expressions like $<CONFIG:Debug> to apply flags conditionally. cmake Presets simplify this: define separate preset entries for debug (with sanitizer) and release builds, ensuring consistent configuration across your team.

What should I do if cmake can't find a package I need?

cmake Configure error "can't find package" usually means the package's config or Find module isn't in CMAKE_PREFIX_PATH. Check the package's installation location and add its directory to CMAKE_PREFIX_PATH via -DCMAKE_PREFIX_PATH=/path/to/package. Verify the Find module name matches find_package() exactly. Use cmake --debug-output to trace search paths. Alternatively, use FetchContent to download the dependency directly, bypassing system search entirely.

SKILL.md

Rendered from the published skill. Quoted content, verbatim.

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

(truncated - see the full file via the links below)

File tree — 2 files
skills/build-systems/cmake/SKILL.md
skills/build-systems/cmake/references/templates.md

Let your AI agent find skills like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 56,283 agent skills by what they can do, searchable in plain language.

wish › “Write or refactor CMakeLists.txt files for C/C++ projects”

Give your agent the search over MCP, or paste the wish link into any chat. No install? Search from any chat →

Related skills

Qt Cmake Project
by TheQtCompanyRnD · TheQtCompanyRnD/agent-skills

Qt Cmake Project helps you create and maintain Qt 6 projects using CMake, handling executable targets, libraries, QML modules, and resource configuration. It enforces modern CMake best practices and Qt 6 conventions to prevent common build mistakes.

no license declared → metadata onlyupdated Jul 2026
★ 322repo stars
cpp-rules
by softspark · softspark/ai-toolkit

cpp-rules provides comprehensive C++ development standards drawn from ai-toolkit's rule library. It covers naming conventions, modern language features, memory management with smart pointers, and framework guidance for CMake, Boost, Qt, and gRPC. The rules emphasize RAII patterns, error handling strategies, concurrency practices, and design patterns to maintain code quality and security across C++ projects.

Apache-2.0updated Jul 2026
★ 161repo stars
cpp-expert
by personamanagmentlayer · personamanagmentlayer/pcl

C++ Expert provides in-depth instruction on contemporary language standards and advanced development practices. Learn concepts, ranges, coroutines, and memory strategies alongside performance techniques like zero-cost abstractions and compile-time computation. Build proficiency with smart pointers, move semantics, and template metaprogramming for production-grade applications.

Apache-2.0updated Mar 2026
★ 38repo stars
make
by mohitmishra786 · mohitmishra786/low-level-dev-skills

This skill guides you through building maintainable Makefiles for C/C++ using phony targets, pattern rules, and automatic dependency tracking. Learn to structure multi-file projects, manage compiler flags, diagnose rebuild issues, and convert ad-hoc compile commands into robust build systems.

MITupdated Jun 2026
★ 148repo stars
msvc-cl
by mohitmishra786 · mohitmishra786/low-level-dev-skills

Master Windows C/C++ compilation with MSVC cl.exe and clang-cl. This skill maps GCC/Clang flags to MSVC equivalents, explains runtime library choices (/MT vs /MD), guides PDB setup for debugging, and diagnoses common linker failures. Use it when configuring Visual Studio builds, MSBuild projects, or switching to clang-cl as a drop-in MSVC replacement.

MITupdated Jun 2026
★ 148repo stars
gcc
by mohitmishra786 · mohitmishra786/low-level-dev-skills

Master GCC flag selection for debug and release builds, from optimization levels and warning discipline to link-time optimization and profile-guided optimization. Covers common compilation errors, sanitizer instrumentation, and integration with GNU Make and CMake.

MITupdated Jun 2026
★ 148repo stars
Tags
build-automationdependency-resolutioncross-platform-compilationcompiler-configurationproject-scaffoldingsanitizer-integrationci-cd-pipelinetarget-based-design