diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4266cf52a67d16dc47ac3df4c4f20228c0ba177e..357a711e112ea99602a3d3ff8b9d0fc605de75b8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,8 +9,6 @@ find_package(dune-common REQUIRED)
 list(APPEND CMAKE_MODULE_PATH ${dune-common_MODULE_PATH})
 include(DuneMacros)
 
-find_package(HDF5 COMPONENTS C HL)
-
 dune_project()
 
 add_subdirectory("doc")
diff --git a/cmake/modules/AddHDF5Flags.cmake b/cmake/modules/AddHDF5Flags.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..195c9cb4847ca8cd30a96fc64a5ba37d345bf6f0
--- /dev/null
+++ b/cmake/modules/AddHDF5Flags.cmake
@@ -0,0 +1,18 @@
+#
+# Module providing convenience methods for compile binaries with HDF5 support.
+#
+# Provides the following functions:
+#
+# add_dune_hdf5_flags(target1 target2 ...)
+#
+# adds HDF5 flags to the targets for compilation and linking
+#
+
+function(add_dune_hdf5_flags _targets)
+    if(HDF5_FOUND)
+        foreach(_target ${_targets})
+            target_link_libraries(${_target} ${HDF5_LIBRARIES})
+            set_property(TARGET ${_target} APPEND PROPERTY INCLUDE_DIRECTORIES ${HDF5_INCLUDE_DIR})
+        endforeach(_target ${_targets})
+    endif(HDF5_FOUND)
+endfunction(add_dune_hdf5_flags)
diff --git a/cmake/modules/DuneFufemMacros.cmake b/cmake/modules/DuneFufemMacros.cmake
index c394897f9603acfca951300e5a78e9e7eebd67b6..fe934054cf1a3b5578bd4f46ac35804b2f602ba6 100644
--- a/cmake/modules/DuneFufemMacros.cmake
+++ b/cmake/modules/DuneFufemMacros.cmake
@@ -42,9 +42,11 @@ set(Python_ADDITIONAL_VERSIONS 2.7 3 3.2)
 
 find_package(PythonLibs)
 find_package(Adolc)
+find_package(HDF5 COMPONENTS C HL)
 
 find_package(Boost COMPONENTS serialization)
 set(HAVE_BOOST_SERIALIZATION ${Boost_SERIALIZATION_FOUND})
 
 include(AddPythonLibsFlags)
 include(AddAdolcFlags)
+include(AddHDF5Flags)
diff --git a/dune/fufem/test/CMakeLists.txt b/dune/fufem/test/CMakeLists.txt
index d0b4d6376211aec4be358f11dec3533a37cf7fe4..efcfe0c45220645e336af608b17310365a2f558e 100644
--- a/dune/fufem/test/CMakeLists.txt
+++ b/dune/fufem/test/CMakeLists.txt
@@ -85,6 +85,5 @@ endif()
 
 if (HDF5_FOUND)
   dune_add_test(SOURCES test-hdf5.cc)
-  set_property(TARGET test-hdf5 APPEND PROPERTY INCLUDE_DIRECTORIES ${HDF5_INCLUDE_DIR})
-  target_link_libraries(test-hdf5 ${HDF5_LIBRARIES})
+  add_dune_hdf5_flags(test-hdf5)
 endif()