From 14371eb3c14fa65f73994590994f08cc6adafd59 Mon Sep 17 00:00:00 2001
From: Markus Blatt <markus@dr-blatt.de>
Date: Mon, 24 Aug 2015 15:28:21 +0200
Subject: [PATCH] [release] Always indicate whether we support parallelism.

Since commit 495f2fce441a USE_MPI was removed from dunecontrol and
the default configuration now defaults to use
parallelism. Unfortunately, there are downstream modules that try to
support multiple versions of DUNE. Sometimes these need to decide
whether to support parallelism before they know which version of DUNE
they are using. This is was not possible when providing
--enable-parallel as no variable gets set for DUNE>=2.4.

With this commit dunecontrol always sets
CMAKE_DISABLE_FIND_PACKAGE_MPI to an appropriate value. Thus if
dunecontrol is used then one can check in one's own module whether the
variable is set explicitly to false and conclude that one is using
>=2.4 and wants parallelism. Otherwise one can check USE_MPI to detect
which behaviour is needed for 2.3.

E.g. like this:
<code>
option (USE_MPI "Use Message Passing Interface for parallel computing" OFF)

if( NOT CMAKE_DISABLE_FIND_PACKAGE_MPI STREQUAL ""
    AND NOT CMAKE_DISABLE_FIND_PACKAGE_MPI)
  set(USE_MPI ON)
endif()

if (NOT USE_MPI)
      set (CMAKE_DISABLE_FIND_PACKAGE_MPI TRUE)
 set (CMAKE_DISABLE_FIND_PACKAGE_MPI TRUE)
endif (NOT USE_MPI)
</code>

Of course without dunecontrol and using the defaults one will still
configure DUNE as parallel, but one's own module as sequential.
---
 lib/dunecommonam2cmake.lib | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/dunecommonam2cmake.lib b/lib/dunecommonam2cmake.lib
index 60549abd9..b88c4ff79 100644
--- a/lib/dunecommonam2cmake.lib
+++ b/lib/dunecommonam2cmake.lib
@@ -25,6 +25,8 @@ dune_common_options_am2cmake()
     echo $PARAMS | grep \\-\\-disable-parallel > /dev/null
     if test "$?" -eq 0 ; then
         CMAKE_PARAMS="$CMAKE_PARAMS -DCMAKE_DISABLE_FIND_PACKAGE_MPI=TRUE"
+    else
+        CMAKE_PARAMS="$CMAKE_PARAMS -DCMAKE_DISABLE_FIND_PACKAGE_MPI=FALSE"
     fi
 
     # Check for --disable-cxx11check
-- 
GitLab