From ae4cfa8b12d127d7673c6278eb67acdae6239b4e Mon Sep 17 00:00:00 2001 From: Sylvain Joubert Date: Mon, 14 Nov 2016 21:42:10 +0100 Subject: 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. --- Source/cmLocalGenerator.cxx | 11 +++++++---- 1 file 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); -- cgit v0.12