mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user