This file provides guidance to AI coding agents when working with code in this repository.
This repository aggregates third-party C++ dependencies for the ECMWF C++ stack. Each dependency is a git submodule with a corresponding build script. The repo does not contain application code — it only vendors and builds external libraries.
Current dependencies: CLI11 (2.6.1), libfmt (12.1.0), libaec (1.1.6), nlohmann/json (3.12.0), pybind11 (3.0.4), qhull (2020.2), SQLite3 (3.53.0), PROJ (9.8.1), libpq (18.3), libpqxx (7.10.5).
After cloning, initialize submodules:
git submodule update --init --recursive# Build all dependencies into ./deps (default)
./build.sh
# Build to a custom prefix
./build.sh --install-path ~/stack-deps
# Control build artifact location
./build.sh --install-path ~/stack-deps --build-path /tmp/buildThe top-level CMakeLists.txt is designed for two modes:
- Standalone (
cmake -S . -B build): installs tobuild/deps-installby default - Sub-project: used via
ecbuild_bundle()in downstream projects withRECURSIVEto pull submodules. Appends the install path toCMAKE_PREFIX_PATHin the parent scope. The CMakeLists.txt early-returns unlessENABLE_BUNDLED_DEPENDENCIESisONor the project is top-level.ecbuild_bundle()sets this automatically; plainadd_subdirectory()callers must set it manually.
A sentinel file stack_deps_built in the install prefix prevents redundant rebuilds.
build.sh # Entry point: uses BUILD_ORDER to iterate scripts, calls build() in each
build-scripts/
cli11.sh # Per-dependency build script (defines a build() function)
fmt.sh
libaec.sh
nlohmann_json.sh
pybind11.sh
qhull.sh
sqlite3.sh
proj.sh
libpq.sh
libpqxx.sh
CMakeLists.txt # CMake wrapper that invokes build.sh at configure time
CLI11/ # Git submodule
fmt/ # Git submodule
json/ # Git submodule (nlohmann/json)
libaec/ # Git submodule
PROJ/ # Git submodule
pybind11/ # Git submodule
qhull/ # Git submodule
sqlite/ # Git submodule (SQLite3)
postgres/ # Git submodule (libpq)
libpqxx/ # Git submodule
Each file in build-scripts/ must define a build() shell function. The function receives these environment variables:
SOURCE_ROOT— repo root (use to locate submodule sources)INSTALL_PREFIX— where to install (-DCMAKE_INSTALL_PREFIX)BUILD_PATH— where to place build artifacts (create a subfolder per dependency)
Scripts are sourced in a subshell for isolation — variables and failures don't leak between scripts. Build order is controlled by the BUILD_ORDER array in build.sh — dependencies must appear before their dependents (e.g. sqlite3 before proj). Use CMAKE_PREFIX_PATH=$INSTALL_PREFIX to find previously built deps.
- Add the library as a git submodule at the repo root
- Create
build-scripts/<name>.shwith abuild()function following existing scripts as templates - Add
<name>to theBUILD_ORDERarray inbuild.sh(position it after any deps it requires) - Register the dependency in
CMakeLists.txtviaadd_dependency_option(NAME <NAME> SCRIPT <name> DESCRIPTION "..." OUTPUT _stack_dep_map DEFAULT ${_stack_dep_default}). If it has transitive deps, addDEPENDENCIES <DEP1> <DEP2>and a correspondingDEP_REQUIRES_<name>="dep1 dep2"inbuild.sh - Update the dependency table in
README.md
All build scripts use -DCMAKE_BUILD_TYPE=RelWithDebInfo by convention.
- Skipped rebuilds: The CMake path writes a
stack_deps_builtsentinel file. To force a rebuild, delete<install-prefix>/stack_deps_built. - Build order: Controlled by the
BUILD_ORDERarray inbuild.sh, not alphabetical. Every script must be listed in this array. New scripts that are missing fromBUILD_ORDERwill cause a runtime error. - Transitive dependencies: If a dependency requires other deps, declare them via
DEPENDENCIESinCMakeLists.txtandDEP_REQUIRES_<name>inbuild.sh. Both CMake andbuild.sh --with-depsauto-enable transitive deps.