From f0c6a313eac808e97c40adf10d790c178a3c1df8 Mon Sep 17 00:00:00 2001
From: Dominic Kempf <dominic.kempf@iwr.uni-heidelberg.de>
Date: Fri, 15 Feb 2019 16:18:27 +0100
Subject: [PATCH] [cmake] find and use google benchmark through cmake

---
 cmake/modules/DuneCodegenMacros.cmake | 2 ++
 python/CMakeLists.txt                 | 9 ++++-----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/cmake/modules/DuneCodegenMacros.cmake b/cmake/modules/DuneCodegenMacros.cmake
index 787f9d48..bd3f9649 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 c237bdfe..b96bd06c 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()
-- 
GitLab