diff --git a/cmake/modules/DuneCodegenMacros.cmake b/cmake/modules/DuneCodegenMacros.cmake
index e024d28e6c2a05bea4a6cf97a387bc111d75abff..d8ebdb8750d41419c05e21da8eb118718f383d54 100644
--- a/cmake/modules/DuneCodegenMacros.cmake
+++ b/cmake/modules/DuneCodegenMacros.cmake
@@ -81,7 +81,9 @@
 
 find_package(benchmark)
 
-find_package(likwid)
+if (DUNE_CODEGEN_PROFILING)
+  find_package(likwid)
+endif()
 
 add_custom_target(generation)
 
@@ -209,9 +211,6 @@ function(add_generated_executable)
   add_executable(${GEN_TARGET} ${GEN_EXCLUDE_FROM_ALL} ${GEN_SOURCE} ${header_deps})
   target_include_directories(${GEN_TARGET} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
   add_dependencies(generation ${GEN_TARGET})
-  if (DUNE_CODEGEN_PROFILING AND likwid_FOUND)
-    target_link_libraries(${GEN_TARGET} ${likwid_LIBRARIES})
-  endif ()
 endfunction()
 
 include(GeneratedSystemtests)