clap.toml configuration reference
Everything in clap.toml lives under one [project] table. Unknown keys are rejected with an error rather than silently ignored — a typo never silently disables a flag. CLI arguments override the file for the invocation.
Sources and output
[project]
name = "myapp" # default output name (default: "main")
sources = ["src/**/*.c"] # glob patterns expand recursively
exclude_sources = ["src/generated/**"] # removed from the expanded sources
entry = "src/main.c" # the translation unit with main(), when ambiguous
output = "bin/myapp" # explicit output path; default derives from name/target
artifact = "exe" # exe | object | static | shared | asm | preprocessCompilation
flags = ["-Wall", "-Wextra"] # extra compile flags, order preserved
link_flags = ["-lm"] # linker-only flags
includes = ["include", "vendor/json/include"] # -I search paths
defines = ["NDEBUG", "APP_VERSION=2"] # -D preprocessor defines
std = "c17" # shared C/C++ standard shortcut
c_std = "c17" # C standard specifically
cpp_std = "c++20" # C++ standard specifically
warnings = true # enable the compiler warning set
warnings_as_errors = true # promote warnings to errors
sanitizers = ["address", "undefined"] # where the zig toolchain supports them
release = true # optimized build, no debug info
debug = true # force debug build (the default)Libraries and packages
libraries = ["sqlite3"] # -l link libraries
library_paths = ["lib"] # -L search paths
packages = ["openssl", "libpng"] # pkg-config packages — cflags/libs resolve automatically
vcpkg_root = "C:/vcpkg" # opt into vcpkg manifest mode
vcpkg_triplet = "x64-windows" # defaults to project config, VCPKG_DEFAULT_TRIPLET, or hostpackages is the zero-friction path for system dependencies — see clap lock, clap deps, and the dependency documentation for the locking workflow.
Build behavior
target = "x86_64-windows-gnu" # cross-compilation triple; CLI --target/--profile override
compiler = "zig" # toolchain preference; default resolves the pinned zig
ninja = true # force ninja on/off (default: on when available)
jobs = 8 # parallel compile jobs
compile_commands = true # always emit compile_commands.json for editor tooling
sbom = true # emit a software bill of materials with each build
object_cache = true # cache object files across builds (integrity-verified)Declared dependencies
The top-level [dependencies] table pins vendored libraries declaratively — the reproducible form of clap vendor:
[dependencies.json]
url = "https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz"
sha256 = "d6c65aca6b1ed68e7a182f4757257b107ae403032760ed6ef121c9d55e81757d"Each key is the dependency name and becomes its directory under vendor/. url must use https, sha256 must be the 64-character lowercase hex digest of the download, and include optionally overrides the include root inside the extracted tree (conventional include//single_include/ layouts are auto-detected otherwise). sources optionally lists files inside the dependency tree that must be compiled and linked into the project — this is how compiled (non-header-only) libraries like cJSON or the SQLite amalgamation are consumed: Archives (.zip, .tar.gz, .tgz, .tar.xz, .tar.bz2) extract into vendor/<name>/; anything else is treated as a single file downloaded into vendor/<name>/.
clap add is the one-command way to write this table. Two forms: clap add <url> downloads the file, computes the SHA-256 pin itself, appends the [dependencies] entry, and vendors it immediately; clap add <name> uses the curated registry of hash-verified pins — doctest, cjson, sqlite, nlohmann-json — where the downloaded bytes are re-verified against the pin before anything is written (the registry is a convenience, never a trust root). Compiled entries in the registry (cjson, sqlite) carry their sources so the library links with zero flags. Editing the table by hand works exactly the same. clap sync downloads and verifies every declared dependency into vendor/. It is idempotent — entries already matching the pin report up to date — and it repairs drift: if vendor/ contents no longer match the pin in clap.toml, the configuration wins because it is the source of truth. The download is always hash-verified before any existing tree is touched.
[dependencies.cjson]
url = "https://github.com/DaveGamble/cJSON/archive/refs/tags/v1.7.18.tar.gz"
sha256 = "3aa806844a03442c00769b83e99970be70fbef03735ff898f4811dd03b9f5ee5"
sources = ["cJSON.c"]Entries are relative paths inside vendor/<name>/; a missing file fails the build with the exact remedy. Verified end-to-end: the cJSON recipe compiles cJSON.c into the project and #include <cJSON.h> resolves with zero flags.
Single-file pins (a URL pointing at one header rather than an archive) treat the payload itself as the source of truth: the live file hash is what drift detection verifies, and the .clap-vendor-*.json marker is provenance metadata only. A missing or tampered marker therefore does not block the build — the pin is still exactly what you declared — and clap sync rewrites the provenance in place instead of re-downloading.
For CI, clap deps is the gate: it exits non-zero when any declared dependency is missing or drifted and zero when everything is synced — no build required, so the check costs seconds before the real matrix starts.
Once synced, builds add the include root of every declared dependency automatically — #include <nlohmann/json.hpp> compiles with no -I flag at all. A dependency that is declared but missing, or whose vendored pin drifted, fails the build with the exact clap sync remedy instead of a misleading missing-header error.
Dev-dependencies
[dev-dependencies] is a second dependency table with exactly the same shape and rules as [dependencies] — url, sha256, include, sources, file_path, defines, links, platforms all behave identically, clap sync vendors both tables into vendor/, clap deps reports both with their scope, clap remove finds either, and clap update refreshes dev pins in the table they live in. The difference is scope, and scope is the whole point: test builds see both tables, production builds see only [dependencies]. A production source that includes a dev-dependency header fails to compile — test harnesses cannot leak into shipped binaries. clap add --dev doctest pins into the dev table in one command. Declaring the same name in both tables is a configuration error: a name means one thing.
[dev-dependencies.doctest]
url = "https://raw.githubusercontent.com/doctest/doctest/v2.4.11/doctest/doctest.h"
sha256 = "44faa038e9c3f9728efbda143748d01124ea0a27f4bf78f35a15d8fab2e039fb"Platform overrides
Per-target additions merge on top of the base configuration when the build target matches:
[project]
libraries = []
[project.platform.windows]
libraries = ["ws2_32"] # winsock only where it exists
[project.platform.linux]
libraries = ["pthread"]The override tables are exactly windows, linux, and macos — matched from the target triple — and only list-valued keys are accepted inside them: flags, link_flags, includes, defines, libraries, library_paths, packages. Override values append to the base lists rather than replacing them.
Discovery rules
clap walks up from the working directory looking for clap.toml, so any subdirectory of the project behaves like the root. With no configuration file at all, the unambiguous main.c/main.cpp convention applies — configuration is opt-in, not required.
Minimal example
[project]
name = "hello"
sources = ["src/**/*.c"]
warnings = true
[project.platform.windows]
libraries = ["ws2_32"]The keys above are the complete accepted set as of CLAP 0.50 — anything else in [project] fails fast with unknown [project] keys, which is the reference working as intended.