From 71ab1dc106c28af237cd72db873332f2e0116a99 Mon Sep 17 00:00:00 2001
From: Dominic Kempf <dominic.kempf@iwr.uni-heidelberg.de>
Date: Thu, 21 Jan 2016 13:51:44 +0100
Subject: [PATCH] [CMake] Correct dependency handling + testtools integration

---
 cmake/modules/DunePerftoolMacros.cmake | 14 ++++++++++++++
 dune.module                            |  2 +-
 test/CMakeLists.txt                    |  5 ++++-
 test/laplace.mini                      |  0
 4 files changed, 19 insertions(+), 2 deletions(-)
 create mode 100644 test/laplace.mini

diff --git a/cmake/modules/DunePerftoolMacros.cmake b/cmake/modules/DunePerftoolMacros.cmake
index dc5b66fc..f64ba56b 100644
--- a/cmake/modules/DunePerftoolMacros.cmake
+++ b/cmake/modules/DunePerftoolMacros.cmake
@@ -43,6 +43,17 @@
 #    form compiler changed.
 #
 
+add_custom_target(generation)
+
+# Gather a list of form compiler sources to add as dependencies
+# to have correct retriggers of generated executables
+if(CMAKE_PROJECT_NAME STREQUAL dune-perftool)
+  set(UFL2PDELAB_GLOB_PATTERN "${CMAKE_SOURCE_DIR}/python/*.py")
+else()
+  # TODO: How do we get to the source here???
+endif()
+file(GLOB_RECURSE UFL2PDELAB_SOURCES ${UFL2PDELAB_GLOB_PATTERN})
+
 function(add_generated_executable)
   set(OPTIONS)
   set(SINGLE TARGET OPERATOR DRIVER UFLFILE)
@@ -92,8 +103,11 @@ function(add_generated_executable)
                              --driver-file ${GEN_DRIVER}
                              ${GEN_FORM_COMPILER_ARGS}
                              ${GEN_UFLFILE}
+                     DEPENDS ${GEN_UFLFILE} ${UFL2PDELAB_SOURCES}
                      COMMENT "Running ufl2pdelab for the target ${GEN_TARGET}"
                     )
 
   add_executable(${GEN_TARGET} ${GEN_MAIN} ${GEN_OPERATOR} ${GEN_DRIVER})
+
+  add_dependencies(generation ${GEN_TARGET})
 endfunction()
diff --git a/dune.module b/dune.module
index b1c8deb6..1de69837 100644
--- a/dune.module
+++ b/dune.module
@@ -7,4 +7,4 @@ Module: dune-perftool
 Version: 0.0
 Maintainer: dominic.kempf@iwr.uni-heidelberg.de
 #depending on
-Depends: dune-python dune-pdelab
+Depends: dune-testtools dune-pdelab
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 48c409ab..afe634a1 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,2 +1,5 @@
 add_generated_executable(UFLFILE ../examples/laplace.ufl
-                         TARGET laplace)
\ No newline at end of file
+                         TARGET laplace)
+
+dune_add_system_test(TARGET laplace
+                     INIFILE laplace.mini)
diff --git a/test/laplace.mini b/test/laplace.mini
new file mode 100644
index 00000000..e69de29b
-- 
GitLab