From 4220962d18f77399286270607eb135378b71c5b9 Mon Sep 17 00:00:00 2001 From: Pedro Navarro Date: Thu, 30 Aug 2018 15:34:24 -0700 Subject: Makefile: Add build events byproducts to clean rules --- Source/cmMakefileTargetGenerator.cxx | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 65a69d1..f423560 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -189,6 +189,30 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() } } } + + // Add byproducts from build events to the clean rules + if (clean) { + std::vector buildEventCommands = + this->GeneratorTarget->GetPreBuildCommands(); + + buildEventCommands.insert( + buildEventCommands.end(), + this->GeneratorTarget->GetPreLinkCommands().begin(), + this->GeneratorTarget->GetPreLinkCommands().end()); + buildEventCommands.insert( + buildEventCommands.end(), + this->GeneratorTarget->GetPostBuildCommands().begin(), + this->GeneratorTarget->GetPostBuildCommands().end()); + + for (const auto& be : buildEventCommands) { + const std::vector& byproducts = be.GetByproducts(); + for (std::string const& byproduct : byproducts) { + this->CleanFiles.push_back( + this->LocalGenerator->MaybeConvertToRelativePath(currentBinDir, + byproduct)); + } + } + } std::vector headerSources; this->GeneratorTarget->GetHeaderSources(headerSources, config); this->OSXBundleGenerator->GenerateMacOSXContentStatements( -- cgit v0.12