summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOrkun Tokdemir <ilhanorkuntokdemir@gmail.com>2023-07-04 10:12:42 (GMT)
committerOrkun Tokdemir <ilhanorkuntokdemir@gmail.com>2023-09-13 13:58:47 (GMT)
commit972cfd1bc393c56d249f1a2fbb8602e5d0c5bb07 (patch)
tree77d656188851edeffa1aa701f9a7c5bcd8da27d6
parent7f5d5f6e5aa2ab4c7043756b607125154fe44666 (diff)
downloadCMake-972cfd1bc393c56d249f1a2fbb8602e5d0c5bb07.zip
CMake-972cfd1bc393c56d249f1a2fbb8602e5d0c5bb07.tar.gz
CMake-972cfd1bc393c56d249f1a2fbb8602e5d0c5bb07.tar.bz2
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.
-rw-r--r--Source/cmCustomCommandGenerator.cxx13
-rw-r--r--Source/cmCustomCommandGenerator.h3
2 files changed, 7 insertions, 9 deletions
diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx
index 2c1480a..634b63b 100644
--- a/Source/cmCustomCommandGenerator.cxx
+++ b/Source/cmCustomCommandGenerator.cxx
@@ -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
diff --git a/Source/cmCustomCommandGenerator.h b/Source/cmCustomCommandGenerator.h
index 4453654..43bdd10 100644
--- a/Source/cmCustomCommandGenerator.h
+++ b/Source/cmCustomCommandGenerator.h
@@ -20,7 +20,8 @@ class cmLocalGenerator;
class cmCustomCommandGenerator
{
- std::string GetInternalDepfileName(const std::string&, const std::string&);
+ std::string GetInternalDepfileName(const std::string&,
+ const std::string&) const;
cmCustomCommand const* CC;
std::string OutputConfig;