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.
- Author
- xonovex ↗
- Repository
- platform ↗
- Licence
- MIT
- Last repository change
- 08.10.2026
Assessment and security
- Files in this package
- 13
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 08.10.2026, without references to retired models or APIs.
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
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
- Requirements
- Essentials
- Gotchas
- Progressive disclosure
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