diff --git a/bin/analyzegrid/CMakeLists.txt b/bin/analyzegrid/CMakeLists.txt
index 2e96704bb1c34086a54e4ed7d537804b578f10f4..bfc2f7f0a275677bd0905103e9b7b5332c310841 100644
--- a/bin/analyzegrid/CMakeLists.txt
+++ b/bin/analyzegrid/CMakeLists.txt
@@ -1,2 +1,4 @@
-add_executable(analyze_grid analyze_grid.cc)
-dune_symlink_to_source_files(FILES test_2d_structured.ini test_3d_structured.ini test_2d_unstructured.ini test_3d_unstructured.ini)
+if(consistent-edge-orientation_FOUND)
+  add_executable(analyze_grid analyze_grid.cc)
+  dune_symlink_to_source_files(FILES test_2d_structured.ini test_3d_structured.ini test_2d_unstructured.ini test_3d_unstructured.ini)
+endif()
diff --git a/cmake/modules/DunePerftoolMacros.cmake b/cmake/modules/DunePerftoolMacros.cmake
index d5557d410333edfe2a292c9ceb668195012440ea..34e542c4ae170a98f64eb4eb106c1e7012f8ead7 100644
--- a/cmake/modules/DunePerftoolMacros.cmake
+++ b/cmake/modules/DunePerftoolMacros.cmake
@@ -119,6 +119,9 @@ function(add_generated_executable)
   set(ANALYZE_GRID_FILE)
   set(ANALYZE_GRID_OPTION)
   if(GEN_ANALYZE_GRID)
+    if(NOT consistent-edge-orientation_FOUND)
+      message(FATAL_ERROR "Asked for grid analysis, but the module consistent-edge-orientation was not found!")
+    endif()
     set(ANALYZE_GRID_FILE "${GEN_INIFILE}.csv")
     set(ANALYZE_GRID_OPTION "--grid-info=${ANALYZE_GRID_FILE}")
     add_custom_command(OUTPUT ${ANALYZE_GRID_FILE}
diff --git a/test/sumfact/poisson/CMakeLists.txt b/test/sumfact/poisson/CMakeLists.txt
index 260a5f53dc643548433aa6ce8c32a83cd3f0bd61..a304dc7fcb6649ff6440688fcd0055d3645c65f4 100644
--- a/test/sumfact/poisson/CMakeLists.txt
+++ b/test/sumfact/poisson/CMakeLists.txt
@@ -50,17 +50,18 @@ dune_add_formcompiler_system_test(UFLFILE poisson_3d.ufl
 #==================================
 # Poisson DG on 'unstructured grid'
 #==================================
-dune_add_formcompiler_system_test(UFLFILE poisson_dg_2d.ufl
-                                  BASENAME sumfact_poisson_dg_2d_unstructured
-                                  INIFILE poisson_dg_2d_unstructured.mini
-                                  ANALYZE_GRID
-                                  )
-dune_add_formcompiler_system_test(UFLFILE poisson_dg_3d.ufl
-                                  BASENAME sumfact_poisson_dg_3d_unstructured
-                                  INIFILE poisson_dg_3d_unstructured.mini
-                                  ANALYZE_GRID
-                                  )
-
+if(consistent-edge-orientation_FOUND)
+  dune_add_formcompiler_system_test(UFLFILE poisson_dg_2d.ufl
+                                    BASENAME sumfact_poisson_dg_2d_unstructured
+                                    INIFILE poisson_dg_2d_unstructured.mini
+                                    ANALYZE_GRID
+                                    )
+  dune_add_formcompiler_system_test(UFLFILE poisson_dg_3d.ufl
+                                    BASENAME sumfact_poisson_dg_3d_unstructured
+                                    INIFILE poisson_dg_3d_unstructured.mini
+                                    ANALYZE_GRID
+                                    )
+endif()
 
 #=============================================
 # Poisson DG using FastDGGridOperator in 2D/3D