From 152724274534def1126f97a28f0ce9f0e126a2b2 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 3 Sep 2020 15:09:19 -0400 Subject: cmLocalVisualStudio10Generator: Simplify target ordering by dependencies Replace our own depth-first traversal with use of the global generator's computed target order that respects dependencies. --- Source/cmLocalVisualStudio10Generator.cxx | 29 +++++++---------------------- Source/cmLocalVisualStudio10Generator.h | 9 +++++---- 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index 6c7d6c6..9706f2e 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -66,29 +66,17 @@ cmLocalVisualStudio10Generator::~cmLocalVisualStudio10Generator() { } -void cmLocalVisualStudio10Generator::GenerateTargetsDepthFirst( - cmGeneratorTarget* target, std::vector& remaining) +void cmLocalVisualStudio10Generator::GenerateTarget(cmGeneratorTarget* target) { if (!target->IsInBuildSystem()) { return; } - // Find this target in the list of remaining targets. - auto it = std::find(remaining.begin(), remaining.end(), target); - if (it == remaining.end()) { - // This target was already handled. - return; - } - // Remove this target from the list of remaining targets because - // we are handling it now. - *it = nullptr; + auto& targetVisited = this->GetSourcesVisited(target); auto& deps = this->GlobalGenerator->GetTargetDirectDepends(target); for (auto& d : deps) { - // FIXME: Revise CreateSingleVCProj so we do not have to drop `const` here. - auto dependee = const_cast(&*d); - GenerateTargetsDepthFirst(dependee, remaining); // Take the union of visited source files of custom commands - auto visited = GetSourcesVisited(dependee); - GetSourcesVisited(target).insert(visited.begin(), visited.end()); + auto depVisited = this->GetSourcesVisited(d); + targetVisited.insert(depVisited.begin(), depVisited.end()); } if (static_cast(this->GlobalGenerator) ->TargetIsFortranOnly(target)) { @@ -104,12 +92,9 @@ void cmLocalVisualStudio10Generator::GenerateTargetsDepthFirst( void cmLocalVisualStudio10Generator::Generate() { - std::vector remaining; - cm::append(remaining, this->GetGeneratorTargets()); - for (auto& t : remaining) { - if (t) { - this->GenerateTargetsDepthFirst(t, remaining); - } + for (cmGeneratorTarget* gt : + this->GlobalGenerator->GetLocalGeneratorTargetsInOrder(this)) { + this->GenerateTarget(gt); } this->WriteStampFiles(); } diff --git a/Source/cmLocalVisualStudio10Generator.h b/Source/cmLocalVisualStudio10Generator.h index 84216c8..a12247c 100644 --- a/Source/cmLocalVisualStudio10Generator.h +++ b/Source/cmLocalVisualStudio10Generator.h @@ -32,7 +32,8 @@ public: void ReadAndStoreExternalGUID(const std::string& name, const char* path) override; - std::set& GetSourcesVisited(cmGeneratorTarget* target) + std::set& GetSourcesVisited( + cmGeneratorTarget const* target) { return SourcesVisited[target]; }; @@ -42,8 +43,8 @@ protected: bool CustomCommandUseLocal() const override { return true; } private: - void GenerateTargetsDepthFirst(cmGeneratorTarget* target, - std::vector& remaining); + void GenerateTarget(cmGeneratorTarget* target); - std::map> SourcesVisited; + std::map> + SourcesVisited; }; -- cgit v0.12