|
@@ -299,8 +299,11 @@ void cmGlobalVisualStudio7Generator::Generate()
|
|
|
// first do the superclass method
|
|
|
this->cmGlobalVisualStudioGenerator::Generate();
|
|
|
|
|
|
- // Now write out the DSW
|
|
|
- this->OutputSLNFile();
|
|
|
+ // Now write out the VS Solution files.
|
|
|
+ for (auto& it : this->ProjectMap) {
|
|
|
+ this->OutputSLNFile(it.second[0], it.second);
|
|
|
+ }
|
|
|
+
|
|
|
// If any solution or project files changed during the generation,
|
|
|
// tell Visual Studio to reload them...
|
|
|
if (!cmSystemTools::GetErrorOccurredFlag() &&
|
|
@@ -336,30 +339,33 @@ void cmGlobalVisualStudio7Generator::OutputSLNFile(
|
|
|
if (generators.empty()) {
|
|
|
return;
|
|
|
}
|
|
|
- this->CurrentProject = root->GetProjectName();
|
|
|
+
|
|
|
+ // Collect all targets under this root generator and the transitive
|
|
|
+ // closure of their dependencies.
|
|
|
+ TargetDependSet projectTargets;
|
|
|
+ TargetDependSet originalTargets;
|
|
|
+ this->GetTargetSets(projectTargets, originalTargets, root, generators);
|
|
|
+ OrderedTargetDependSet orderedProjectTargets(
|
|
|
+ projectTargets, this->GetStartupProjectName(root));
|
|
|
+
|
|
|
+ VSFolders vsFolders = this->CreateSolutionFolders(orderedProjectTargets);
|
|
|
+ this->AddSolutionItems(root, vsFolders);
|
|
|
+
|
|
|
std::string fname = GetSLNFile(root);
|
|
|
cmGeneratedFileStream fout(fname);
|
|
|
fout.SetCopyIfDifferent(true);
|
|
|
if (!fout) {
|
|
|
return;
|
|
|
}
|
|
|
- this->WriteSLNFile(fout, root, generators);
|
|
|
+ this->WriteSLNFile(fout, root, orderedProjectTargets, vsFolders);
|
|
|
if (fout.Close()) {
|
|
|
this->FileReplacedDuringGenerate(fname);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// output the SLN file
|
|
|
-void cmGlobalVisualStudio7Generator::OutputSLNFile()
|
|
|
-{
|
|
|
- for (auto& it : this->ProjectMap) {
|
|
|
- this->OutputSLNFile(it.second[0], it.second);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
|
|
|
std::ostream& fout, std::vector<std::string> const& configs,
|
|
|
- OrderedTargetDependSet const& projectTargets)
|
|
|
+ OrderedTargetDependSet const& projectTargets) const
|
|
|
{
|
|
|
// loop over again and write out configurations for each target
|
|
|
// in the solution
|
|
@@ -394,7 +400,29 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-cmVisualStudioFolder* cmGlobalVisualStudio7Generator::CreateSolutionFolders(
|
|
|
+cmGlobalVisualStudio7Generator::VSFolders
|
|
|
+cmGlobalVisualStudio7Generator::CreateSolutionFolders(
|
|
|
+ OrderedTargetDependSet const& orderedProjectTargets)
|
|
|
+{
|
|
|
+ VSFolders vsFolders;
|
|
|
+ if (!this->UseFolderProperty()) {
|
|
|
+ return vsFolders;
|
|
|
+ }
|
|
|
+ for (cmGeneratorTarget const* target : orderedProjectTargets) {
|
|
|
+ if (this->IsInSolution(target) &&
|
|
|
+ (target->GetProperty("EXTERNAL_MSPROJECT") ||
|
|
|
+ target->GetProperty("GENERATOR_FILE_NAME"))) {
|
|
|
+ // Create "solution folder" information from FOLDER target property
|
|
|
+ if (cmVisualStudioFolder* folder =
|
|
|
+ vsFolders.Create(target->GetEffectiveFolderName())) {
|
|
|
+ folder->Projects.insert(target->GetName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return vsFolders;
|
|
|
+}
|
|
|
+
|
|
|
+cmVisualStudioFolder* cmGlobalVisualStudio7Generator::VSFolders::Create(
|
|
|
std::string const& path)
|
|
|
{
|
|
|
if (path.empty()) {
|
|
@@ -414,7 +442,7 @@ cmVisualStudioFolder* cmGlobalVisualStudio7Generator::CreateSolutionFolders(
|
|
|
if (cumulativePath.empty()) {
|
|
|
cumulativePath = cmStrCat("CMAKE_FOLDER_GUID_", iter);
|
|
|
} else {
|
|
|
- this->VisualStudioFolders[cumulativePath].Projects.insert(
|
|
|
+ this->Folders[cumulativePath].Projects.insert(
|
|
|
cmStrCat(cumulativePath, '/', iter));
|
|
|
|
|
|
cumulativePath = cmStrCat(cumulativePath, '/', iter);
|
|
@@ -425,15 +453,13 @@ cmVisualStudioFolder* cmGlobalVisualStudio7Generator::CreateSolutionFolders(
|
|
|
return nullptr;
|
|
|
}
|
|
|
|
|
|
- return &this->VisualStudioFolders[cumulativePath];
|
|
|
+ return &this->Folders[cumulativePath];
|
|
|
}
|
|
|
|
|
|
void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
|
|
|
std::ostream& fout, cmLocalGenerator* root,
|
|
|
- OrderedTargetDependSet const& projectTargets)
|
|
|
+ OrderedTargetDependSet const& projectTargets) const
|
|
|
{
|
|
|
- VisualStudioFolders.clear();
|
|
|
-
|
|
|
std::vector<std::string> configs =
|
|
|
root->GetMakefile()->GetGeneratorConfigs(cmMakefile::ExcludeEmptyConfig);
|
|
|
|
|
@@ -441,12 +467,6 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
|
|
|
if (!this->IsInSolution(target)) {
|
|
|
continue;
|
|
|
}
|
|
|
- bool written = false;
|
|
|
-
|
|
|
- for (auto const& c : configs) {
|
|
|
- target->CheckCxxModuleStatus(c);
|
|
|
- }
|
|
|
-
|
|
|
// handle external vc project files
|
|
|
cmValue expath = target->GetProperty("EXTERNAL_MSPROJECT");
|
|
|
if (expath) {
|
|
@@ -456,7 +476,6 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
|
|
|
this->WriteExternalProject(fout, project, location,
|
|
|
target->GetProperty("VS_PROJECT_TYPE"),
|
|
|
target->GetUtilities());
|
|
|
- written = true;
|
|
|
} else {
|
|
|
cmValue vcprojName = target->GetProperty("GENERATOR_FILE_NAME");
|
|
|
if (vcprojName) {
|
|
@@ -467,28 +486,17 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
|
|
|
dir.clear(); // msbuild cannot handle ".\" prefix
|
|
|
}
|
|
|
this->WriteProject(fout, *vcprojName, dir, target);
|
|
|
- written = true;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // Create "solution folder" information from FOLDER target property
|
|
|
- //
|
|
|
- if (written && this->UseFolderProperty()) {
|
|
|
- cmVisualStudioFolder* folder =
|
|
|
- this->CreateSolutionFolders(target->GetEffectiveFolderName());
|
|
|
-
|
|
|
- if (folder != nullptr) {
|
|
|
- folder->Projects.insert(target->GetName());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void cmGlobalVisualStudio7Generator::WriteFolders(std::ostream& fout)
|
|
|
+void cmGlobalVisualStudio7Generator::WriteFolders(
|
|
|
+ std::ostream& fout, VSFolders const& vsFolders) const
|
|
|
{
|
|
|
cm::string_view const prefix = "CMAKE_FOLDER_GUID_";
|
|
|
std::string guidProjectTypeFolder = "2150E333-8FDC-42A3-9474-1A3956D46DE8";
|
|
|
- for (auto const& iter : VisualStudioFolders) {
|
|
|
+ for (auto const& iter : vsFolders.Folders) {
|
|
|
std::string fullName = iter.first;
|
|
|
std::string guid = this->GetGUID(fullName);
|
|
|
|
|
@@ -510,9 +518,10 @@ void cmGlobalVisualStudio7Generator::WriteFolders(std::ostream& fout)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void cmGlobalVisualStudio7Generator::WriteFoldersContent(std::ostream& fout)
|
|
|
+void cmGlobalVisualStudio7Generator::WriteFoldersContent(
|
|
|
+ std::ostream& fout, VSFolders const& vsFolders) const
|
|
|
{
|
|
|
- for (auto const& iter : VisualStudioFolders) {
|
|
|
+ for (auto const& iter : vsFolders.Folders) {
|
|
|
std::string key(iter.first);
|
|
|
std::string guidParent(this->GetGUID(key));
|
|
|
|
|
@@ -526,7 +535,7 @@ void cmGlobalVisualStudio7Generator::WriteFoldersContent(std::ostream& fout)
|
|
|
}
|
|
|
|
|
|
std::string cmGlobalVisualStudio7Generator::ConvertToSolutionPath(
|
|
|
- std::string const& path)
|
|
|
+ std::string const& path) const
|
|
|
{
|
|
|
// Convert to backslashes. Do not use ConvertToOutputPath because
|
|
|
// we will add quoting ourselves, and we know these projects always
|
|
@@ -540,7 +549,7 @@ std::string cmGlobalVisualStudio7Generator::ConvertToSolutionPath(
|
|
|
}
|
|
|
|
|
|
void cmGlobalVisualStudio7Generator::WriteSLNGlobalSections(
|
|
|
- std::ostream& fout, cmLocalGenerator* root)
|
|
|
+ std::ostream& fout, cmLocalGenerator* root) const
|
|
|
{
|
|
|
std::string const guid =
|
|
|
this->GetGUID(cmStrCat(root->GetProjectName(), ".sln"));
|
|
@@ -606,7 +615,7 @@ void cmGlobalVisualStudio7Generator::WriteSLNGlobalSections(
|
|
|
}
|
|
|
|
|
|
// Standard end of dsw file
|
|
|
-void cmGlobalVisualStudio7Generator::WriteSLNFooter(std::ostream& fout)
|
|
|
+void cmGlobalVisualStudio7Generator::WriteSLNFooter(std::ostream& fout) const
|
|
|
{
|
|
|
fout << "EndGlobal\n";
|
|
|
}
|
|
@@ -674,7 +683,8 @@ std::string cmGlobalVisualStudio7Generator::WriteUtilityDepend(
|
|
|
return pname;
|
|
|
}
|
|
|
|
|
|
-std::string cmGlobalVisualStudio7Generator::GetGUID(std::string const& name)
|
|
|
+std::string cmGlobalVisualStudio7Generator::GetGUID(
|
|
|
+ std::string const& name) const
|
|
|
{
|
|
|
std::string const& guidStoreName = cmStrCat(name, "_GUID_CMAKE");
|
|
|
if (cmValue storedGUID =
|
|
@@ -708,7 +718,7 @@ void cmGlobalVisualStudio7Generator::AppendDirectoryForConfig(
|
|
|
std::set<std::string> cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
|
|
|
std::vector<std::string> const& configs,
|
|
|
OrderedTargetDependSet const& projectTargets,
|
|
|
- cmGeneratorTarget const* target)
|
|
|
+ cmGeneratorTarget const* target) const
|
|
|
{
|
|
|
std::set<std::string> activeConfigs;
|
|
|
// if it is a utility target then only make it part of the
|
|
@@ -751,7 +761,8 @@ std::set<std::string> cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
|
|
|
}
|
|
|
|
|
|
bool cmGlobalVisualStudio7Generator::IsDependedOn(
|
|
|
- OrderedTargetDependSet const& projectTargets, cmGeneratorTarget const* gtIn)
|
|
|
+ OrderedTargetDependSet const& projectTargets,
|
|
|
+ cmGeneratorTarget const* gtIn) const
|
|
|
{
|
|
|
return std::any_of(projectTargets.begin(), projectTargets.end(),
|
|
|
[this, gtIn](cmTargetDepend const& l) {
|