diff --git a/stuff/math.hh b/stuff/math.hh
index 2d2f85d66f37e086958012aabdd9119e32623979..0e810c2a12c3335e68a1fef77022d66f6db17cf8 100644
--- a/stuff/math.hh
+++ b/stuff/math.hh
@@ -20,6 +20,8 @@
 #include <boost/accumulators/statistics/mean.hpp>
 #include <boost/math/special_functions/fpclassify.hpp>
 
+#if HAVE_DUNE_FEM
+#include <dune/fem/function/blockvectorfunction/blockvectorfunction.hh>
 namespace boost {
 namespace math {
 //! isinf specialization for Dune::StraightenBlockVector
@@ -34,6 +36,7 @@ inline bool isinf(const Dune::StraightenBlockVector<BlockVectorImp, DofImp>& x)
 }
 }
 }
+#endif
 
 namespace Stuff {