← ClaudeAtlas

cmake-presetslisted

Modern CMake builds: target-based rules, CMakePresets.json with configure, build, test and workflow presets, toolchains with a vcpkg manifest or Conan 2, FetchContent vs find_package, warning, hardening and sanitizer presets, clang-tidy and ccache, install/export packaging, and C++20 modules. Load when creating, fixing or modernizing a CMake build.
rustcircle/c101 · ★ 0 · AI & Automation · score 65
Install: claude install-skill rustcircle/c101
# CMake presets and modern builds Baseline: `cmake_minimum_required(VERSION 3.25...4.4)` (workflow presets need 3.25, C++ modules 3.28). The presets, install/export and worked example ran on CMake 4.4 + Ninja 1.13. Split: `CMakeLists.txt` describes targets and their usage requirements; build-variant policy (build type, sanitizers, `-Werror`, toolchain, launcher) lives in presets. Deep material: [preset catalogue](references/preset-catalogue.md) | [dependencies, packaging and CI](references/deps-packaging-ci.md) ```bash cmake --version; ninja --version ls CMakePresets.json CMakeUserPresets.json vcpkg.json conanfile.* .clang-tidy 2>/dev/null cmake --list-presets=all 2>/dev/null grep -rnE 'CMAKE_CXX_FLAGS|include_directories\(|add_definitions\(|link_libraries\(|file\(GLOB' \ --include=CMakeLists.txt --include='*.cmake' . | grep -v '/build/' | head -20 # record: minimum version, generator, dependency manager, existing presets, global-flag smells ``` ## 1. Target-based rules | Directory-global (remove) | Per target (write) | |---|---| | `set(CMAKE_CXX_FLAGS "... -std=c++17")` | `target_compile_features(geo PUBLIC cxx_std_20)` + `set(CMAKE_CXX_EXTENSIONS OFF)` before the targets (else `-std=gnu++20`) | | `include_directories(include)` | `target_sources(geo PUBLIC FILE_SET HEADERS BASE_DIRS include FILES ...)` or `target_include_directories` with `$<BUILD_INTERFACE:>`/`$<INSTALL_INTERFACE:>` | | `add_definitions(-DX)` | `target_compile_definitions(geo PUBLIC X)` | | `link_lib