Skip to content
Skills Library
Programming · Building & coding

cmake-guide

/cmake-guide

Use when editing CMake build files for C/C++ projects on CMake 3.20+. Triggers on `CMakeLists.txt`, `*.cmake` files and on prompts about adding targets, linking libraries, dependency fetching, test setup, install rules, or PUBLIC/PRIVATE/INTERFACE visibility, even when the user doesn't say 'CMake'. Apply for FetchContent, find_package, target_link_libraries, CTest.

Repository
platform ↗
Licence
MIT
Last repository change
08.10.2026

Assessment and security

90/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content25 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
13
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 08.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Use when editing CMake build files for C/C++ projects on CMake 3.20+. Triggers on `CMakeLists.txt`, `*.cmake` files and on prompts about adding targets, linking libraries, dependency fetching, test setup, install rules, or PUBLIC/PRIVATE/INTERFACE visibility, even when the user doesn't say 'CMake'. Apply for FetchContent, find_package, target_link_libraries, CTest.

Triggers from the description

t say
Original author description

Use when editing CMake build files for C/C++ projects on CMake 3.20+. Triggers on `CMakeLists.txt`, `*.cmake` files and on prompts about adding targets, linking libraries, dependency fetching, test setup, install rules, or PUBLIC/PRIVATE/INTERFACE visibility, even when the user doesn't say 'CMake'. Apply for FetchContent, find_package, target_link_libraries, CTest.

How it works

  1. Requirements
  2. Essentials
  3. Gotchas
  4. Progressive disclosure
Original SKILL.md headings · 35 lines, 249 words
SKILL.md preview
---
name: cmake-guide
description: "Use when editing CMake build files for C/C++ projects on CMake 3.20+. Triggers on `CMakeLists.txt`, `*.cmake` files and on prompts about adding targets, linking libraries, dependency fetching, test setup, install rules, or PUBLIC/PRIVATE/INTERFACE visibility, even when the user doesn't say 'CMake'. Apply for FetchContent, find_package, target_link_libraries, CTest."
---

# CMake Coding Guidelines

Define builds through CMake targets with explicit dependencies, visibility, and installation rules.

## Requirements

- CMake ≥ 3.20; modern target-based usage.

## Essentials

- **Target-based builds** - Use targets, no global include/link dirs, see [references/target-types.md](references/target-types.md), [references/compile-options.md](references/compile-options.md)
- **Visibility specifiers** - Use PUBLIC/PRIVATE/INTERFACE correctly, see [references/visibility-specifiers.md](references/visibility-specifiers.md)
- **Dependencies** - Declare explicitly with find_package, see [references/find-package.md](references/find-package.md)
- **Testing** - Enable testing with CTest, see [references/testing.md](references/testing.md)
- **Project structure** - Organize multi-directory projects, see [references/project-structure.md](references/project-structure.md)

## Gotchas

- `target_link_libraries` scope matters: PRIVATE = consumers don't see it, INTERFACE = no compile, PUBLIC = both. Wrong scope leaks transitive deps
- `find_package` may use PATHS or HINTS but ignores both if a config file is on a system path; use `<Pkg>_ROOT` env var to force-locate
- Generator expressions (`$<CONFIG:Debug>`) only evaluate at build time: debugging by `message()` won't show their final values
- `CMAKE_INSTALL_PREFIX` is captured at configure time; changing it after first config requires a clean reconfigure

## Progressive disclosure

- Read [references/target-types.md](references/target-types.md) - Load when choosing between library types or executables
- Read [references/visibility-specifiers.md](references/visibility-specifiers.md) - Load when deciding PUBLIC vs PRIVATE vs INTERFACE
- Read [references/compile-options.md](references/compile-options.md) - Load when adding compiler flags to targets
- Read [references/find-package.md](references/find-package.md) - Load when integrating external dependencies
- Read [references/testing.md](references/testing.md) - Load when setting up CTest or test targets
- Read [references/project-structure.md](references/project-structure.md) - Load when organizing multi-directory CMake projects
- Read [references/generator-expressions.md](references/generator-expressions.md) - Load when using conditional build configuration
- Read [references/installation.md](references/installation.md) - Load when creating install targets or package exports
Files in this package (13)
  • SKILL.md 3 KB
  • SOURCES.md 1 KB
  • eval-queries.json 5 KB
  • evals.json 2 KB
  • moon.yml 1 KB
  • references/compile-options.md 1 KB
  • references/find-package.md 1 KB
  • references/generator-expressions.md 1 KB
  • references/installation.md 1 KB
  • references/project-structure.md 1 KB
  • references/target-types.md 1 KB
  • references/testing.md 1 KB
  • references/visibility-specifiers.md 1 KB

Versions

The database has no other skills named cmake-guide.

Database snapshot: 13.11.2026 · package version 27f0f911dd21 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 2 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100cmake
    CMake build system skill for C/C++ projects. Use when writing or refactoring CMakeLists.txt, configuring out-of-source builds, selecting generators (Ninja, Make, VS), managing targets and dependencies with target_link_libraries, integrating external packages via find_package or…
  • 100cmake
    Use when writing CMakeLists.txt, out-of-source builds, target_link_libraries, target properties, find_package/FetchContent, toolchain files, CPack, CMake presets, or cmake configure errors.
  • 95cmake
    CMake build system for C/C++ projects. Modern CMake (3.20+) with targets, properties, presets (CMakePresets.json), FetchContent, find_package, generator expressions, install rules, vcpkg/Conan integration. USE WHEN: user mentions "CMake", "CMakeLists.txt", "CMakePresets",…
  • 90qt-cmake-project
    Use to generate or update Qt 6 CMake projects or edit CMakeLists.txt, add sources/resources or define targets (executable, QML module, library).
  • 91cmake-build-system
    CMake build-system design. Use for Literate AI workflow tasks.
  • 87cmake-vcpkg
    C++ project configuration and package management Triggers on: **/*.cmake, **/CMakeLists.txt, **/*.cpp, **/*.h, **/*.hpp

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.