The recommended CMake configuration for MPI-enabled GROMACS does not
provide MPI compiler wrappers for regular compiler variables. However,
the MPI toolchain details do not get conveyed transitively through the
libgromacs target. This should be easily resolved by checking whether
libgromacs is built with MPI library support and, if so, using the
CMake FindMPI module.
This may not be robust and should be revisited in the context of issue
#3672.
Meanwhile, this change should reduce errors for users following the
documentation updated under #3671.
# GROMACS is built against an MPI library.
# Clarification should be possible with resolution of #3672.
set(_gmx_mpi_type "library")
+ # Ref https://cmake.org/cmake/help/v3.13/module/FindMPI.html#variables-for-using-mpi
+ find_package(MPI COMPONENTS CXX)
+ if (MPI_CXX_FOUND)
+ target_link_libraries(gmxapi PUBLIC MPI::MPI_CXX)
+ else()
+ message(FATAL_ERROR "Building gmxapi for MPI-enabled GROMACS, but no MPI toolchain found.")
+ endif ()
elseif(GMX_THREAD_MPI)
# GROMACS is built with its internal thread-MPI implementation.
set(_gmx_mpi_type "tmpi")