diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 44c390c141adb7ed04311da5098e9bbabd397008..7077bbbc989fc1fd4313133f3da520c7c3cb724e 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -214,14 +214,7 @@ void cmLocalGenerator::TraceDependencies()
 
 void cmLocalGenerator::GenerateTestFiles()
 {
-  std::string file = this->StateSnapshot.GetDirectory().GetCurrentBinary();
-  file += "/";
-  file += "CTestTestfile.cmake";
-
   if (!this->Makefile->IsOn("CMAKE_TESTING_ENABLED")) {
-    if (cmSystemTools::FileExists(file)) {
-      cmSystemTools::RemoveFile(file);
-    }
     return;
   }
 
@@ -230,6 +223,10 @@ void cmLocalGenerator::GenerateTestFiles()
   const std::string& config =
     this->Makefile->GetConfigurations(configurationTypes, false);
 
+  std::string file = this->StateSnapshot.GetDirectory().GetCurrentBinary();
+  file += "/";
+  file += "CTestTestfile.cmake";
+
   cmGeneratedFileStream fout(file.c_str());
   fout.SetCopyIfDifferent(true);