From 9963d6a0c89985226809656322522d036229300c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Del=20Pino?= <stephane.delpino44@gmail.com>
Date: Fri, 30 Oct 2020 15:25:54 +0100
Subject: [PATCH] Fix petsc configuration when pugs is built without mpi
 support

By now the choice is made that mpi is required when PETSc. This may
change in the future: it is not that important but would probably
require the use of #ifdef directives...
---
 CMakeLists.txt | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6878c9a0d..f3f5c8478 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -156,8 +156,14 @@ set(PUGS_ENABLE_PETSC AUTO CACHE STRING
   "Choose one of: AUTO ON OFF")
 
 if (PUGS_ENABLE_PETSC MATCHES "^(AUTO|ON)$")
-  pkg_check_modules(PETSC PETSc)
-
+  if (MPI_FOUND)
+    # PETSc support is deactivated if MPI is not found
+    pkg_check_modules(PETSC PETSc)
+  else()
+    message(STATUS "PETSc support is deactivated since pugs will not be build with MPI support")
+    set(PETSC_FOUND FALSE)
+    unset(PUGS_HAS_PETSC)
+  endif()
   set(PUGS_HAS_PETSC ${PETSC_FOUND})
 else()
   unset(PUGS_HAS_PETSC)
-- 
GitLab