From c350bd12163c7a3886a573b0d9e777395efe22e9 Mon Sep 17 00:00:00 2001
From: Denis Davydov <davydden@gmail.com>
Date: Thu, 19 Jan 2017 20:24:09 +0100
Subject: [PATCH] dealii: fix config without mpi (#2856)

* dealii: fix config without mpi

* dealii: add check of variants
---
 var/spack/repos/builtin/packages/dealii/package.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/var/spack/repos/builtin/packages/dealii/package.py b/var/spack/repos/builtin/packages/dealii/package.py
index 66267b2d9a..ca26edfb40 100644
--- a/var/spack/repos/builtin/packages/dealii/package.py
+++ b/var/spack/repos/builtin/packages/dealii/package.py
@@ -115,11 +115,19 @@ class Dealii(CMakePackage):
     depends_on("slepc@:3.6.3",     when='@:8.4.1+slepc+petsc+mpi~int64')
     depends_on("trilinos",         when='+trilinos+mpi')
 
+    # check that the combination of variants makes sense
+    def variants_check(self):
+        for p in ['+arpack', '+hdf5', '+netcdf', '+p4est', '+petsc',
+                  '+slepc', '+trilinos']:
+            if p in self.spec and '+mpi' not in self.spec:
+                raise RuntimeError('The ' + p + ' variant requires +mpi')
+
     def build_type(self):
         # CMAKE_BUILD_TYPE should be DebugRelease | Debug | Release
         return 'DebugRelease'
 
     def cmake_args(self):
+        self.variants_check()
         spec = self.spec
         options = []
 
@@ -192,7 +200,7 @@ def cmake_args(self):
         ])
 
         # arpack
-        if '+arpack' in spec:
+        if '+arpack' in spec and '+mpi' in spec:
             options.extend([
                 '-DARPACK_DIR=%s' % spec['arpack-ng'].prefix,
                 '-DDEAL_II_WITH_ARPACK=ON',
@@ -204,7 +212,7 @@ def cmake_args(self):
             ])
 
         # since Netcdf is spread among two, need to do it by hand:
-        if '+netcdf' in spec:
+        if '+netcdf' in spec and '+mpi' in spec:
             # take care of lib64 vs lib installed lib locations:
             if os.path.isdir(spec['netcdf-cxx'].prefix.lib):
                 netcdfcxx_lib_dir = spec['netcdf-cxx'].prefix.lib
-- 
GitLab