diff options
Diffstat (limited to 'Source/cmCustomCommandGenerator.cxx')
-rw-r--r-- | Source/cmCustomCommandGenerator.cxx | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index 41d4442..14c22e3 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -148,6 +148,14 @@ std::string EvaluateDepfile(std::string const& path, std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(path); return cge->Evaluate(lg, config); } + +std::string EvaluateComment(const char* comment, + cmGeneratorExpression const& ge, + cmLocalGenerator* lg, std::string const& config) +{ + std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(comment); + return cge->Evaluate(lg, config); +} } cmCustomCommandGenerator::cmCustomCommandGenerator( @@ -172,7 +180,7 @@ cmCustomCommandGenerator::cmCustomCommandGenerator( }; } - cmGeneratorExpression ge(cc.GetBacktrace()); + cmGeneratorExpression ge(*lg->GetCMakeInstance(), cc.GetBacktrace()); cmGeneratorTarget const* target{ lg->FindGeneratorTargetToUse( this->Target) }; @@ -417,7 +425,8 @@ std::string cmCustomCommandGenerator::GetDepfile() const return ""; } - cmGeneratorExpression ge(this->CC->GetBacktrace()); + cmGeneratorExpression ge(*this->LG->GetCMakeInstance(), + this->CC->GetBacktrace()); return EvaluateDepfile(depfile, ge, this->LG, this->OutputConfig); } @@ -462,9 +471,19 @@ std::string cmCustomCommandGenerator::GetInternalDepfile() const return this->ComputeInternalDepfile(this->OutputConfig, depfile); } -const char* cmCustomCommandGenerator::GetComment() const +cm::optional<std::string> cmCustomCommandGenerator::GetComment() const { - return this->CC->GetComment(); + const char* comment = this->CC->GetComment(); + if (!comment) { + return cm::nullopt; + } + if (!*comment) { + return std::string(); + } + + cmGeneratorExpression ge(*this->LG->GetCMakeInstance(), + this->CC->GetBacktrace()); + return EvaluateComment(comment, ge, this->LG, this->OutputConfig); } std::string cmCustomCommandGenerator::GetWorkingDirectory() const |