From 78a06b351d3dbfdc6056fe9b66dfb6333dae8dc1 Mon Sep 17 00:00:00 2001
From: Dominic Kempf <dominic.kempf@iwr.uni-heidelberg.de>
Date: Fri, 1 Dec 2017 11:19:47 +0100
Subject: [PATCH] [cmake] Retrigger code generation from downstream modules

So far, changes in the form compiler did not trigger code regeneration
if invoked from a downstream dune module. This is fixed now.
---
 cmake/modules/DunePerftoolMacros.cmake | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/cmake/modules/DunePerftoolMacros.cmake b/cmake/modules/DunePerftoolMacros.cmake
index 074b5e5e..66d0b4d7 100644
--- a/cmake/modules/DunePerftoolMacros.cmake
+++ b/cmake/modules/DunePerftoolMacros.cmake
@@ -64,8 +64,14 @@ add_custom_target(generation)
 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???
-  message(WARNING "You are using dune-perftool from a downstream module. This may cause insufficient retriggers of code generation")
+  dune_module_path(MODULE dune-perftool
+                   RESULT perftool_path
+                   CMAKE_MODULES)
+  dune_execute_process(COMMAND ${CMAKE_BINARY_DIR}/run-in-dune-env python ${perftool_path}/perftool_sourcepath.py
+                       OUTPUT_VARIABLE perftool_source
+                       OUTPUT_STRIP_TRAILING_WHITESPACE
+                       )
+  set(UFL2PDELAB_GLOB_PATTERN "${perftool_source}/*.py")
 endif()
 file(GLOB_RECURSE UFL2PDELAB_SOURCES ${UFL2PDELAB_GLOB_PATTERN})
 
-- 
GitLab