From 71c4a0fcaf0ed08e5e7164071b60261fae36e483 Mon Sep 17 00:00:00 2001 From: "M. Eric Irrgang" Date: Mon, 26 Oct 2020 15:07:21 +0100 Subject: [PATCH] Tell gmxapi to look for MPI, when appropriate. 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. --- api/gmxapi/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/api/gmxapi/CMakeLists.txt b/api/gmxapi/CMakeLists.txt index 81823a89c1..e287816034 100644 --- a/api/gmxapi/CMakeLists.txt +++ b/api/gmxapi/CMakeLists.txt @@ -66,6 +66,13 @@ if (GMX_LIB_MPI) # 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") -- 2.22.0