diff --git a/cmake/modules/DuneCodegenMacros.cmake b/cmake/modules/DuneCodegenMacros.cmake
index 787f9d48399d35ae25062f59d8d2343cce2f9607..bd3f9649116d72afee7118e5d3940e5f11a54e4e 100644
--- a/cmake/modules/DuneCodegenMacros.cmake
+++ b/cmake/modules/DuneCodegenMacros.cmake
@@ -79,6 +79,8 @@
 #    generator is run.
 #
 
+find_package(benchmark)
+
 add_custom_target(generation)
 
 # Gather a list of form compiler sources to add as dependencies
diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt
index c237bdfe9395e4db5464ccfdef7f54efdaa2ac04..b96bd06cbce6361f1130e17bb7cb4d97efe08ec7 100644
--- a/python/CMakeLists.txt
+++ b/python/CMakeLists.txt
@@ -21,10 +21,9 @@ dune_python_add_test(NAME pep8-ourcode
 
 add_subdirectory(test)
 
-# Add a dummy target to extract compiler flags for the autotune tool chain
-include_directories(../../benchmark/include)
-link_directories(../../build-benchmark-optimized-gcc8/src)
-
 add_executable(_autotune_target EXCLUDE_FROM_ALL _autotune.cc)
-target_link_libraries(_autotune_target benchmark)
 target_compile_options(_autotune_target PUBLIC -fno-strict-aliasing)
+
+if(benchmark_FOUND)
+  target_link_libraries(_autotune_target benchmark::benchmark)
+endif()