cmCustomCommandGenerator: Fix GetInternalDepfile on moved instance

Previously the constructor captured `this` in a lambda used by the
`GetInternalDepfile` method, but the pointer is invalidated when the
instance moves.
This commit is contained in:
Orkun Tokdemir
2023-07-04 12:12:42 +02:00
parent 7f5d5f6e5a
commit 972cfd1bc3
2 changed files with 7 additions and 9 deletions

View File

@@ -174,12 +174,6 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(
, EmulatorsWithArguments(cc.GetCommandLines().size())
, ComputeInternalDepfile(std::move(computeInternalDepfile))
{
if (!this->ComputeInternalDepfile) {
this->ComputeInternalDepfile =
[this](const std::string& cfg, const std::string& file) -> std::string {
return this->GetInternalDepfileName(cfg, file);
};
}
cmGeneratorExpression ge(*lg->GetCMakeInstance(), cc.GetBacktrace());
cmGeneratorTarget const* target{ lg->FindGeneratorTargetToUse(
@@ -445,7 +439,7 @@ std::string cmCustomCommandGenerator::GetFullDepfile() const
}
std::string cmCustomCommandGenerator::GetInternalDepfileName(
const std::string& /*config*/, const std::string& depfile)
const std::string& /*config*/, const std::string& depfile) const
{
cmCryptoHash hash(cmCryptoHash::AlgoSHA256);
std::string extension;
@@ -469,7 +463,10 @@ std::string cmCustomCommandGenerator::GetInternalDepfile() const
return "";
}
return this->ComputeInternalDepfile(this->OutputConfig, depfile);
if (this->ComputeInternalDepfile) {
return this->ComputeInternalDepfile(this->OutputConfig, depfile);
}
return this->GetInternalDepfileName(this->OutputConfig, depfile);
}
cm::optional<std::string> cmCustomCommandGenerator::GetComment() const