From 93e34a5e0e552d4e0f4e945f301d166c464a7a46 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 29 Aug 2025 11:45:07 -0400 Subject: [PATCH] cmGlobalGenerator: Constify GetTargetDirectDepends It should only be called for targets whose dependencies are already computed. --- Source/cmGlobalGenerator.cxx | 7 +++++-- Source/cmGlobalGenerator.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index bf155851c2..5d46d2a166 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -3389,9 +3389,12 @@ cmValue cmGlobalGenerator::GetDebuggerWorkingDirectory( } cmGlobalGenerator::TargetDependSet const& -cmGlobalGenerator::GetTargetDirectDepends(cmGeneratorTarget const* target) +cmGlobalGenerator::GetTargetDirectDepends( + cmGeneratorTarget const* target) const { - return this->TargetDependencies[target]; + auto i = this->TargetDependencies.find(target); + assert(i != this->TargetDependencies.end()); + return i->second; } bool cmGlobalGenerator::TargetOrderIndexLess(cmGeneratorTarget const* l, diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index e7b252859d..7d59d9a8bb 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -525,7 +525,7 @@ public: // what targets does the specified target depend on directly // via a target_link_libraries or add_dependencies TargetDependSet const& GetTargetDirectDepends( - cmGeneratorTarget const* target); + cmGeneratorTarget const* target) const; // Return true if target 'l' occurs before 'r' in a global ordering // of targets that respects inter-target dependencies.