diff --git a/bin/duneproject b/bin/duneproject
index b298f549309157aed83d20791b16c46e6975ab3f..cd88748e2a366cb59c4125b97ecd9dc632f0b249 100755
--- a/bin/duneproject
+++ b/bin/duneproject
@@ -465,7 +465,7 @@ M_DELIM
 ################## CMakeLists.txt ##################
 echo " - $PROJECT/CMakeLists.txt"
 cat> "$PROJECT/CMakeLists.txt" << M_DELIM
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 2.8.8)
 project($PROJECT CXX)
 
 # for this to work you will have to modify the CMAKE_MODULE_PATH
@@ -841,6 +841,7 @@ EOF
 
 echo "- $PROJECT/$PROJECT""-config.cmake.in"
 cat> "$PROJECT/$PROJECT""-config.cmake.in" <<EOF
+if(NOT @DUNE_MOD_NAME@_FOUND)
 #import the target
 #include("@CMAKE_BINARY_DIR@/@DUNE_MOD_NAME@-targets.cmake")
 
@@ -853,6 +854,7 @@ set(@DUNE_MOD_NAME@_CXX_FLAGS_MINSIZEREL "@CMAKE_CXX_FLAGS_MINSIZEREL@")
 set(@DUNE_MOD_NAME@_CXX_FLAGS_RELEASE "@CMAKE_CXX_FLAGS_RELEASE@")
 set(@DUNE_MOD_NAME@_CXX_FLAGS_RELWITHDEBINFO "@CMAKE_CXX_FLAGS_RELWITHDEBINFO@")
 set(@DUNE_MOD_NAME@_LIBRARIES "")
+endif(NOT @DUNE_MOD_NAME@_FOUND)
 EOF
 
 mkdir "$PROJECT/cmake"
@@ -861,6 +863,7 @@ mkdir "$PROJECT/cmake/pkg"
 
 echo "- $PROJECT/cmake/pkg/$PROJECT""-config.cmake.in"
 cat> "$PROJECT/cmake/pkg/$PROJECT""-config.cmake.in" <<EOF
+if(NOT @DUNE_MOD_NAME@_FOUND)
 #compute installation prefix relative to this file
 get_filename_component(_dir "\${CMAKE_CURRENT_LIST_FILE}" PATH)
 get_filename_component(_prefix "\${_dir}/../../.." ABSOLUTE)
@@ -875,6 +878,7 @@ set(@DUNE_MOD_NAME@_CXX_FLAGS_DEBUG "@CMAKE_CXX_FLAGS_DEBUG@")
 set(@DUNE_MOD_NAME@_CXX_FLAGS_MINSIZEREL "@CMAKE_CXX_FLAGS_MINSIZEREL@")
 set(@DUNE_MOD_NAME@_CXX_FLAGS_RELEASE "@CMAKE_CXX_FLAGS_RELEASE@")
 set(@DUNE_MOD_NAME@_CXX_FLAGS_RELWITHDEBINFO "@CMAKE_CXX_FLAGS_RELWITHDEBINFO@")
+endif(NOT @DUNE_MOD_NAME@_FOUND)
 EOF
 
 echo "- $PROJECT/$PROJECT""-version.cmake.in"
diff --git a/cmake/pkg/dune-common-config.cmake.in b/cmake/pkg/dune-common-config.cmake.in
index 877edf4f01b43546da8bdce08ace9979c57e2ce8..4d3c83a2e772e754f00ebb94980c75829fb571ad 100644
--- a/cmake/pkg/dune-common-config.cmake.in
+++ b/cmake/pkg/dune-common-config.cmake.in
@@ -1,3 +1,4 @@
+if(NOT @DUNE_MOD_NAME@_FOUND)
 #compute installation prefix relative to this file
 get_filename_component(_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
 get_filename_component(_prefix "${_dir}/../../.." ABSOLUTE)
@@ -16,4 +17,5 @@ set(@DUNE_MOD_NAME@_CXX_FLAGS_RELWITHDEBINFO "@CMAKE_CXX_FLAGS_RELWITHDEBINFO@")
 set(@DUNE_MOD_NAME@_LIBRARIES "dunecommon")
 set(@DUNE_MOD_NAME@_SCRIPT_DIR "${_prefix}/share/cmake/scripts")
 set(@DUNE_MOD_NAME@_SCRIPT_SOURCE_DIR "${_prefix}/share/cmake/scripts")
-set(DOXYSTYLE_FILE "${_prefix}/share/dune-common/doc/doxygen/Doxystyle")
\ No newline at end of file
+set(DOXYSTYLE_FILE "${_prefix}/share/dune-common/doc/doxygen/Doxystyle")
+endif(NOT @DUNE_MOD_NAME@_FOUND)
\ No newline at end of file