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

cx runs programs it doesn't contain:

  • CMake (and its ctest) builds and tests.
  • Ninja is the build tool CMake drives, when there is one.
  • clang-format is used by cx fmt.
  • clang-tidy is used by cx lint.
  • Doxygen is used by cx doc.
  • SCons, and the Python it runs on, build SCons dependencies.
  • make and autoreconf build dependencies with a configure script.
  • vcpkg installs vcpkg dependencies.

Each one is taken from PATH when it's installed there. When it isn't, cx downloads a release it pins for CMake, Ninja, the LLVM tools, Doxygen, SCons and Python, checks its SHA-256 and unpacks it into its cache. So a machine needs only a compiler (and git for git dependencies) to use cx. cx never downloads make, autoreconf or vcpkg; it only looks for them, and only when a dependency needs them.

$ cx tools list
cmake 3.28.3 /usr/bin/cmake (from PATH)
ninja 1.13.2 ~/.cache/cx/tools/ninja-1.13.2-linux-x86_64/ninja (managed by cx)
clang-format 23.1.5 not downloaded yet: cx downloads it when it's needed, or with `cx tools install clang-format`
clang-tidy 18.1.3 /usr/bin/clang-tidy (from PATH)
doxygen 1.18.0 not downloaded yet: cx downloads it when it's needed, or with `cx tools install doxygen`
python 3.12.3 /usr/bin/python3 (from PATH)
scons 4.11.1 not downloaded yet: cx downloads it when it's needed, or with `cx tools install scons`
vcpkg 2025.12.16 /opt/vcpkg/vcpkg (from PATH)
make 4.3 /usr/bin/make (from PATH)
autoreconf 2.71 /usr/bin/autoreconf (from PATH)

The pinned releases

Tool Version Downloaded from
CMake 4.5.1 Kitware's release archives on GitHub
Ninja 1.13.2 the Ninja project's releases on GitHub
clang-format 23.1.5 the clang-format wheel on PyPI (a self-contained build of LLVM's tool)
clang-tidy 23.1.4 the clang-tidy wheel on PyPI, with Clang's built-in headers
Doxygen 1.18.0 the Doxygen project's release binaries on GitHub (from the Linux archive, only the doxygen program is unpacked)
Python 3.13.18 python-build-standalone's install_only_stripped builds on GitHub
SCons 4.11.1 the scons wheel on PyPI (pure Python, run with the Python above or the one in PATH)
  • Platforms: downloads exist for Linux (x86-64 and AArch64, glibc 2.28 or newer), macOS (Intel and Apple silicon) and Windows (x86-64 and Arm64). There is no clang-tidy download for Windows on Arm, and no Doxygen download for Linux on AArch64 or Windows on Arm. On other platforms, install the tools yourself.
  • Verification: the SHA-256 of every download is built into cx, so a changed or corrupt file is never unpacked.
  • Where they go: each tool is unpacked into <cache>/tools/<tool>-<version>-<platform>/, where <cache> is CX_HOME (see Environment variables). An interrupted download is never used; cx starts it again next time. To remove the tools, delete that directory.
  • Updates: a new cx can pin newer releases. The old directories stay until you delete them.

Choosing a tool: tools.<name>

Each tool has a setting in config.toml and an environment variable, which wins over the files:

Setting Environment variable
tools.cmake CX_CMAKE
tools.ninja CX_NINJA
tools.clang-format CX_CLANG_FORMAT
tools.clang-tidy CX_CLANG_TIDY
tools.doxygen CX_DOXYGEN
tools.python CX_PYTHON
tools.scons CX_SCONS
tools.vcpkg CX_VCPKG
tools.make CX_MAKE
tools.autoreconf CX_AUTORECONF

Its value is one of these:

  • "auto" (default): the program in PATH. If it's missing, the pinned release.
    • CMake in PATH must be 3.25 or newer, or cx uses its own CMake instead.
    • Ninja is never downloaded automatically on Windows. Without it, CMake uses the Visual Studio generator, which finds MSVC without a developer prompt. Ninja with MSVC only works from one.
    • Python in PATH (python3, then python) must be 3.7 or newer.
    • vcpkg is $VCPKG_ROOT/vcpkg before the one in PATH.
    • make is gmake, make or mingw32-make, the first in PATH.
    • make, autoreconf and vcpkg have no pinned release: when they're missing, the error says how to install them.
  • "system": only the program in PATH, and an error if it's missing. Ninja is the exception: if it's missing, CMake picks its default generator (Make, or Visual Studio).
  • "managed": always the pinned release, even when PATH has one (not for make, autoreconf and vcpkg).
  • A program: a path such as "/opt/llvm-19/bin/clang-format" (in a project's .cx/config.toml, relative to the project), or a name looked up in PATH such as "clang-format-19".
# .cx/config.toml: everyone on the project formats with the same clang-format
[tools]
clang-format = "managed"

Pinning clang-format this way is worth it: different clang-format versions format the same file differently, so cx fmt --check in CI can disagree with a developer's machine when each uses its own copy.

Downloading ahead of time

cx downloads a tool the first time it needs one. To download them before going offline, or to bake them into a CI image, run:

$ cx tools install # CMake, Ninja, clang-format, clang-tidy and Doxygen
$ cx tools install clang-tidy # just one
$ cx tools install scons # also for SCons dependencies (and `python` for its Python)

cx tools install puts the pinned release in the cache even when PATH has the tool. Builds only use that copy when the setting is "managed", or when "auto" finds no tool in PATH. cx says so when that's the case.

Offline, and mirrors

  • --offline: cx never downloads a tool. A tool that isn't in the cache is an error that says how to get it, except for an automatic Ninja: cx then uses CMake's default generator.
  • A failed download is an error as well, again except for an automatic Ninja, which only gets a warning.
  • tools.mirror (or CX_TOOLS_MIRROR): where to download from instead, for networks that can't reach GitHub or PyPI. It's a base URL, a file:// URL or a directory, laid out as <mirror>/<tool>/<version>/<file name of the original download>, for example <mirror>/ninja/1.13.2/ninja-linux.zip. The checksums are the same as for the original downloads. A local mirror also works offline.