Help clients find dependencies of imported CMake targets.
authorM. Eric Irrgang <ericirrgang@gmail.com>
Thu, 29 Oct 2020 20:48:06 +0000 (21:48 +0100)
committerM. Eric Irrgang <ericirrgang@gmail.com>
Mon, 9 Nov 2020 08:29:19 +0000 (11:29 +0300)
Refs #3776

api/gmxapi/CMakeLists.txt
api/gmxapi/cpp/cmake/gmxapi-config.cmake.in

index 12b2fd4226304f7e2f841b7294aa3edb544dc618..6887ac4875cc2a473310436eb1cf7f13b2e8133c 100644 (file)
@@ -70,6 +70,8 @@ if (GMX_LIB_MPI)
     find_package(MPI COMPONENTS C)
     if (MPI_C_FOUND)
         target_link_libraries(gmxapi PRIVATE MPI::MPI_C)
+        # If clients also need to link this target, we need to provide help in gmxapi-config.cmake
+        set(_gmxapi_find_dependencies "find_dependency(MPI COMPONENTS C)")
     else()
         message(FATAL_ERROR "Building gmxapi for MPI-enabled GROMACS, but no MPI toolchain found.")
     endif ()
index fcb7de77e103d4ca06183f2ba758d71aae34fd70..829e802bc639e4b689a6af3ae30aa6b4b34a4ac1 100644 (file)
@@ -2,6 +2,8 @@ set(gmxapi_VERSION @GMXAPI_RELEASE@)
 @PACKAGE_INIT@
 # Refer to CMake docs for information on more elaborate use of this stub file:
 # https://cmake.org/cmake/help/v3.4/module/CMakePackageConfigHelpers.html#command:configure_package_config_file
+include(CMakeFindDependencyMacro)
+@_gmxapi_find_dependencies@
 include("${CMAKE_CURRENT_LIST_DIR}/gmxapi.cmake")
 check_required_components(gmxapi)
 set_property(TARGET Gromacs::gmxapi PROPERTY MPI "@_mpi@")