Build BornAgain from source

Prepare the dependencies and source checkout, then follow the build commands for your platform. This is the starting point for development and debugging.

Developer options

For development, add -DZERO_TOLERANCE=ON -DDEVELOPER_CHECKS=ON to the CMake command for your platform. DEVELOPER_CHECKS takes effect only on Linux and macOS.

To enable these options in an existing build, run from its build directory:

cmake .. -DZERO_TOLERANCE=ON -DDEVELOPER_CHECKS=ON

CMake retains the Python, dependency, and generator settings from that build. Add -DCMAKE_CXX_COMPILER_LAUNCHER=ccache when ccache is installed.

Enable the generators needed for your work:

  • Add -DCONFIGURE_BINDINGS=ON when working on the C++ API. This requires SWIG and regenerates auto/Wrap/.
  • Add -DCONFIGURE_EXAMPLES=ON when working on rawEx/. This requires Ruby with ERB and regenerates the examples below auto/.
  • Add -DCONFIGURE_DOXY=ON to build the Doxygen API reference.

Use -DDEV=ON when all generators and developer checks are needed together. It requires the dependencies listed under Developer build.

Run tests

After building, run the test suite from the build directory:

ctest -j8 --output-on-failure

-jN runs up to N tests in parallel. To rerun only failed tests or select tests by name, use:

ctest --rerun-failed --output-on-failure
ctest -R 'TestNamePattern' --output-on-failure

List matching tests without running them with ctest -N -R 'TestNamePattern'.

On Linux and macOS, DEVELOPER_CHECKS=ON adds CTest checks for source format, code structure, documentation, and generated examples. Use ctest -N to list them. The checks do not rewrite files.

If cpp.format fails on files you did not change, compare your clang-format version with the one used by CI.

Doxygen API reference

Configure with -DCONFIGURE_DOXY=ON, then build the doxy target:

ninja doxy

Open html/index.html from the build directory.

Continue with Contribute changes to submit code changes, or Debug and analyze for debug builds and analysis tools.