cmake: try to fix MPI4WIN build

This commit is contained in:
Christoph Junghans 2020-03-31 15:06:40 -06:00
parent ef0df90b48
commit 05ecda3748
2 changed files with 7 additions and 6 deletions

View File

@ -186,6 +186,7 @@ if(BUILD_MPI)
# We use a non-standard procedure to compile with MPI on windows
if (CMAKE_SYSTEM_NAME STREQUAL Windows)
include(MPI4WIN)
target_link_libraries(lammps PUBLIC LAMMPS::MPI)
else()
find_package(MPI REQUIRED)
target_compile_definitions(lammps PRIVATE -DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX=1)
@ -515,9 +516,6 @@ include(Packages/GPU)
# and after everything else that is compiled locally
######################################################################
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
if(LAMMPS_USE_MPI4WIN)
target_link_libraries(lammps PRIVATE ${MPI4WIN_LIBRARIES})
endif()
target_link_libraries(lammps PRIVATE -lwsock32 -lpsapi)
endif()

View File

@ -16,8 +16,11 @@ else()
endif()
ExternalProject_get_property(mpi4win_build SOURCE_DIR)
target_compile_definitions(lammps PRIVATE -DMPICH_SKIP_MPICXX)
target_include_directories(lammps PRIVATE "${SOURCE_DIR}/include")
set(MPI4WIN_LIBRARIES "${SOURCE_DIR}/lib/libmpi.a")
file(MAKE_DIRECTORY "${SOURCE_DIR}/include")
add_library(LAMMPS::MPI UNKNOWN IMPORTED)
set_target_properties(LAMMPS::MPI PROPERTIES
IMPORTED_LOCATION "${SOURCE_DIR}/lib/libmpi.a"
INTERFACE_INCLUDE_DIRECTORIES "${SOURCE_DIR}/include"
INTERFACE_COMPILE_DEFINITIONS "-DMPICH_SKIP_MPICXX")
add_dependencies(lammps mpi4win_build)
set(LAMMPS_USE_MPI4WIN ON)