ekala-project/corepkgs / .agents/skills/cmake
cmake
VerifiedPackage a CMake-based project for corepkgs. Use when a source tree has a CMakeLists.txt — covers the minimal derivation, cmakeEntries, cross-compilation, and diagnosing CMake configure failures.
CMake Build System
Minimal Example
{
lib,
stdenv,
fetchFromGitHub,
cmake,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "example";
version = "1.0.0";
src = fetchFromGitHub {
owner = "example";
repo = "example";
tag = "v${finalAttrs.version}";
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
};
nativeBuildInputs = [
cmake
cmake.configurePhaseHook # Required
];
meta = {
description = "Example CMake package";
license = lib.licenses.mit;
};
})
Essential Requirements
Always include cmake.configurePhaseHook in nativeBuildInputs.
cmakealone provides the cmake binary and the setup hook (setup-hook.sh), which defines allcmakeEntrieshelpers (setCMakeEntry,prependCMakeEntry,concatCMakeEntryFlagsTo, etc.) andcmakeConfigurePhase.cmake.configurePhaseHookreplaces the default configure phase withcmakeConfigurePhase, which assemblescmakeEntries+cmakeFlagsinto the final cmake invocation. Without it, the configure phase is the generic autotools-style one and cmake entries/flags are ignored.
Common Patterns
With Dependencies
nativeBuildInputs = [
cmake
cmake.configurePhaseHook
pkg-config
];
buildInputs = [
zlib
openssl
];
CMake Entries (Preferred)
Use cmakeEntries to specify CMake -D cache entries as a structured attrset.
Booleans are automatically converted to ON/OFF.
cmakeEntries = {
BUILD_SHARED_LIBS = true;
ENABLE_TESTS = false;
CMAKE_INSTALL_LIBDIR = "lib";
};
CMake Flags (non--D only)
cmakeFlags is reserved for non--D flags (warning suppression, generator
selection, source-dir overrides, unset flags). All -D entries must use
cmakeEntries.
cmakeFlags = [
"-Wno-dev"
"-H.."
"-UCMAKE_INSTALL_LIBDIR" # unset (-U), not a -D flag
];
Both can be used together. cmakeEntries entries are emitted first, then
cmakeFlags / cmakeFlagsArray are appended.
Cross-Compilation
strictDeps = true;
nativeBuildInputs = [ cmake cmake.configurePhaseHook pkg-config ];
buildInputs = [ zlib ];
depsBuildBuild = [ pkg-config ];
Troubleshooting
CMake can't find dependencies:
cmakeEntries = {
ZLIB_ROOT = "${zlib}";
OPENSSL_ROOT_DIR = "${openssl}";
};
Library install to lib64:
cmakeEntries = {
CMAKE_INSTALL_LIBDIR = "lib";
};
Install prefix issues:
cmakeEntries = {
CMAKE_INSTALL_PREFIX = "${placeholder "out"}";
};
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 192k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 192k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 192k | Updated | Claude CodeCodex | Verified | Install |