summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-03-24 12:49:41 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2016-03-24 12:49:41 (GMT)
commit5b2acf6c1c904df96bd0031c9469e61118da5200 (patch)
treeaf7a870a3b4490f521d5d8c87a182d8f63930698 /Source
parent59f53f7422818f3ccad8518ab0863de6bb7fd293 (diff)
parentad140c6e1bb6eda5d17a199304578dbd92bedbad (diff)
downloadCMake-5b2acf6c1c904df96bd0031c9469e61118da5200.zip
CMake-5b2acf6c1c904df96bd0031c9469e61118da5200.tar.gz
CMake-5b2acf6c1c904df96bd0031c9469e61118da5200.tar.bz2
Merge topic 'vs-startup-project'
ad140c6e VS: Put ALL_BUILD in the PREDEFINED_TARGETS_FOLDER f069be05 VS: Fix default target support for targets nested inside a folder c05ea485 VS: Improve unit test macros 78ec0461 VS: Add option to choose the `.sln` startup project (#15578)
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGlobalVisualStudio71Generator.cxx22
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx34
-rw-r--r--Source/cmGlobalVisualStudioGenerator.h2
3 files changed, 49 insertions, 9 deletions
diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx
index 8227b82..7b51fdf 100644
--- a/Source/cmGlobalVisualStudio71Generator.cxx
+++ b/Source/cmGlobalVisualStudio71Generator.cxx
@@ -94,16 +94,34 @@ void cmGlobalVisualStudio71Generator
TargetDependSet projectTargets;
TargetDependSet originalTargets;
this->GetTargetSets(projectTargets, originalTargets, root, generators);
- OrderedTargetDependSet orderedProjectTargets(projectTargets, "ALL_BUILD");
+ OrderedTargetDependSet orderedProjectTargets(
+ projectTargets, this->GetStartupProjectName(root));
- this->WriteTargetsToSolution(fout, root, orderedProjectTargets);
+ // Generate the targets specification to a string. We will put this in
+ // the actual .sln file later. As a side effect, this method also
+ // populates the set of folders.
+ std::ostringstream targetsSlnString;
+ this->WriteTargetsToSolution(targetsSlnString, root, orderedProjectTargets);
+ // VS 7 does not support folders specified first.
+ if (this->GetVersion() <= VS71)
+ {
+ fout << targetsSlnString.str();
+ }
+
+ // Generate folder specification.
bool useFolderProperty = this->UseFolderProperty();
if (useFolderProperty)
{
this->WriteFolders(fout);
}
+ // Now write the actual target specification content.
+ if (this->GetVersion() > VS71)
+ {
+ fout << targetsSlnString.str();
+ }
+
// Write out the configurations information for the solution
fout << "Global\n";
// Write out the configurations for the solution
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index 00bb511..04146fb 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -89,19 +89,13 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets()
cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]);
gen[0]->AddGeneratorTarget(gt);
-#if 0
- // Can't activate this code because we want ALL_BUILD
- // selected as the default "startup project" when first
- // opened in Visual Studio... And if it's nested in a
- // folder, then that doesn't happen.
//
// Organize in the "predefined targets" folder:
//
- if (this->UseFolderProperty())
+ if (this->UseFolderProperty() && this->GetVersion() > VS71)
{
allBuild->SetProperty("FOLDER", this->GetPredefinedTargetsFolder());
}
-#endif
// Now make all targets depend on the ALL_BUILD target
for(std::vector<cmLocalGenerator*>::iterator i = gen.begin();
@@ -519,6 +513,32 @@ cmGlobalVisualStudioGenerator::GetUtilityDepend(
}
//----------------------------------------------------------------------------
+std::string
+cmGlobalVisualStudioGenerator::GetStartupProjectName(
+ cmLocalGenerator const* root) const
+{
+ const char* n = root->GetMakefile()->GetProperty("VS_STARTUP_PROJECT");
+ if (n && *n)
+ {
+ std::string startup = n;
+ if (this->FindTarget(startup))
+ {
+ return startup;
+ }
+ else
+ {
+ root->GetMakefile()->IssueMessage(
+ cmake::AUTHOR_WARNING,
+ "Directory property VS_STARTUP_PROJECT specifies target "
+ "'" + startup + "' that does not exist. Ignoring.");
+ }
+ }
+
+ // default, if not specified
+ return this->GetAllTargetName();
+}
+
+//----------------------------------------------------------------------------
#include <windows.h>
//----------------------------------------------------------------------------
diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h
index ac9111e..723a75f 100644
--- a/Source/cmGlobalVisualStudioGenerator.h
+++ b/Source/cmGlobalVisualStudioGenerator.h
@@ -106,6 +106,8 @@ public:
void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
+ std::string GetStartupProjectName(cmLocalGenerator const* root) const;
+
void AddSymbolExportCommand(
cmGeneratorTarget*, std::vector<cmCustomCommand>& commands,
std::string const& configName);