Explorar el Código

Remove CTestTestfile.cmake when BUILD_TESTING is OFF

When disabling BUILD_TESTING after a previous configure, the
`CTestTestfile.cmake` was left unchanged.  As a result, ctest would see
the tests while the user disabled testing.  Now when BUILD_TESTING is
OFF any existing `CTestTestfile.cmake` is removed ensuring an empty test
list.
Sylvain Joubert hace 9 años
padre
commit
ae4cfa8b12
Se han modificado 1 ficheros con 7 adiciones y 4 borrados
  1. 7 4
      Source/cmLocalGenerator.cxx

+ 7 - 4
Source/cmLocalGenerator.cxx

@@ -211,7 +211,14 @@ 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;
   }
 
@@ -220,10 +227,6 @@ 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);