1
0
mirror of synced 2024-12-23 05:00:01 +01:00
Henry Fredrick Schreiner 6fda3e2328 Better internal structure
2018-03-30 08:53:16 +02:00

38 lines
1.0 KiB
Markdown

# MPI
To add MPI, like OpenMP, you'll be best off with CMake 3.9+.
```cmake
find_package(MPI REQUIRED)
message(STATUS "Run: ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} EXECUTABLE ${MPIEXEC_POSTFLAGS} ARGS")
target_link_libraries(MyTarget PUBLIC MPI::MPI_CXX)
```
However, you can imitate this on CMake 3.1+ with:
```cmake
find_package(MPI REQUIRED)
# For supporting CMake < 3.9:
if(NOT TARGET MPI::MPI_CXX)
add_library(MPI::MPI_CXX IMPORTED INTERFACE)
set_property(TARGET MPI::MPI_CXX
PROPERTY INTERFACE_COMPILE_OPTIONS ${MPI_CXX_COMPILE_FLAGS})
set_property(TARGET MPI::MPI_CXX
PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${MPI_CXX_INCLUDE_PATH}")
set_property(TARGET MPI::MPI_CXX
PROPERTY INTERFACE_LINK_LIBRARIES ${MPI_CXX_LINK_FLAGS} ${MPI_CXX_LIBRARIES})
endif()
message(STATUS "Run: ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} EXECUTABLE ${MPIEXEC_POSTFLAGS} ARGS")
target_link_libraries(MyTarget PUBLIC MPI::MPI_CXX)
```