diff --git a/cmake/modules/DuneMPI.cmake b/cmake/modules/DuneMPI.cmake
index 3bd792c08b29f2c3d205abe0bf973389a63cc8ec..82f0eceaed3cf4921f100df0e8f1c28cf7f677cc 100644
--- a/cmake/modules/DuneMPI.cmake
+++ b/cmake/modules/DuneMPI.cmake
@@ -27,14 +27,15 @@ if(MPI_FOUND)
 endif(MPI_FOUND)
 
 # A macro that adds the MPI flags for the compilation
-function(add_dune_mpi_flags _target)
+function(add_dune_mpi_flags _targets)
   if(MPI_FOUND)
+    foreach(_target ${_targets})
     target_link_libraries(${_target} ${MPI_DUNE_LIBRARIES})
     # The definitions are a hack as we do not seem to know which MPI implementation was
     # found.
     SET_TARGET_PROPERTIES(${_target} PROPERTIES COMPILE_FLAGS ${MPI_DUNE_COMPILE_FLAGS}
       "-DENABLE_MPI=1 -DMPICH_SKIP_MPICXX -DMPIPP_H")
     SET_TARGET_PROPERTIES(${_target} PROPERTIES LINK_FLAGS ${MPI_DUNE_LINK_FLAGS} "")
-    #SET_TARGET_PROPERTIES(indicestest PROPERTIES INCLUDE_PATH ${MPI_CC_INCLUDE_PATH})
+    endforeach(_target ${_targets})
   endif(MPI_FOUND)
 endfunction()