diff --git a/CMakeLists.txt b/CMakeLists.txt
index ed304633f8b03b82807d3c919d45adfe41fa8e63..8b70fc58e31c515d04e091b963d2c56fbf758911 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -17,6 +17,7 @@ add_subdirectory("src")
 
 if(HAVE_AMIRAMESH AND HAVE_IPOPT AND HAVE_PSURFACE AND HAVE_UG)
   set(programs viscoelast nonlinelast)
+
   foreach(_program ${programs})
     add_executable(${_program} ${_program}.cc)
     add_dune_amiramesh_flags(${_program})
@@ -27,7 +28,7 @@ if(HAVE_AMIRAMESH AND HAVE_IPOPT AND HAVE_PSURFACE AND HAVE_UG)
   endforeach()
 endif()
 
-if (ADOLC_FOUND)
+if(HAVE_AMIRAMESH AND HAVE_IPOPT AND HAVE_PSURFACE AND HAVE_UG AND ADOLC_FOUND)
   add_dune_adolc_flags(nonlinelast)
 endif()