summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSylvain Joubert <joubert.sy@gmail.com>2016-11-14 20:42:10 (GMT)
committerBrad King <brad.king@kitware.com>2016-11-15 15:08:12 (GMT)
commitae4cfa8b12d127d7673c6278eb67acdae6239b4e (patch)
tree090444b932e22bd799bc9726e5e05651fdcfc5d4
parent1d9934a56a36707a9366043042c3aa3e5ae7d86d (diff)
downloadCMake-ae4cfa8b12d127d7673c6278eb67acdae6239b4e.zip
CMake-ae4cfa8b12d127d7673c6278eb67acdae6239b4e.tar.gz
CMake-ae4cfa8b12d127d7673c6278eb67acdae6239b4e.tar.bz2
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.
-rw-r--r--Source/cmLocalGenerator.cxx11
1 files changed, 7 insertions, 4 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index e7dfed5..1fda4e9 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/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);