Building from source - Configuration

preCICE uses CMake to configure and build the library. After this step, preCICE is ready to be built.

Using presets

preCICE offers a range of CMake configuration presets, which all use the build directory build. These presets adjust flags, build type, link-time optimizations, assertions, and more. You can combine presets with other CMake arguments such as -DCMAKE_INSTALL_PREFIX=....

To see all available presets use:

cd precice-3.4.1 # Enter the preCICE source directory
cmake --list-presets

Then, to configure preCICE, run:

cd precice-3.4.1 # Enter the preCICE source directory
cmake --preset=production # Configure using the production preset

This will automatically create a build/ directory for you, if it does not already exist.

Build directory

CMake keeps track of the source and the build directory separately. This allows to cleanly create multiple build configurations for a single source directory.

Please create a build directory inside the preCICE source directory as follows:

cd precice-3.4.1 # Enter the preCICE source directory
mkdir build
cd build

Options

Now it is time to configure preCICE with the decisions taken in the preparation steps. First, make sure that you changed into the build/ directory.

If you need to configure a debug build with all default settings, run:

cmake ..

As you can see, you can pass variables to cmake using the syntax -DNAME=VALUE. The following table lists the most important options to pass to CMake.

Assemble your CMake command and run it to configure preCICE.

This example builds the release version of preCICE with the PETSc mapping and the user-defined python actions off, which will be installed in the prefix ~/software/precice.

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/software/precice -DPRECICE_FEATURE_PETSC_MAPPING=OFF -DPRECICE_FEATURE_PYTHON_ACTIONS=OFF ..
OptionTypeDefaultDescription
BUILD_SHARED_LIBSBooleanONBuild as a shared library.
CMAKE_BUILD_TYPEStringDebugChoose Debug, Release, or RelWithDebInfo.
CMAKE_INSTALL_PREFIXPath/usr/localThe prefix used in the installation step.
PRECICE_FEATURE_MPI_COMMUNICATIONBooleanONBuild with MPI.
MPI_CXX_COMPILERPathMPI compiler wrapper to use for detection.
PRECICE_FEATURE_PETSC_MAPPINGBooleanONBuild with PETSc (for MPI-parallel RBF mapping), requires PRECICE_FEATURE_MPI_COMMUNICATION=ON.
PRECICE_FEATURE_PYTHON_ACTIONSBooleanONBuild support for python actions.
PYTHON_EXECUTABLEPathPath to the python interpreter to use.
BUILD_TESTINGBooleanONBuild and register the tests.
PRECICE_RELEASE_WITH_ASSERTIONSBooleanOFFEnables assertions in release builds.
PRECICE_RELEASE_WITH_DEBUG_LOGBooleanOFFEnables debug logging in release builds.
PRECICE_RELEASE_WITH_TRACE_LOGBooleanOFFEnables trace logging in release builds.
PRECICE_InstallTestBooleanOFFInstall testprecice and test configuration files.
PRECICE_CONFIGURE_PACKAGE_GENERATIONBooleanONEnable package configuration.
PRECICE_BINDINGS_CBooleanONEnable the native C bindings.
PRECICE_BINDINGS_FORTRANBooleanONEnable the native Fortran bindings.
PRECICE_ALWAYS_VALIDATE_LIBSBooleanOFFForce CMake to always validate required libraries.
PRECICE_TEST_TIMEOUT_LONGInteger180Timeout for big test suites
PRECICE_TEST_TIMEOUT_SHORTInteger20Timeout for small test suites
PRECICE_CTEST_MPI_FLAGSStringAdditional flags to pass to mpiexec when running the tests.
CMAKE_INTERPROCEDURAL_OPTIMIZATIONBooleanOFFEnable interprocedural/link-time optimization

The next step

preCICE is now configured and the build system has been generated. The next step covers how to build preCICE.