The cx Book 1.0.0
cx: a package manager and build tool for C and C++
Loading...
Searching...
No Matches
cx.toml

The manifest of a package. cx warns about keys it doesn't know.

[package]
name = "hello" # required: letters, digits, - and _, starting with a letter
version = "0.1.0" # semver; default 0.1.0
language = "c++" # "c" or "c++"; default "c++"
standard = 23 # C++: 98 11 14 17 20 23 26 (default 23). C: 90 99 11 17 23 (default 17)
description = "..." # optional
authors = [{ name = "Ada Lovelace", email = "ada@example.com" }] # optional, see below
license = "MIT" # optional (required by `cx publish`)
default-run = "tool" # optional: the binary `cx run` runs when there are several
import-std = false # optional: `import std;` (C++23, see C++20 modules)
include = ["data/**"] # optional: extra files for `cx package`
exclude = ["tests/big/**"] # optional: files to leave out of `cx package`
[dependencies]
# name = <dependency>, see below
[dev-dependencies]
# only linked into tests; cannot be optional
[build-dependencies]
# cx packages whose binaries [[generate]] runs as {bin:<package>/<binary>}
[features]
# feature = ["what it enables", ...], see Features
[build]
defines = ["MY_FLAG=1"] # compile definitions
flags = ["-fno-exceptions"] # compiler flags
link-flags = ["-Wl,--as-needed"]
link-libraries = ["m"] # extra libraries to link
include-dirs = ["third_party"] # extra include directories, relative to the package
warnings = true # -Wall -Wextra -Wpedantic (/W4 on MSVC) for this package only
[lib]
kind = "static" # "static" (default), "shared" or "both"; see Package layout
[[bin]] # also [[example]] and [[bench]]; see Package layout
name = "tool"
path = "tools/tool.cpp"
required-features = ["cli"]
[toolchain] # see Toolchains
cxx = "clang++"
min-version = "17"
[target.aarch64-linux-gnu] # `--target aarch64-linux-gnu`
cmake-toolchain-file = "cmake/aarch64.cmake"
runner = "qemu-aarch64"
[target.'cfg(windows)'.dependencies] # only on matching platforms; see Dependencies
wil = "^1.0"
[[generate]] # see Code generation and build scripts
command = ["protoc", "--cpp_out={out}", "proto/api.proto"]
inputs = ["proto/api.proto"]
outputs = ["api.pb.h", "api.pb.cc"]
[profile.release] # see Profiles
lto = true
[profile.asan]
inherits = "debug"
sanitizers = ["address", "undefined"]
[resolver] # see Dependencies
incompatible-standards = "fallback" # "fallback" (default), "deny" or "allow"
max-standard = 20 # default: package.standard

standard also accepts strings such as "c++20" or "c17".

A workspace's root cx.toml also has (see Workspaces):

[workspace]
members = ["core", "apps/*"] # directories or globs, relative to this file
exclude = ["apps/experimental"]
[workspace.dependencies] # used by members as `name = { workspace = true }`
fmt = "^11.1"

Without [package], it is a virtual workspace: only [workspace], [profile.*], [toolchain], [target.*] toolchains and [resolver] are allowed.

Authors

authors lists the package's authors the way uv (and pyproject.toml) does: each one is a table with a name, an email, or both.

authors = [
{ name = "Ada Lovelace", email = "ada@example.com" },
{ name = "Charles Babbage" },
{ email = "team@example.com" },
]
  • Names must not contain <, > or ,. Emails must look like local@domain. Anything else is an error that names the entry (package.authors[1]).
  • Strings in the older "Name <email>" form (or just "Name") are read as well, so existing manifests keep working.
  • cx new and cx init fill it in from git, like uv init: the author git would record (GIT_AUTHOR_NAME/GIT_AUTHOR_EMAIL, else user.name / user.email). --author-from none leaves it out; --author-from git fails when git knows no author.
  • cx metadata reports it as "authors": [{"name": ..., "email": ...}].

Dependency keys

Key Applies to Meaning
version registry version requirement, e.g. "^1.2". A plain string name = "^1.2" means the same
registry registry name of a registry other than the default
git git repository URL
tag / branch / rev git what to check out (at most one; default: the remote's default branch)
path path directory, relative to this cx.toml
version git, path the exact version a plain CMake source provides
build-system git, path how a source without a cx.toml is built: "cmake", "configure" or "scons" (default: the first of CMakeLists.txt, configure/configure.ac, SConstruct)
libs configure, SCons static libraries the project builds, [<dir>/]<name> (default: the dependency name without lib)
include-dirs configure, SCons include directories (default: include)
system system true, or the find_package name
vcpkg vcpkg true, or the vcpkg port name (default: the dependency name)
package system, vcpkg find_package name when system = true, or of a vcpkg port (default: the dependency name)
version system, vcpkg minimum version passed to find_package
components system, vcpkg find_package components
targets all CMake targets to link (default: guessed; configure and SCons projects are <name>::<name>)
options plain CMake, configure, SCons plain CMake: ["KEY=VALUE"] cache variables set before the project is added; configure and SCons: arguments passed on as they are
optional all but dev only included when a feature enables it
features registry, git, path, vcpkg features of the dependency to enable (of a vcpkg port: the port's features)
default-features registry, git, path, vcpkg false to not enable the dependency's default feature (vcpkg: the port's default features)
public all but dev true: part of the library's interface, so its users get the dependency's headers too; false: private. Unset: public only if the package's include/ headers include it
workspace members true: use the declaration from [workspace.dependencies]; only features, optional, default-features and public may be added

[target.<platform>.dependencies] and [target.<platform>.dev-dependencies] take the same keys. <platform> is a cfg(...) condition or a target triple; a name can only be declared in one section. See Dependencies and Features for how these fit together.

Profile keys

[profile.<name>] takes inherits, opt-level, debug, lto, sanitizers, defines, flags and link-flags. See Profiles. Profile names follow the rules for package names; cx and package are reserved.