diff --git a/cmake/modules/DunePerftoolMacros.cmake b/cmake/modules/DunePerftoolMacros.cmake
index 074b5e5e22810ea2ac433c008244b5b751dafa60..66d0b4d7537b4ba44c69bfa4ebfd6b8fe9aae2c4 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})
 
diff --git a/cmake/modules/perftool_sourcepath.py b/cmake/modules/perftool_sourcepath.py
new file mode 100644
index 0000000000000000000000000000000000000000..26cde733d7b09b3dd344213ea0ed2f3030bb88de
--- /dev/null
+++ b/cmake/modules/perftool_sourcepath.py
@@ -0,0 +1,16 @@
+# Find the actual sources of dune-perftool from downstream modules
+# to define dependency on them (otherwise working on the form compiler
+# becomes PITA). The cmake variable dune-perftool_DIR only points to the
+# *build directory*, the source directory of upstream modules is not
+# available through CMake (for good reason).
+#
+# Do not use this on your own, DunePerftoolMacros.cmake uses this!
+
+import os
+import sys
+import dune.perftool
+
+path = dune.perftool.__path__[0]
+path = os.path.split(os.path.split(path)[0])[0]
+sys.stdout.write(path)
+sys.exit(0)