must promote imported target to global scope in order to be able to alias it

This commit is contained in:
Axel Kohlmeyer
2022-01-30 08:32:21 -05:00
parent dc0e013297
commit f8a4006da7

View File

@ -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)