Third-party packages

The libraries, tools and test data the build downloads are pinned in cpmfile.json and added with CPMUtil, crueter's wrapper of CPM.cmake as Eden carries it, from packages.cmake. An entry gives the package's version, where it comes from (repo and an artifact for a release's asset, repo alone for the archive of a tag or commit, or a url) and the SHA-512 of that file in hash; CPMUtil's documentation gives the other fields. The file is in CPMUtil's form, which jq --indent 4 -S . cpmfile.json or python3 -m json.tool --indent 4 --sort-keys cpmfile.json writes.

The tests' reference values are the package test-references (scarletnx/test-references, fetched only with the tests); -DCPM_test-references_SOURCE=<a clone> reads a local copy instead, where the recording scripts write.

To update a package:

  1. Change its version, and its artifact or url where they name it (%VERSION% in an artifact, or numeric_version, as lz4's entry has it, spare that).
  2. Download the file, check it against the digest its release publishes (GitHub shows each asset's SHA-256), and put its SHA-512 in hash: cmake -E sha512sum <file>. Never the hash of what a configure happened to fetch.
  3. Configure: the new version downloads into CPM_SOURCE_CACHE/<package>/<version> (with the patches' key after it where it has patches).

To add one:

  1. Pin it in cpmfile.json as above, under a lowercase key, as Eden's are; package gives the CMake name where that differs ("openssl": {"package": "OpenSSL", ...}), and <package>_SOURCE_DIR is where it lands.
  2. Add it in dependencies.cmake, under the conditions that need it: AddJsonPackage(NAME <key> DOWNLOAD_ONLY FORCE_BUNDLED_PACKAGE ON) when the build compiles its sources into a target of its own, patches it or reads it as data, so no system package can stand in for it. One the system may give instead, which installs a CMake package find_package finds, gets a min_version and AddJsonPackage(<key>), with "bundled": true when the pinned one stays the default (and snx_cpm_options(<key>) before it, for CPM_USE_LOCAL_PACKAGES). A package that is one file (a header, a font, a test vector), which CPMUtil would try to extract, is added with snx_package_file(<key>).
  3. Its license: in the install (CMakeLists.txt, under licenses) when it ships, and in CREDITS.

A patch goes in .patch/<key>/NNNN-<what>.patch, named in the entry's patches in the order they apply. CPMUtil applies them with patch -p1 and no fuzz to the release it extracts, does it again on a fresh copy when one changes, and stops the configure on one that does not apply. To make one, edit a copy of the pristine file and rebuild the hunks with diff -u --label a/<file> --label b/<file>. runtime_architecture refuses a download outside CPMUtil (CPM.cmake's calls, FetchContent, file(DOWNLOAD)), a name cpmfile.json does not pin, a pin nothing adds, a package without a min_version added without FORCE_BUNDLED_PACKAGE ON, a patch named and missing or there and not named, and a cpmfile.json out of that form.


Made from docs/dev/build.md at 69237645142c. GPL-3.0-or-later.