diff options
author | Daniel Eiband <daniel.eiband@brainlab.com> | 2019-09-11 16:05:06 (GMT) |
---|---|---|
committer | Daniel Eiband <daniel.eiband@brainlab.com> | 2019-09-17 20:58:31 (GMT) |
commit | ccc9685cc1fb61242f179a02661730140b026253 (patch) | |
tree | 4d3682be4955fcff614682e6c43c5eee19a4b62d /Source/cmCustomCommandGenerator.cxx | |
parent | 026ef9b312047778ac0638cf2d2ef8bed6a2b3f2 (diff) | |
download | CMake-ccc9685cc1fb61242f179a02661730140b026253.zip CMake-ccc9685cc1fb61242f179a02661730140b026253.tar.gz CMake-ccc9685cc1fb61242f179a02661730140b026253.tar.bz2 |
Genex: Move genex expansion of paths into AppendPaths utility
Refactored internals of cmCustomCommandGenerator to make processing of path
lists (evaluation of generator expressions and expansion into a list) available
as AppendPaths utility function to be used for byproduct generator expression
support.
Diffstat (limited to 'Source/cmCustomCommandGenerator.cxx')
-rw-r--r-- | Source/cmCustomCommandGenerator.cxx | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index 2c0cbfd..d5d7041 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -17,6 +17,26 @@ #include <memory> #include <utility> +namespace { +void AppendPaths(const std::vector<std::string>& inputs, + cmGeneratorExpression& ge, cmLocalGenerator* lg, + std::string const& config, std::vector<std::string>& output) +{ + for (std::string const& in : inputs) { + std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(in); + std::vector<std::string> result = + cmExpandedList(cge->Evaluate(lg, config)); + for (std::string& it : result) { + cmSystemTools::ConvertToUnixSlashes(it); + if (cmSystemTools::FileIsFullPath(it)) { + it = cmSystemTools::CollapseFullPath(it); + } + } + cmAppend(output, result); + } +} +} + cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc, std::string config, cmLocalGenerator* lg) @@ -46,25 +66,14 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc, // lists on an empty command may have left this empty. // FIXME: Should we define behavior for removing empty commands? if (argv.empty()) { - argv.push_back(std::string()); + argv.emplace_back(); } this->CommandLines.push_back(std::move(argv)); } - std::vector<std::string> depends = this->CC.GetDepends(); - for (std::string const& d : depends) { - std::unique_ptr<cmCompiledGeneratorExpression> cge = this->GE->Parse(d); - std::vector<std::string> result = - cmExpandedList(cge->Evaluate(this->LG, this->Config)); - for (std::string& it : result) { - cmSystemTools::ConvertToUnixSlashes(it); - if (cmSystemTools::FileIsFullPath(it)) { - it = cmSystemTools::CollapseFullPath(it); - } - } - cmAppend(this->Depends, result); - } + AppendPaths(cc.GetDepends(), *this->GE, this->LG, this->Config, + this->Depends); const std::string& workingdirectory = this->CC.GetWorkingDirectory(); if (!workingdirectory.empty()) { |