From f8a4006da7c14eeb0517aa52b2fd7dfd0b550c60 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 30 Jan 2022 08:32:21 -0500 Subject: [PATCH] must promote imported target to global scope in order to be able to alias it --- cmake/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 1778c7b7f2..e2f7d8c90c 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -276,6 +276,8 @@ else() option(BUILD_MPI "Build MPI version" OFF) endif() +# configure MPI related settings and define an MPI::ANY_CXX alias target +# which will point to either the imported MPI library or the STUBS lib if(BUILD_MPI) # do not include the (obsolete) MPI C++ bindings which makes # for leaner object files and avoids namespace conflicts @@ -290,6 +292,9 @@ if(BUILD_MPI) target_compile_definitions(lammps PRIVATE -DLAMMPS_LONGLONG_TO_LONG) endif() endif() + if(CMAKE_VERSION VERSION_GREATER 3.11) + set_property(TARGET MPI::MPI_CXX PROPERTY IMPORTED_GOBAL TRUE) + endif() add_library(MPI::ANY_CXX ALIAS MPI::MPI_CXX) else() target_sources(lammps PRIVATE ${LAMMPS_SOURCE_DIR}/STUBS/mpi.cpp)