Skip to content

Commit 36bc66e

Browse files
committed
Add a way to manually disable MPI support.
1 parent 45e6219 commit 36bc66e

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

CMakeLists.txt

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,33 @@ endif ()
211211
########################################################################################################################
212212
## check for MPI (optional) ##
213213
########################################################################################################################
214-
# TODO: maybe be able to explicitly disable MPI support?
215-
find_package(MPI)
216-
if (MPI_FOUND)
217-
message(STATUS "Found MPI ${MPI_CXX_VERSION} for distributed memory support.")
218-
set(PLSSVM_FOUND_MPI ON)
219-
target_link_libraries(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC MPI::MPI_CXX)
220-
target_compile_definitions(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC PLSSVM_HAS_MPI_ENABLED)
214+
## check for MPI
215+
set(PLSSVM_ENABLE_MPI AUTO CACHE STRING "Enable distributed memory support via MPI")
216+
set_property(CACHE PLSSVM_ENABLE_MPI PROPERTY STRINGS AUTO ON OFF)
217+
if (PLSSVM_ENABLE_MPI MATCHES "AUTO" OR PLSSVM_ENABLE_MPI)
218+
list(APPEND CMAKE_MESSAGE_INDENT "MPI: ")
219+
message(CHECK_START "Checking for MPI")
220+
221+
# try finding MPI
222+
find_package(MPI)
223+
224+
if (MPI_FOUND)
225+
# MPI found
226+
message(CHECK_PASS "found ")
227+
228+
message(STATUS "Found MPI ${MPI_CXX_VERSION} for distributed memory support.")
229+
set(PLSSVM_FOUND_MPI ON)
230+
target_link_libraries(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC MPI::MPI_CXX)
231+
target_compile_definitions(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC PLSSVM_HAS_MPI_ENABLED)
232+
else ()
233+
# MPI not found
234+
message(CHECK_FAIL "not found")
235+
if (PLSSVM_ENABLE_MPI MATCHES "ON")
236+
message(SEND_ERROR "Cannot find requested MPI!")
237+
endif ()
238+
endif ()
239+
240+
list(POP_BACK CMAKE_MESSAGE_INDENT)
221241
endif ()
222242

223243
########################################################################################################################

0 commit comments

Comments
 (0)