diff --git a/cmake/modules/DuneMacros.cmake b/cmake/modules/DuneMacros.cmake
index d657ceb2aec6c6a1cd8c9fcb2f5a790c5a38530c..03f2b3798eb0fd723b99cc48ba02fd3235f857ef 100644
--- a/cmake/modules/DuneMacros.cmake
+++ b/cmake/modules/DuneMacros.cmake
@@ -1157,5 +1157,7 @@ macro(add_dune_all_flags targets)
     set_property(TARGET ${target}
           APPEND_STRING
           PROPERTY COMPILE_FLAGS ${FLAGSTR})
+    get_property(libs GLOBAL PROPERTY ALL_PKG_LIBS)
+    target_link_libraries(${target} ${DUNE_LIBS} ${libs})
   endforeach()
 endmacro(add_dune_all_flags targets)