summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-09-03 15:09:19 -0400
committerBrad King <brad.king@kitware.com>2020-09-04 09:44:30 -0400
commit152724274534def1126f97a28f0ce9f0e126a2b2 (patch)
treea41ca387a2fdf1f948ec04ba9abf011030a0bb52
parent48bf7192e702f9fdc99585e3d9d616091cc62974 (diff)
downloadcmake-152724274534def1126f97a28f0ce9f0e126a2b2.tar.gz
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.
-rw-r--r--Source/cmLocalVisualStudio10Generator.cxx29
-rw-r--r--Source/cmLocalVisualStudio10Generator.h9
2 files changed, 12 insertions, 26 deletions
diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx
index 6c7d6c6c45..9706f2e7d0 100644
--- a/Source/cmLocalVisualStudio10Generator.cxx
+++ b/Source/cmLocalVisualStudio10Generator.cxx
@@ -66,29 +66,17 @@ cmLocalVisualStudio10Generator::~cmLocalVisualStudio10Generator()
{
}
-void cmLocalVisualStudio10Generator::GenerateTargetsDepthFirst(
- cmGeneratorTarget* target, std::vector<cmGeneratorTarget*>& 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<cmGeneratorTarget*>(&*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<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator)
->TargetIsFortranOnly(target)) {
@@ -104,12 +92,9 @@ void cmLocalVisualStudio10Generator::GenerateTargetsDepthFirst(
void cmLocalVisualStudio10Generator::Generate()
{
- std::vector<cmGeneratorTarget*> 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 84216c8fb8..a12247cac3 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<cmSourceFile const*>& GetSourcesVisited(cmGeneratorTarget* target)
+ std::set<cmSourceFile const*>& 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<cmGeneratorTarget*>& remaining);
+ void GenerateTarget(cmGeneratorTarget* target);
- std::map<cmGeneratorTarget*, std::set<cmSourceFile const*>> SourcesVisited;
+ std::map<cmGeneratorTarget const*, std::set<cmSourceFile const*>>
+ SourcesVisited;
};