mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 21:31:08 -06:00
cmCustomCommandGenerator: Treat relative outputs w.r.t. build dir
The `add_custom_command` and `add_custom_target` commands already do this for plain output and byproduct paths. Perform the same conversion for such paths discovered after generator expression evaluation too.
This commit is contained in:
@@ -24,25 +24,42 @@
|
|||||||
#include "cmTransformDepfile.h"
|
#include "cmTransformDepfile.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
std::vector<std::string> EvaluatePaths(std::vector<std::string> const& paths,
|
std::vector<std::string> EvaluateDepends(std::vector<std::string> const& paths,
|
||||||
cmGeneratorExpression const& ge,
|
cmGeneratorExpression const& ge,
|
||||||
cmLocalGenerator* lg,
|
cmLocalGenerator* lg,
|
||||||
std::string const& config)
|
std::string const& config)
|
||||||
{
|
{
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> depends;
|
||||||
for (std::string const& p : paths) {
|
for (std::string const& p : paths) {
|
||||||
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(p);
|
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(p);
|
||||||
std::string const& ep = cge->Evaluate(lg, config);
|
std::string const& ep = cge->Evaluate(lg, config);
|
||||||
cm::append(result, cmExpandedList(ep));
|
cm::append(depends, cmExpandedList(ep));
|
||||||
}
|
}
|
||||||
for (std::string& p : result) {
|
for (std::string& p : depends) {
|
||||||
if (cmSystemTools::FileIsFullPath(p)) {
|
if (cmSystemTools::FileIsFullPath(p)) {
|
||||||
p = cmSystemTools::CollapseFullPath(p);
|
p = cmSystemTools::CollapseFullPath(p);
|
||||||
} else {
|
} else {
|
||||||
cmSystemTools::ConvertToUnixSlashes(p);
|
cmSystemTools::ConvertToUnixSlashes(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return depends;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> EvaluateOutputs(std::vector<std::string> const& paths,
|
||||||
|
cmGeneratorExpression const& ge,
|
||||||
|
cmLocalGenerator* lg,
|
||||||
|
std::string const& config)
|
||||||
|
{
|
||||||
|
std::vector<std::string> outputs;
|
||||||
|
for (std::string const& p : paths) {
|
||||||
|
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(p);
|
||||||
|
std::string const& ep = cge->Evaluate(lg, config);
|
||||||
|
cm::append(outputs, cmExpandedList(ep));
|
||||||
|
}
|
||||||
|
for (std::string& p : outputs) {
|
||||||
|
p = cmSystemTools::CollapseFullPath(p, lg->GetCurrentBinaryDirectory());
|
||||||
|
}
|
||||||
|
return outputs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,10 +141,10 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc,
|
|||||||
this->CommandLines.push_back(std::move(argv));
|
this->CommandLines.push_back(std::move(argv));
|
||||||
}
|
}
|
||||||
|
|
||||||
this->Outputs = EvaluatePaths(cc.GetOutputs(), ge, this->LG, this->Config);
|
this->Outputs = EvaluateOutputs(cc.GetOutputs(), ge, this->LG, this->Config);
|
||||||
this->Byproducts =
|
this->Byproducts =
|
||||||
EvaluatePaths(cc.GetByproducts(), ge, this->LG, this->Config);
|
EvaluateOutputs(cc.GetByproducts(), ge, this->LG, this->Config);
|
||||||
this->Depends = EvaluatePaths(cc.GetDepends(), ge, this->LG, this->Config);
|
this->Depends = EvaluateDepends(cc.GetDepends(), ge, this->LG, this->Config);
|
||||||
|
|
||||||
const std::string& workingdirectory = this->CC->GetWorkingDirectory();
|
const std::string& workingdirectory = this->CC->GetWorkingDirectory();
|
||||||
if (!workingdirectory.empty()) {
|
if (!workingdirectory.empty()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user