Build and install BornAgain from source

Build and install libheinz, libformfactor, and BornAgain in that order. Use the same installation prefix for the two support libraries so that CMake can find them when configuring BornAgain.

Each project uses CMake. Create an out-of-source build directory inside each source directory. For libheinz and libformfactor, run:

INSTALL_PREFIX=/path/to/install
mkdir build
cd build
cmake .. -GNinja \
  -DCMAKE_PREFIX_PATH="$INSTALL_PREFIX" \
  -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX"
ninja
ctest --output-on-failure
ninja install

Return to the BornAgain source directory, then configure and build BornAgain:

mkdir build
cd build
cmake .. -GNinja \
  -DPython3_EXECUTABLE=/path/to/venv/bin/python \
  -DCMAKE_PREFIX_PATH="$INSTALL_PREFIX" \
  -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX"
ninja
ctest --output-on-failure
ninja ba_wheel
ninja install

CMAKE_PREFIX_PATH can contain a semicolon-separated list when dependencies are installed under several prefixes. Use -DDEV=ON for a developer build that regenerates tracked generated files and enables all developer checks.

The wheel is written below build/py/wheel/. To install it with uv, run:

uv pip install --python /path/to/venv/bin/python \
  path/to/bornagain-wheel.whl

or use the environment’s Python interpreter:

/path/to/venv/bin/python -m pip install path/to/bornagain-wheel.whl

Installing the wheel is optional for development because the test suite uses the package directly from the build tree.