From d48b9ee96b90437e4f74bb1bfee76d45a815dfc9 Mon Sep 17 00:00:00 2001 From: Stephane Del Pino <stephane.delpino44@gmail.com> Date: Wed, 24 Jul 2019 17:50:13 +0200 Subject: [PATCH] Fix MPI configuration result when MPI is found but not ParMETIS Now if PUGS_ENABLE_MPI is set to `AUTO` (default value) and if MPI is detected but not ParMETIS, then just throw a warning stating that MPI will not be used to build binaries. If PUGS_ENABLE_MPI is set to `ON` (user requires MPI), then since MPI building cannot be made without ParMETIS, CMake throws a fatal error. --- CMakeLists.txt | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ed103c81..c7f2d4c04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,6 +112,26 @@ if (PUGS_ENABLE_MPI MATCHES "^(AUTO|ON)$") find_package(MPI) endif() + +#------------------------------------------------------ +# Search for ParMETIS + +if(${MPI_FOUND}) + find_package(ParMETIS) + if (NOT PARMETIS_LIBRARIES) + if(PUGS_ENABLE_MPI MATCHES "^AUTO$") + message(WARNING "MPI support deactivated: ParMETIS cannot be found!") + unset(MPI_FOUND) + unset(MPI_CXX_LINK_FLAGS) + unset(MPI_CXX_LIBRARIES) + else() + message(FATAL_ERROR "MPI support requires ParMETIS which cannot be found!") + endif() + endif() +endif() + +# ----------------------------------------------------- + if (${MPI_FOUND}) set(PUGS_CXX_FLAGS "${PUGS_CXX_FLAGS} ${MPI_CXX_COMPILER_FLAGS}") include_directories(SYSTEM ${MPI_CXX_INCLUDE_DIRS}) @@ -308,13 +328,6 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Coverage") endif() endif() -#------------------------------------------------------ -# Search for ParMETIS - -if(${MPI_FOUND}) - find_package(ParMETIS REQUIRED) -endif() - # ----------------------------------------------------- link_libraries("-rdynamic") -- GitLab