Build and install BornAgain

The following instructions must be executed for the software projects

  • libheinz,
  • libformfactor,
  • BornAgain,

in the given order.

Each source package comes with configuration files for the cross-platform build system CMake. Using CMake, it takes the following commands to build and install the software:

$ cd <source_dir>
$ mkdir build
$ cd build
$ cmake [<options>] ..
$ make -j4
$ ctest -j4
$ sudo make install

These steps shall now be explained in more detail.

Dedicated build directory

$ mkdir build
$ cd build

The build process must take place in a dedicated directory, for which we suggest the canonical name build, and which should be a subdirectory of the software’s source directory.

CMake command for the build configuration

$ cmake -DCMAKE_INSTALL_PREFIX=<install_dir> ..

This command checks your system for the presence of the third party libraries necessary for compilation. In the case of a complex system setup, with libraries of different versions scattered across multiple places (/opt/local, /usr/local, etc), you may want to help CMake in finding the correct library paths by running it with additional parameters:

$ cmake -DCMAKE_PREFIX_PATH=/opt/local -DCMAKE_INSTALL_PREFIX=<install_dir> ..

The compilation

$ make -j4

This command starts the compilation process with a maximum of 4 parallel threads. Depending on your CPU, you can increase this parameter (-j[N]) to decrease the compilation time.

Testing the build

$ ctest -j4
...
100% tests passed, 0 tests failed out of 61
Total Test time (real) = 31.14 sec
[100%] Build target check

Running the functional tests is an optional but recommended step. The command ctest will compile several additional tests and run them one by one. The option -j[N] uses up to N threads to run these tests in parallel. Every test contains the simulation of a typical sample and compares the result with a reference file. Having 100% tests passed ensures that your local installation is correct.

Installing the framework

$ sudo make install

The last command copies the compiled software into the installation directory <install_dir>, which has been specified earlier on during the CMake configuration.