From a892c3ad5e209f735c68c6d180e2f31d9f08115e Mon Sep 17 00:00:00 2001
From: Oliver Sander <oliver.sander@tu-dresden.de>
Date: Tue, 12 Nov 2024 18:55:05 +0100
Subject: [PATCH] Make the dune-elasticity module an optional dependency

It is only used by `film-on-substrate.cc` which many people
do no use.
---
 CHANGELOG.md        | 4 ++++
 dune.module         | 4 ++--
 src/CMakeLists.txt  | 6 ++++--
 test/CMakeLists.txt | 7 ++++++-
 4 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 26940762c..a4a36d4ed 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # Master
 
+- The module `dune-elasticity` has been downgraded from a required
+  dependency to an optional dependency.  It is currently only needed
+  by the `film-on-substrate.cc` program.
+
 - `cosserat-rod.cc` (formerly `rod3d.cc`) now reads the reference configuration
   and the initial iterate from the Python file.
 
diff --git a/dune.module b/dune.module
index 923d968c9..4361fa879 100644
--- a/dune.module
+++ b/dune.module
@@ -7,5 +7,5 @@ Module: dune-gfe
 Version: svn
 Maintainer: oliver.sander@tu-dresden.de
 #depending on
-Depends: dune-grid(>=2.9) dune-uggrid dune-istl dune-localfunctions dune-functions (>=2.9) dune-solvers dune-fufem dune-elasticity (>=2.9) dune-gmsh4 dune-vtk
-Suggests: dune-foamgrid dune-parmg dune-curvedgrid
+Depends: dune-grid(>=2.9) dune-uggrid dune-istl dune-localfunctions dune-functions (>=2.9) dune-solvers dune-fufem dune-gmsh4 dune-vtk
+Suggests: dune-foamgrid dune-parmg dune-curvedgrid dune-elasticity
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2ea90e75e..658ef54c6 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,6 +1,5 @@
 set(programs compute-disc-error
              cosserat-rod
-             film-on-substrate-stress-plot
              gradient-flow
              harmonicmaps
              simofoxshell)
@@ -10,10 +9,13 @@ foreach(_program ${programs})
   add_executable(${_program} ${_program}.cc)
 endforeach()
 
-if (dune-parmg_FOUND AND dune-curvedgeometry_FOUND)
+if (dune-parmg_FOUND AND dune-curvedgeometry_FOUND AND dune-elasticity_FOUND)
   add_executable("film-on-substrate" film-on-substrate.cc)
   set_property(TARGET "film-on-substrate" APPEND PROPERTY COMPILE_DEFINITIONS "WORLD_DIM=3;  LFE_ORDER=2; GFE_ORDER=2")
 	set(programs film-on-substrate ${programs})
+
+  add_executable("film-on-substrate-stress-plot" film-on-substrate-stress-plot.cc)
+  set(programs film-on-substrate-stress-plot ${programs})
 endif()
 
 add_executable("cosserat-continuum-2d-in-2d" cosserat-continuum.cc)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 3df7670d7..b6a959918 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -19,18 +19,19 @@ set(TESTS
   planarcosseratshelltest
   polardecompositiontest
   rotationtest
-  surfacecosseratstressassemblertest
   svdtest
   targetspacetest
 )
 
 dune_add_test(NAME "filmonsubstratetest"
               SOURCES filmonsubstratetest.cc
+              CMAKE_GUARD dune-elasticity_FOUND
               COMPILE_DEFINITIONS "MIXED_SPACE=0"
               TIMEOUT 2400)
 
 dune_add_test(NAME "filmonsubstratetest-mixed"
               SOURCES filmonsubstratetest.cc
+              CMAKE_GUARD dune-elasticity_FOUND
               COMPILE_DEFINITIONS "MIXED_SPACE=1"
               TIMEOUT 2400)
 
@@ -74,6 +75,10 @@ dune_add_test(SOURCES mixedriemannianpnsolvertest.cc
               TIMEOUT 600
               CMAKE_GUARD MPI_FOUND)
 
+# TODO: The dependency on dune-elasticity is very minor, and can be removed.
+dune_add_test(SOURCES surfacecosseratstressassemblertest.cc
+              CMAKE_GUARD dune-elasticity_FOUND)
+
 # Copy the example grid used for testing into the build dir
 file(COPY grids/irregular-square.msh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/grids)
 
-- 
GitLab