Merge topic 'vs-target-ordering'

40c7b461 VS: Fix rebuild with regeneration after input CMake code change (#15754)
03bfe71a VS: Refactor target ordering logic
This commit is contained in:
Brad King 2015-09-23 09:23:01 -04:00 committed by CMake Topic Stage
commit c3b3284c93
7 changed files with 26 additions and 14 deletions

View File

@ -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();

View File

@ -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);

View File

@ -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);

View File

@ -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)
{

View File

@ -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)

View File

@ -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

View File

@ -2849,7 +2849,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences()
= this->GlobalGenerator->GetTargetDirectDepends(this->GeneratorTarget);
typedef cmGlobalVisualStudioGenerator::OrderedTargetDependSet
OrderedTargetDependSet;
OrderedTargetDependSet depends(unordered);
OrderedTargetDependSet depends(unordered, CMAKE_CHECK_BUILD_SYSTEM_TARGET);
this->WriteString("<ItemGroup>\n", 1);
for( OrderedTargetDependSet::const_iterator i = depends.begin();
i != depends.end(); ++i)