Skip to content

Compiling and Build Time Configuration

Peter Spackman edited this page Sep 2, 2023 · 1 revision

Configuration flags

Note that the library should respect most common changes when using CMake e.g. setting the CMAKE_C_FLAGS or CMAKE_CXX_FLAGS variables etc. There are a variety of build configuration flags available, but here I will go over only the major ones that should be utilised/changed:

  • USE_SYSTEM_EIGEN: if this is ON then cmake will find the Eigen3 library via system paths, otherwise it will be downloaded using CPM. If you already have a compatible version of Eigen3 installed, set this to ON.
  • USE_SYSTEM_LIBXC: if this is ON then cmake will find the LibXC library via system paths, otherwise it will be downloaded using CPM. If you already have a compatible version of LibXC installed, set this to ON.
  • USE_SYSTEM_BLAS: if this is ON then cmake will find the BLAS and LAPACK libraries via system paths and link them, also specifying to e.g. Eigen3 that it should use BLAS operations etc. Generally this will improve performance (particularly for DFT calculations) but it can cause issues with e.g. multithreading as OpenBLAS for example is not thread-safe. So be careful turning this on.
  • USE_QCINT: there is a SIMD optimized varient of libcint, and setting this to ON will use that instead of the (slightly slower) libcint. This performance change may be platform specific, but in general if speed is the goal you should try to set this ON.
  • WITH_PYTHON_BINDINGS: Some python bindings for occ have been written, but the documentation for building the library with CMake and making it usable with a python installation remains to be written. So in general, if you're not compiling it via a python build process, just ignore this flag and leave it OFF.

On a fresh system

Assuming you have a working C and C++ compiler and the ninja build program, a basic build can be achieved via:

# from the root directory of this repository, but you can of course put the build directory
# wherever you wish
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DUSE_SYSTEM_EIGEN=OFF -DUSE_SYSTEM_LIBXC=OFF -G Ninja
ninja 

Then you can run the tests via:

export OCC_BASIS_PATH=/path/to/occ/repository
ninja test

Note: some of the tests will fail if you don't set the OCC_BASIS_PATH variable correctly.

Cross compilation for windows from an ubuntu host

Current workarounds/issues

Windows.h

scnlib expects <Windows.h> but only <windows.h> exists, just need to copy/link it so it can locate it.

Threads

The posix thread model is required - probably due to library expectations. This can be achieved by updating alternatives and selecting the posix thread model, or modifying the toolchain file.

sudo update-alternatives --config x86_64-w64-mingw32-g++
sudo update-alternatives --config x86_64-w64-mingw32-gcc

Aligned allocation

gau2grid uses aligned_alloc as it detects GNUC. Need to set CMAKE_C_FLAGS (and maybe CMAKE_CXX_FLAGS) to include -D__GG_NO_PRAGMA.

Clone this wiki locally