Greetings,
I'm currently attempting a patch for
http://www.cmake.org/Bug/view.php?id=15578 and trying to do it how Brad
suggests. So far, I've propagated a string down into the comparision
functor. This string comes from
cmGlobalVisiaulStudioGenerator::GetStartupProjectName(). However, I'm
having trouble implementing this method.
My plan is for it to simply pull a directory property called,
"VS_STARTUP_PROJECT". However, I don't see how to access directory
properties from cmGlobalVisualStudioGenerator. They seem to be
available from a cmLocalGenerator but not cmGlobalGenerator.
Attached is the patch so far.
Any help would be appreciated. Am I headed in the right direction?
Thanks
Source/cmGlobalVisualStudio6Generator.cxx | 2 +-
Source/cmGlobalVisualStudio71Generator.cxx | 2 +-
Source/cmGlobalVisualStudio7Generator.cxx | 2 +-
Source/cmGlobalVisualStudio8Generator.cxx | 2 +-
Source/cmGlobalVisualStudioGenerator.cxx | 28 +++++++++++++++++++++++-----
Source/cmGlobalVisualStudioGenerator.h | 9 +++++++--
Source/cmVisualStudio10TargetGenerator.cxx | 2 +-
7 files changed, 35 insertions(+), 12 deletions(-)
diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx
index 632141a..2ab9e77 100644
--- a/Source/cmGlobalVisualStudio6Generator.cxx
+++ b/Source/cmGlobalVisualStudio6Generator.cxx
@@ -218,7 +218,7 @@ void cmGlobalVisualStudio6Generator
TargetDependSet projectTargets;
TargetDependSet originalTargets;
this->GetTargetSets(projectTargets, originalTargets, root, generators);
- OrderedTargetDependSet orderedProjectTargets(projectTargets);
+ OrderedTargetDependSet orderedProjectTargets(projectTargets, this->GetStartupProjectName());
for(OrderedTargetDependSet::const_iterator
tt = orderedProjectTargets.begin();
diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx
index 1ab4c9c..cb8bde4 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, this->GetStartupProjectName());
this->WriteTargetsToSolution(fout, root, orderedProjectTargets);
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index 4dd54d0..72178e3 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -570,7 +570,7 @@ void cmGlobalVisualStudio7Generator
TargetDependSet projectTargets;
TargetDependSet originalTargets;
this->GetTargetSets(projectTargets, originalTargets, root, generators);
- OrderedTargetDependSet orderedProjectTargets(projectTargets);
+ OrderedTargetDependSet orderedProjectTargets(projectTargets, this->GetStartupProjectName());
this->WriteTargetsToSolution(fout, root, orderedProjectTargets);
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index a3ebc61..57f9d08 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -447,7 +447,7 @@ void cmGlobalVisualStudio8Generator::WriteProjectDepends(
std::ostream& fout, const std::string&, const char*, cmTarget const& t)
{
TargetDependSet const& unordered = this->GetTargetDirectDepends(t);
- OrderedTargetDependSet depends(unordered);
+ OrderedTargetDependSet depends(unordered, this->GetStartupProjectName());
for(OrderedTargetDependSet::const_iterator i = depends.begin();
i != depends.end(); ++i)
{
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index 585d19a..50ce22c 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -507,6 +507,16 @@ cmGlobalVisualStudioGenerator::GetUtilityDepend(cmTarget const* target)
}
//----------------------------------------------------------------------------
+std::string
+cmGlobalVisualStudioGenerator::GetStartupProjectName() const
+{
+ // TODO how to get directory property named "VS_STARTUP_PROJECT" here?
+
+ // default to this if the directory property is not specified.
+ return this->GetAllTargetName();
+}
+
+//----------------------------------------------------------------------------
#include <windows.h>
//----------------------------------------------------------------------------
@@ -841,16 +851,22 @@ cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target)
}
//----------------------------------------------------------------------------
+cmGlobalVisualStudioGenerator::TargetCompare
+::TargetCompare()
+: FirstProject("ALL_BUILD")
+{
+}
+
bool
cmGlobalVisualStudioGenerator::TargetCompare
::operator()(cmTarget const* l, cmTarget const* r) const
{
- // Make sure ALL_BUILD is first so it is the default active project.
- if(r->GetName() == "ALL_BUILD")
+ // Make sure the user-specified firstProject is first so it is the default active project.
+ if(r->GetName() == FirstProject)
{
return false;
}
- if(l->GetName() == "ALL_BUILD")
+ if(l->GetName() == FirstProject)
{
return true;
}
@@ -859,15 +875,17 @@ cmGlobalVisualStudioGenerator::TargetCompare
//----------------------------------------------------------------------------
cmGlobalVisualStudioGenerator::OrderedTargetDependSet
-::OrderedTargetDependSet(TargetDependSet const& targets)
+::OrderedTargetDependSet(TargetDependSet const& targets, const std::string& firstProject)
{
+ this->key_comp().FirstProject = firstProject;
this->insert(targets.begin(), targets.end());
}
//----------------------------------------------------------------------------
cmGlobalVisualStudioGenerator::OrderedTargetDependSet
-::OrderedTargetDependSet(TargetSet const& targets)
+::OrderedTargetDependSet(TargetSet const& targets, const std::string& firstProject)
{
+ this->key_comp().FirstProject = firstProject;
this->insert(targets.begin(), targets.end());
}
diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h
index 69b4564..2815264 100644
--- a/Source/cmGlobalVisualStudioGenerator.h
+++ b/Source/cmGlobalVisualStudioGenerator.h
@@ -91,6 +91,8 @@ public:
class TargetSet: public std::set<cmTarget const*> {};
struct TargetCompare
{
+ std::string FirstProject;
+ TargetCompare();
bool operator()(cmTarget const* l, cmTarget const* r) const;
};
class OrderedTargetDependSet;
@@ -102,6 +104,9 @@ public:
const std::string& config) const;
void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
+
+ std::string GetStartupProjectName() const;
+
protected:
virtual void Generate();
@@ -149,8 +154,8 @@ class cmGlobalVisualStudioGenerator::OrderedTargetDependSet:
public:
typedef cmGlobalGenerator::TargetDependSet TargetDependSet;
typedef cmGlobalVisualStudioGenerator::TargetSet TargetSet;
- OrderedTargetDependSet(TargetDependSet const&);
- OrderedTargetDependSet(TargetSet const&);
+ OrderedTargetDependSet(TargetDependSet const&, const std::string&);
+ OrderedTargetDependSet(TargetSet const&, const std::string&);
};
#endif
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 5dfdb14..0b2ef33 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -2670,7 +2670,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences()
= this->GlobalGenerator->GetTargetDirectDepends(*this->Target);
typedef cmGlobalVisualStudioGenerator::OrderedTargetDependSet
OrderedTargetDependSet;
- OrderedTargetDependSet depends(unordered);
+ OrderedTargetDependSet depends(unordered, this->GlobalGenerator->GetStartupProjectName());
this->WriteString("<ItemGroup>\n", 1);
for( OrderedTargetDependSet::const_iterator i = depends.begin();
i != depends.end(); ++i)
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers