cx install builds a package in release mode and installs it into a prefix. With --lib, it also installs the library with a CMake package config, so plain CMake projects can use a cx package.
$ cx install # this package's binaries into ~/.local/bin
$ cx install --git https://github.com/me/tool --tag v1.0
$ cx install --path ../tool
$ cx install mytool@^1 # from the registry (or --registry NAME)
$ cx install --lib --root /usr/local # also the library, its headers and CMake config
$ cx uninstall mytool
- The prefix: --root <DIR>, else CX_INSTALL_ROOT, else ~/.local (LOCALAPPDATA%\cx\install on Windows). Binaries go to <root>/bin; cx notes when that isn't in PATH.
- The build: the release profile, unless --profile or --debug say otherwise. Packages from git or a registry are built in a copy under the cache, with --locked when they ship a cx.lock. In a workspace, pick the member with -p.
- Tracking: every installed file is recorded in <root>/.cx-installed.toml. cx uninstall removes exactly those files (and directories left empty). Installing a package again replaces its files and removes the ones the new version doesn't have.
- Shared libraries: a package whose library is shared installs it with its binaries, which find it in <root>/lib.
Using a cx library from plain CMake
$ cx install --lib --root "$HOME/prefix"
# a plain CMake project
find_package(mylib CONFIG REQUIRED) # with CMAKE_PREFIX_PATH=$HOME/prefix
target_link_libraries(app PRIVATE mylib::mylib)
--lib installs:
| Path | Contents |
| lib/libmylib.a (or .so, .dylib, .lib/.dll) | the library |
| include/mylib/... | its public headers, and mylib/export.hpp |
| lib/cmake/mylib/mylibConfig.cmake, mylibConfigVersion.cmake, mylib-targets*.cmake | the CMake package: target mylib::mylib, same-major-version compatibility |
- cx dependencies are bundled: their libraries and headers are installed too, because nothing else would find them.
- System dependencies become find_dependency() calls in the config file.
- Plain CMake dependencies can't be bundled; cx install --lib fails and names them.
- The same names as inside cx: the target is <name>::<name>, and the feature macros and <ID>_EXPORT work as in a cx build.