diff --git a/CMakeLists.txt b/CMakeLists.txt
index 181295035f3e751a048fd0c7db5ad6ac9bdbc549..d15a82d0c1817ecb295a95108439057700d78a66 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,7 +27,7 @@ add_subdirectory("dune")
 add_subdirectory("src")
 add_subdirectory("cmake/modules")
 
-if(HAVE_AMIRAMESH AND HAVE_IPOPT AND HAVE_PSURFACE AND HAVE_UG)
+if(HAVE_AMIRAMESH AND HAVE_IPOPT AND HAVE_PSURFACE AND dune-uggrid_FOUND)
   set(programs viscoelast nonlinelast)
 
   foreach(_program ${programs})
@@ -40,7 +40,7 @@ if(HAVE_AMIRAMESH AND HAVE_IPOPT AND HAVE_PSURFACE AND HAVE_UG)
   endforeach()
 endif()
 
-if(HAVE_AMIRAMESH AND HAVE_IPOPT AND HAVE_PSURFACE AND HAVE_UG AND ADOLC_FOUND)
+if(HAVE_AMIRAMESH AND HAVE_IPOPT AND HAVE_PSURFACE AND dune-uggrid_FOUND AND ADOLC_FOUND)
   add_dune_adolc_flags(nonlinelast)
 endif()