diff options
Diffstat (limited to 'Source/cmLocalUnixMakefileGenerator3.cxx')
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.cxx | 60 |
1 files changed, 54 insertions, 6 deletions
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 88966c8..6a08840 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -15,6 +15,7 @@ #include "cmCustomCommandGenerator.h" #include "cmFileTimeCache.h" #include "cmGeneratedFileStream.h" +#include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" #include "cmGlobalUnixMakefileGenerator3.h" @@ -115,10 +116,9 @@ void cmLocalUnixMakefileGenerator3::Generate() this->Makefile->IsOn("CMAKE_SKIP_ASSEMBLY_SOURCE_RULES"); // Generate the rule files for each target. - const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets(); cmGlobalUnixMakefileGenerator3* gg = static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator); - for (cmGeneratorTarget* target : targets) { + for (cmGeneratorTarget* target : this->GetGeneratorTargets()) { if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } @@ -154,8 +154,7 @@ void cmLocalUnixMakefileGenerator3::ComputeHomeRelativeOutputPath() void cmLocalUnixMakefileGenerator3::GetLocalObjectFiles( std::map<std::string, LocalObjectInfo>& localObjectFiles) { - const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets(); - for (cmGeneratorTarget* gt : targets) { + for (cmGeneratorTarget* gt : this->GetGeneratorTargets()) { if (gt->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } @@ -353,9 +352,8 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets( // for each target we just provide a rule to cd up to the top and do a make // on the target - const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets(); std::string localName; - for (cmGeneratorTarget* target : targets) { + for (cmGeneratorTarget* target : this->GetGeneratorTargets()) { if ((target->GetType() == cmStateEnums::EXECUTABLE) || (target->GetType() == cmStateEnums::STATIC_LIBRARY) || (target->GetType() == cmStateEnums::SHARED_LIBRARY) || @@ -1092,6 +1090,56 @@ void cmLocalUnixMakefileGenerator3::AppendCleanCommand( } } +void cmLocalUnixMakefileGenerator3::AppendDirectoryCleanCommand( + std::vector<std::string>& commands) +{ + std::vector<std::string> cleanFiles; + // Look for additional files registered for cleaning in this directory. + if (const char* prop_value = + this->Makefile->GetProperty("ADDITIONAL_CLEAN_FILES")) { + cmGeneratorExpression ge; + std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop_value); + cmSystemTools::ExpandListArgument( + cge->Evaluate(this, + this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")), + cleanFiles); + } + if (cleanFiles.empty()) { + return; + } + + cmLocalGenerator* rootLG = + this->GetGlobalGenerator()->GetLocalGenerators().at(0); + std::string const& binaryDir = rootLG->GetCurrentBinaryDirectory(); + std::string const& currentBinaryDir = this->GetCurrentBinaryDirectory(); + std::string cleanfile = currentBinaryDir; + cleanfile += "/CMakeFiles/cmake_directory_clean.cmake"; + // Write clean script + { + std::string cleanfilePath = cmSystemTools::CollapseFullPath(cleanfile); + cmsys::ofstream fout(cleanfilePath.c_str()); + if (!fout) { + cmSystemTools::Error("Could not create " + cleanfilePath); + return; + } + fout << "file(REMOVE_RECURSE\n"; + for (std::string const& cfl : cleanFiles) { + std::string fc = rootLG->MaybeConvertToRelativePath( + binaryDir, cmSystemTools::CollapseFullPath(cfl, currentBinaryDir)); + fout << " " << cmOutputConverter::EscapeForCMake(fc) << "\n"; + } + fout << ")\n"; + } + // Create command + { + std::string remove = "$(CMAKE_COMMAND) -P "; + remove += this->ConvertToOutputFormat( + rootLG->MaybeConvertToRelativePath(binaryDir, cleanfile), + cmOutputConverter::SHELL); + commands.push_back(std::move(remove)); + } +} + void cmLocalUnixMakefileGenerator3::AppendEcho( std::vector<std::string>& commands, std::string const& text, EchoColor color, EchoProgress const* progress) |