diff --git a/dumux/discretization/projection/l2_projection.hh b/dumux/discretization/projection/l2_projection.hh
index 7dbeda486e513b2d6b9f21718102d81847970f37..49f2ac18e380a50b1c736d918f61b927a1e6b0bb 100644
--- a/dumux/discretization/projection/l2_projection.hh
+++ b/dumux/discretization/projection/l2_projection.hh
@@ -23,6 +23,7 @@
  */
 #ifndef DUMUX_DISCRETIZATION_L2_PROJECTION_HH
 #define DUMUX_DISCRETIZATION_L2_PROJECTION_HH
+#if HAVE_DUNE_FUNCTIONS
 
 #include <vector>
 
@@ -31,6 +32,7 @@
 #include <dune/geometry/quadraturerules.hh>
 #include <dune/istl/bcrsmatrix.hh>
 #include <dune/istl/bvector.hh>
+#include <dune/functions/gridfunctions/gridviewfunction.hh>
 
 #include <dumux/linear/seqsolverbackend.hh>
 #include <dumux/assembly/jacobianpattern.hh>
@@ -62,7 +64,7 @@ public:
     {}
 
     template <class Function>
-    CoefficientVector project(Function&& function, const Params& params = Params{})
+    CoefficientVector project(Function&& function, const Params& params = Params{}) const
     {
         CoefficientVector projection, rhs;
         projection.resize(feBasis_.size());
@@ -162,4 +164,5 @@ private:
 
 } // end namespace Dumux
 
+#endif // HAVE_DUNE_FUNCTIONS
 #endif