summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmGlobalGenerator.cxx46
-rw-r--r--Source/cmGlobalGenerator.h8
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx41
-rw-r--r--Source/cmGlobalXCodeGenerator.h3
4 files changed, 56 insertions, 42 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 74360b8..8688b1b 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1471,6 +1471,7 @@ bool cmGlobalGenerator::Compute()
if (!this->ComputeTargetDepends()) {
return false;
}
+ this->ComputeTargetOrder();
if (this->CheckTargetsForType()) {
return false;
@@ -1581,6 +1582,50 @@ bool cmGlobalGenerator::ComputeTargetDepends()
return true;
}
+std::vector<cmGeneratorTarget*>
+cmGlobalGenerator::GetLocalGeneratorTargetsInOrder(cmLocalGenerator* lg) const
+{
+ std::vector<cmGeneratorTarget*> gts;
+ cm::append(gts, lg->GetGeneratorTargets());
+ std::sort(gts.begin(), gts.end(),
+ [this](cmGeneratorTarget const* l, cmGeneratorTarget const* r) {
+ return this->TargetOrderIndex.at(l) <
+ this->TargetOrderIndex.at(r);
+ });
+ return gts;
+}
+
+void cmGlobalGenerator::ComputeTargetOrder()
+{
+ size_t index = 0;
+ auto const& lgens = this->GetLocalGenerators();
+ for (auto const& lgen : lgens) {
+ const auto& targets = lgen->GetGeneratorTargets();
+ for (const auto& gt : targets) {
+ this->ComputeTargetOrder(gt.get(), index);
+ }
+ }
+ assert(index == this->TargetOrderIndex.size());
+}
+
+void cmGlobalGenerator::ComputeTargetOrder(cmGeneratorTarget const* gt,
+ size_t& index)
+{
+ std::map<cmGeneratorTarget const*, size_t>::value_type value(gt, 0);
+ auto insertion = this->TargetOrderIndex.insert(value);
+ if (!insertion.second) {
+ return;
+ }
+ auto entry = insertion.first;
+
+ auto& deps = this->GetTargetDirectDepends(gt);
+ for (auto& d : deps) {
+ this->ComputeTargetOrder(d, index);
+ }
+
+ entry->second = index++;
+}
+
bool cmGlobalGenerator::QtAutoGen()
{
#ifndef CMAKE_BOOTSTRAP
@@ -1760,6 +1805,7 @@ void cmGlobalGenerator::ClearGeneratorMembers()
this->GeneratorTargetSearchIndex.clear();
this->MakefileSearchIndex.clear();
this->LocalGeneratorSearchIndex.clear();
+ this->TargetOrderIndex.clear();
this->ProjectMap.clear();
this->RuleHashes.clear();
this->DirectoryContentMap.clear();
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 6ae7e15..478028e 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -4,6 +4,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
+#include <cstddef>
#include <iosfwd>
#include <map>
#include <memory>
@@ -264,6 +265,9 @@ public:
return this->LocalGenerators;
}
+ std::vector<cmGeneratorTarget*> GetLocalGeneratorTargetsInOrder(
+ cmLocalGenerator* lg) const;
+
cmMakefile* GetCurrentMakefile() const
{
return this->CurrentConfigureMakefile;
@@ -613,6 +617,10 @@ private:
// Its order is not deterministic.
LocalGeneratorMap LocalGeneratorSearchIndex;
+ void ComputeTargetOrder();
+ void ComputeTargetOrder(cmGeneratorTarget const* gt, size_t& index);
+ std::map<cmGeneratorTarget const*, size_t> TargetOrderIndex;
+
cmMakefile* TryCompileOuterMakefile;
// If you add a new map here, make sure it is copied
// in EnableLanguagesFromGenerator
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index dbc95e6..2f27128 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -424,37 +424,6 @@ void cmGlobalXCodeGenerator::AddExtraIDETargets()
}
}
-void cmGlobalXCodeGenerator::ComputeTargetOrder()
-{
- size_t index = 0;
- auto const& lgens = this->GetLocalGenerators();
- for (auto const& lgen : lgens) {
- const auto& targets = lgen->GetGeneratorTargets();
- for (const auto& gt : targets) {
- this->ComputeTargetOrder(gt.get(), index);
- }
- }
- assert(index == this->TargetOrderIndex.size());
-}
-
-void cmGlobalXCodeGenerator::ComputeTargetOrder(cmGeneratorTarget const* gt,
- size_t& index)
-{
- std::map<cmGeneratorTarget const*, size_t>::value_type value(gt, 0);
- auto insertion = this->TargetOrderIndex.insert(value);
- if (!insertion.second) {
- return;
- }
- auto entry = insertion.first;
-
- auto& deps = this->GetTargetDirectDepends(gt);
- for (auto& d : deps) {
- this->ComputeTargetOrder(d, index);
- }
-
- entry->second = index++;
-}
-
void cmGlobalXCodeGenerator::Generate()
{
this->cmGlobalGenerator::Generate();
@@ -462,8 +431,6 @@ void cmGlobalXCodeGenerator::Generate()
return;
}
- this->ComputeTargetOrder();
-
for (auto keyVal : this->ProjectMap) {
cmLocalGenerator* root = keyVal.second[0];
@@ -1243,12 +1210,8 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets(
cmLocalGenerator* gen, std::vector<cmXCodeObject*>& targets)
{
this->SetCurrentLocalGenerator(gen);
- std::vector<cmGeneratorTarget*> gts;
- cm::append(gts, this->CurrentLocalGenerator->GetGeneratorTargets());
- std::sort(gts.begin(), gts.end(),
- [this](cmGeneratorTarget const* l, cmGeneratorTarget const* r) {
- return this->TargetOrderIndex[l] < this->TargetOrderIndex[r];
- });
+ std::vector<cmGeneratorTarget*> gts =
+ this->GetLocalGeneratorTargetsInOrder(gen);
for (auto gtgt : gts) {
if (!this->CreateXCodeTarget(gtgt, targets)) {
return false;
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index c9f9926..c7524e8 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -115,8 +115,6 @@ public:
protected:
void AddExtraIDETargets() override;
- void ComputeTargetOrder();
- void ComputeTargetOrder(cmGeneratorTarget const* gt, size_t& index);
void Generate() override;
private:
@@ -303,7 +301,6 @@ private:
std::string ObjectDirArch;
std::string SystemName;
std::string GeneratorToolset;
- std::map<cmGeneratorTarget const*, size_t> TargetOrderIndex;
std::vector<std::string> EnabledLangs;
std::map<cmGeneratorTarget const*, std::set<cmSourceFile const*>>
CommandsVisited;