Is there a cmake module FindpreCICE.cmake?

Let’s say a group builds their in-house code with cmake and they link all their external dependencies via cmake modules, a natural question would be: is there also such a thing for preCICE?

Being a CMake project, preCICE generates a preciceCongfig.cmake file instead of providing a Findprecice.cmake module.

This file is available

  • after configuration in the directory CMAKE_BINARY_DIR,
  • after installation in the CMAKE_INSTALL_PREFIX/lib/cmake/precice and
  • after installing the Debian package in /usr/lib/cmake/precice.

To use preCICE from another CMake project, you simply have to:

  1. find the package

    find_package(precice REQUIRED CONFIG)
  2. link to the library to your target

    target_link_libraries(yourTarget PRIVATE precice::precice)
  3. for locations not searched by CMake: tell CMake where to find the config when configuring the dependant

    cmake -DpreciceDIR=dir/of/precice/config ..

This allows you to easily handle multiple installations in parallel such as:

  1. Debian package (works without passing the -Dprecice_DIR=dir option
  2. Custom release build
  3. Custom debug build

This is especially useful when benchmarking cases or debugging adapters.