diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2019-05-13 15:58:06 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2019-05-14 15:50:14 (GMT) |
commit | 012d599e26392312266e96d5ff6d0b905e7e2647 (patch) | |
tree | 8c95782cdffd07a3551327e7637a895d7c67fbb4 /Source | |
parent | 890a1b9dc34820b73f77221f68e04cf1ae811234 (diff) | |
download | CMake-012d599e26392312266e96d5ff6d0b905e7e2647.zip CMake-012d599e26392312266e96d5ff6d0b905e7e2647.tar.gz CMake-012d599e26392312266e96d5ff6d0b905e7e2647.tar.bz2 |
Ninja: Add support for ADDITIONAL_CLEAN_FILES target property
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmNinjaNormalTargetGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 25 | ||||
-rw-r--r-- | Source/cmNinjaTargetGenerator.h | 2 |
3 files changed, 29 insertions, 0 deletions
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index ebb7c15..680f881 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -83,6 +83,8 @@ void cmNinjaNormalTargetGenerator::Generate() this->WriteDeviceLinkStatement(); this->WriteLinkStatement(); } + + this->AdditionalCleanFiles(); } void cmNinjaNormalTargetGenerator::WriteLanguagesRules() diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 506711a..8afac70 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -1310,6 +1310,31 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand( this->GetGlobalGenerator()->AddCXXCompileCommand(cmdLine, sourceFileName); } +void cmNinjaTargetGenerator::AdditionalCleanFiles() +{ + if (const char* prop_value = + this->GeneratorTarget->GetProperty("ADDITIONAL_CLEAN_FILES")) { + cmLocalNinjaGenerator* lg = this->LocalGenerator; + std::vector<std::string> cleanFiles; + { + cmGeneratorExpression ge; + auto cge = ge.Parse(prop_value); + cmSystemTools::ExpandListArgument( + cge->Evaluate(lg, + this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"), + false, this->GeneratorTarget, nullptr, nullptr), + cleanFiles); + } + std::string const& binaryDir = lg->GetCurrentBinaryDirectory(); + cmGlobalNinjaGenerator* gg = lg->GetGlobalNinjaGenerator(); + for (std::string const& cleanFile : cleanFiles) { + // Support relative paths + gg->AddAdditionalCleanFile( + cmSystemTools::CollapseFullPath(cleanFile, binaryDir)); + } + } +} + void cmNinjaTargetGenerator::EnsureDirectoryExists( const std::string& path) const { diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 3dbc1b5..235c60c 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -134,6 +134,8 @@ protected: std::string const& objectFileDir, std::string const& flags, std::string const& defines, std::string const& includes); + void AdditionalCleanFiles(); + cmNinjaDeps GetObjects() const { return this->Objects; } void EnsureDirectoryExists(const std::string& dir) const; |