summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-09-22 14:14:49 (GMT)
committerBrad King <brad.king@kitware.com>2015-09-22 14:25:58 (GMT)
commit03bfe71ae055ed9e5dbeb619967ee44e5f555459 (patch)
treefd1344e66b17d48cc94e4c3901373e657d67bbd6
parentdce7d8befb94e2531d6c7d68b78b4b4a67ca024f (diff)
downloadCMake-03bfe71ae055ed9e5dbeb619967ee44e5f555459.zip
CMake-03bfe71ae055ed9e5dbeb619967ee44e5f555459.tar.gz
CMake-03bfe71ae055ed9e5dbeb619967ee44e5f555459.tar.bz2
VS: Refactor target ordering logic
Refactor cmGlobalVisualStudioGenerator::TargetCompare to store the name of the target that should come first instead of hard-coding "ALL_BUILD". Update client sites to specify "ALL_BUILD" when ordering for .sln files and an empty string otherwise (in cases when "ALL_BUILD" should not be encountered anyway).
-rw-r--r--Source/cmGlobalVisualStudio6Generator.cxx2
-rw-r--r--Source/cmGlobalVisualStudio71Generator.cxx2
-rw-r--r--Source/cmGlobalVisualStudio7Generator.cxx2
-rw-r--r--Source/cmGlobalVisualStudio8Generator.cxx2
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx18
-rw-r--r--Source/cmGlobalVisualStudioGenerator.h12
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx2
7 files changed, 26 insertions, 14 deletions
diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx
index df49948..14de698 100644
--- a/Source/cmGlobalVisualStudio6Generator.cxx
+++ b/Source/cmGlobalVisualStudio6Generator.cxx
@@ -217,7 +217,7 @@ void cmGlobalVisualStudio6Generator
TargetDependSet projectTargets;
TargetDependSet originalTargets;
this->GetTargetSets(projectTargets, originalTargets, root, generators);
- OrderedTargetDependSet orderedProjectTargets(projectTargets);
+ OrderedTargetDependSet orderedProjectTargets(projectTargets, "ALL_BUILD");
for(OrderedTargetDependSet::const_iterator
tt = orderedProjectTargets.begin();
diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx
index 607642c..b913afc 100644
--- a/Source/cmGlobalVisualStudio71Generator.cxx
+++ b/Source/cmGlobalVisualStudio71Generator.cxx
@@ -94,7 +94,7 @@ void cmGlobalVisualStudio71Generator
TargetDependSet projectTargets;
TargetDependSet originalTargets;
this->GetTargetSets(projectTargets, originalTargets, root, generators);
- OrderedTargetDependSet orderedProjectTargets(projectTargets);
+ OrderedTargetDependSet orderedProjectTargets(projectTargets, "ALL_BUILD");
this->WriteTargetsToSolution(fout, root, orderedProjectTargets);
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index 0175062..05da022 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -568,7 +568,7 @@ void cmGlobalVisualStudio7Generator
TargetDependSet projectTargets;
TargetDependSet originalTargets;
this->GetTargetSets(projectTargets, originalTargets, root, generators);
- OrderedTargetDependSet orderedProjectTargets(projectTargets);
+ OrderedTargetDependSet orderedProjectTargets(projectTargets, "ALL_BUILD");
this->WriteTargetsToSolution(fout, root, orderedProjectTargets);
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index 28f0425..70c00e9 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -449,7 +449,7 @@ void cmGlobalVisualStudio8Generator::WriteProjectDepends(
{
cmGeneratorTarget* gt = this->GetGeneratorTarget(&t);
TargetDependSet const& unordered = this->GetTargetDirectDepends(gt);
- OrderedTargetDependSet depends(unordered);
+ OrderedTargetDependSet depends(unordered, std::string());
for(OrderedTargetDependSet::const_iterator i = depends.begin();
i != depends.end(); ++i)
{
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index 2bf04b4..e7cc8ff 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -864,28 +864,34 @@ bool
cmGlobalVisualStudioGenerator::TargetCompare
::operator()(cmGeneratorTarget const* l, cmGeneratorTarget const* r) const
{
- // Make sure ALL_BUILD is first so it is the default active project.
- if(r->GetName() == "ALL_BUILD")
+ // Make sure a given named target is ordered first,
+ // e.g. to set ALL_BUILD as the default active project.
+ // When the empty string is named this is a no-op.
+ if (r->GetName() == this->First)
{
return false;
}
- if(l->GetName() == "ALL_BUILD")
+ if (l->GetName() == this->First)
{
return true;
}
- return strcmp(l->GetName().c_str(), r->GetName().c_str()) < 0;
+ return l->GetName() < r->GetName();
}
//----------------------------------------------------------------------------
cmGlobalVisualStudioGenerator::OrderedTargetDependSet
-::OrderedTargetDependSet(TargetDependSet const& targets)
+::OrderedTargetDependSet(TargetDependSet const& targets,
+ std::string const& first):
+ derived(TargetCompare(first))
{
this->insert(targets.begin(), targets.end());
}
//----------------------------------------------------------------------------
cmGlobalVisualStudioGenerator::OrderedTargetDependSet
-::OrderedTargetDependSet(TargetSet const& targets)
+::OrderedTargetDependSet(TargetSet const& targets,
+ std::string const& first):
+ derived(TargetCompare(first))
{
for (TargetSet::const_iterator it = targets.begin();
it != targets.end(); ++it)
diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h
index 64440ad..c940eb3 100644
--- a/Source/cmGlobalVisualStudioGenerator.h
+++ b/Source/cmGlobalVisualStudioGenerator.h
@@ -89,8 +89,11 @@ public:
virtual bool TargetsWindowsCE() const { return false; }
class TargetSet: public std::set<cmTarget const*> {};
- struct TargetCompare
+ class TargetCompare
{
+ std::string First;
+ public:
+ TargetCompare(std::string const& first): First(first) {}
bool operator()(cmGeneratorTarget const* l,
cmGeneratorTarget const* r) const;
};
@@ -151,11 +154,14 @@ class cmGlobalVisualStudioGenerator::OrderedTargetDependSet:
public std::multiset<cmTargetDepend,
cmGlobalVisualStudioGenerator::TargetCompare>
{
+ typedef std::multiset<cmTargetDepend,
+ cmGlobalVisualStudioGenerator::TargetCompare>
+ derived;
public:
typedef cmGlobalGenerator::TargetDependSet TargetDependSet;
typedef cmGlobalVisualStudioGenerator::TargetSet TargetSet;
- OrderedTargetDependSet(TargetDependSet const&);
- OrderedTargetDependSet(TargetSet const&);
+ OrderedTargetDependSet(TargetDependSet const&, std::string const& first);
+ OrderedTargetDependSet(TargetSet const&, std::string const& first);
};
#endif
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index cb5048d..b91ae11 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -2849,7 +2849,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences()
= this->GlobalGenerator->GetTargetDirectDepends(this->GeneratorTarget);
typedef cmGlobalVisualStudioGenerator::OrderedTargetDependSet
OrderedTargetDependSet;
- OrderedTargetDependSet depends(unordered);
+ OrderedTargetDependSet depends(unordered, std::string());
this->WriteString("<ItemGroup>\n", 1);
for( OrderedTargetDependSet::const_iterator i = depends.begin();
i != depends.end(); ++i)