cmake: fix MPI linkage

This commit is contained in:
Christoph Junghans 2020-03-31 08:23:59 -06:00
parent 3806222e04
commit 119ba61c09
3 changed files with 5 additions and 4 deletions

View File

@ -190,6 +190,7 @@ if(BUILD_MPI)
find_package(MPI REQUIRED) find_package(MPI REQUIRED)
target_compile_definitions(lammps PRIVATE -DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX=1) target_compile_definitions(lammps PRIVATE -DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX=1)
target_link_libraries(lammps PUBLIC MPI::MPI_CXX) target_link_libraries(lammps PUBLIC MPI::MPI_CXX)
add_library(LAMMPS::MPI ALIAS MPI::MPI_CXX)
option(LAMMPS_LONGLONG_TO_LONG "Workaround if your system or MPI version does not recognize 'long long' data types" OFF) option(LAMMPS_LONGLONG_TO_LONG "Workaround if your system or MPI version does not recognize 'long long' data types" OFF)
if(LAMMPS_LONGLONG_TO_LONG) if(LAMMPS_LONGLONG_TO_LONG)
target_compile_definitions(lammps PRIVATE -DLAMMPS_LONGLONG_TO_LONG) target_compile_definitions(lammps PRIVATE -DLAMMPS_LONGLONG_TO_LONG)
@ -211,7 +212,7 @@ else()
else() else()
target_link_libraries(lammps PUBLIC mpi_stubs) target_link_libraries(lammps PUBLIC mpi_stubs)
endif() endif()
add_library(MPI::MPI_CXX ALIAS mpi_stubs) add_library(LAMMPS::MPI ALIAS mpi_stubs)
endif() endif()
set(LAMMPS_SIZES "smallbig" CACHE STRING "LAMMPS integer sizes (smallsmall: all 32-bit, smallbig: 64-bit #atoms #timesteps, bigbig: also 64-bit imageint, 64-bit atom ids)") set(LAMMPS_SIZES "smallbig" CACHE STRING "LAMMPS integer sizes (smallsmall: all 32-bit, smallbig: 64-bit #atoms #timesteps, bigbig: also 64-bit imageint, 64-bit atom ids)")
@ -488,7 +489,7 @@ if(PKG_USER-ATC)
if(LAMMPS_SIZES STREQUAL BIGBIG) if(LAMMPS_SIZES STREQUAL BIGBIG)
message(FATAL_ERROR "The USER-ATC Package is not compatible with -DLAMMPS_BIGBIG") message(FATAL_ERROR "The USER-ATC Package is not compatible with -DLAMMPS_BIGBIG")
endif() endif()
target_link_libraries(atc PRIVATE ${LAPACK_LIBRARIES} MPI::MPI_CXX) target_link_libraries(atc PRIVATE ${LAPACK_LIBRARIES} LAMMPS::MPI)
target_include_directories(atc PRIVATE ${LAMMPS_SOURCE_DIR}) target_include_directories(atc PRIVATE ${LAMMPS_SOURCE_DIR})
target_compile_definitions(atc PRIVATE -DLAMMPS_${LAMMPS_SIZES}) target_compile_definitions(atc PRIVATE -DLAMMPS_${LAMMPS_SIZES})
endif() endif()

View File

@ -192,7 +192,7 @@ if(PKG_GPU)
get_property(GPU_SOURCES GLOBAL PROPERTY GPU_SOURCES) get_property(GPU_SOURCES GLOBAL PROPERTY GPU_SOURCES)
target_link_libraries(gpu PRIVATE MPI::MPI_CXX) target_link_libraries(gpu PRIVATE LAMMPS::MPI)
if(BUILD_LIB AND NOT BUILD_SHARED_LIBS) if(BUILD_LIB AND NOT BUILD_SHARED_LIBS)
install(TARGETS gpu EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(TARGETS gpu EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif() endif()

View File

@ -15,7 +15,7 @@ if(PKG_MESSAGE)
if(BUILD_MPI) if(BUILD_MPI)
target_compile_definitions(cslib PRIVATE -DMPI_YES) target_compile_definitions(cslib PRIVATE -DMPI_YES)
set_target_properties(cslib PROPERTIES OUTPUT_NAME "csmpi") set_target_properties(cslib PROPERTIES OUTPUT_NAME "csmpi")
target_link_libraries(cslib PRIVATE MPI::MPI_CXX) target_link_libraries(cslib PRIVATE LAMMPS::MPI)
else() else()
target_compile_definitions(cslib PRIVATE -DMPI_NO) target_compile_definitions(cslib PRIVATE -DMPI_NO)
target_include_directories(cslib PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/src/STUBS_MPI) target_include_directories(cslib PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/src/STUBS_MPI)