mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-30 19:19:32 -05:00
VS: Refactor solution folder creation
* Add cmVisualStudioFolder struct containing names of projects within that folder. * Separate folder creation out of WriteTargetsToSolution into a new CreateSolutionFolders function.
This commit is contained in:
@@ -375,6 +375,40 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmVisualStudioFolder* cmGlobalVisualStudio7Generator::CreateSolutionFolders(
|
||||||
|
const std::string& path)
|
||||||
|
{
|
||||||
|
if (path.empty()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> tokens =
|
||||||
|
cmSystemTools::SplitString(path, '/', false);
|
||||||
|
|
||||||
|
std::string cumulativePath;
|
||||||
|
|
||||||
|
for (std::string const& iter : tokens) {
|
||||||
|
if (iter.empty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cumulativePath.empty()) {
|
||||||
|
cumulativePath = cmStrCat("CMAKE_FOLDER_GUID_", iter);
|
||||||
|
} else {
|
||||||
|
this->VisualStudioFolders[cumulativePath].Projects.insert(
|
||||||
|
cmStrCat(cumulativePath, '/', iter));
|
||||||
|
|
||||||
|
cumulativePath = cmStrCat(cumulativePath, '/', iter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cumulativePath.empty()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return &this->VisualStudioFolders[cumulativePath];
|
||||||
|
}
|
||||||
|
|
||||||
void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
|
void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
|
||||||
std::ostream& fout, cmLocalGenerator* root,
|
std::ostream& fout, cmLocalGenerator* root,
|
||||||
OrderedTargetDependSet const& projectTargets)
|
OrderedTargetDependSet const& projectTargets)
|
||||||
@@ -421,31 +455,11 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
|
|||||||
// Create "solution folder" information from FOLDER target property
|
// Create "solution folder" information from FOLDER target property
|
||||||
//
|
//
|
||||||
if (written && this->UseFolderProperty()) {
|
if (written && this->UseFolderProperty()) {
|
||||||
const std::string targetFolder = target->GetEffectiveFolderName();
|
cmVisualStudioFolder* folder =
|
||||||
if (!targetFolder.empty()) {
|
this->CreateSolutionFolders(target->GetEffectiveFolderName());
|
||||||
std::vector<std::string> tokens =
|
|
||||||
cmSystemTools::SplitString(targetFolder, '/', false);
|
|
||||||
|
|
||||||
std::string cumulativePath;
|
if (folder != nullptr) {
|
||||||
|
folder->Projects.insert(target->GetName());
|
||||||
for (std::string const& iter : tokens) {
|
|
||||||
if (iter.empty()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cumulativePath.empty()) {
|
|
||||||
cumulativePath = cmStrCat("CMAKE_FOLDER_GUID_", iter);
|
|
||||||
} else {
|
|
||||||
VisualStudioFolders[cumulativePath].insert(
|
|
||||||
cmStrCat(cumulativePath, '/', iter));
|
|
||||||
|
|
||||||
cumulativePath = cmStrCat(cumulativePath, '/', iter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!cumulativePath.empty()) {
|
|
||||||
VisualStudioFolders[cumulativePath].insert(target->GetName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -477,7 +491,7 @@ void cmGlobalVisualStudio7Generator::WriteFoldersContent(std::ostream& fout)
|
|||||||
std::string key(iter.first);
|
std::string key(iter.first);
|
||||||
std::string guidParent(this->GetGUID(key));
|
std::string guidParent(this->GetGUID(key));
|
||||||
|
|
||||||
for (std::string const& it : iter.second) {
|
for (std::string const& it : iter.second.Projects) {
|
||||||
std::string const& value(it);
|
std::string const& value(it);
|
||||||
std::string guid(this->GetGUID(value));
|
std::string guid(this->GetGUID(value));
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,11 @@ class cmake;
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
class BT;
|
class BT;
|
||||||
|
|
||||||
|
struct cmVisualStudioFolder
|
||||||
|
{
|
||||||
|
std::set<std::string> Projects;
|
||||||
|
};
|
||||||
|
|
||||||
/** \class cmGlobalVisualStudio7Generator
|
/** \class cmGlobalVisualStudio7Generator
|
||||||
* \brief Write a Unix makefiles.
|
* \brief Write a Unix makefiles.
|
||||||
*
|
*
|
||||||
@@ -154,6 +159,8 @@ protected:
|
|||||||
virtual void WriteSLNFooter(std::ostream& fout);
|
virtual void WriteSLNFooter(std::ostream& fout);
|
||||||
std::string WriteUtilityDepend(const cmGeneratorTarget* target) override;
|
std::string WriteUtilityDepend(const cmGeneratorTarget* target) override;
|
||||||
|
|
||||||
|
cmVisualStudioFolder* CreateSolutionFolders(const std::string& path);
|
||||||
|
|
||||||
virtual void WriteTargetsToSolution(
|
virtual void WriteTargetsToSolution(
|
||||||
std::ostream& fout, cmLocalGenerator* root,
|
std::ostream& fout, cmLocalGenerator* root,
|
||||||
OrderedTargetDependSet const& projectTargets);
|
OrderedTargetDependSet const& projectTargets);
|
||||||
@@ -178,7 +185,7 @@ protected:
|
|||||||
|
|
||||||
virtual void WriteFolders(std::ostream& fout);
|
virtual void WriteFolders(std::ostream& fout);
|
||||||
virtual void WriteFoldersContent(std::ostream& fout);
|
virtual void WriteFoldersContent(std::ostream& fout);
|
||||||
std::map<std::string, std::set<std::string>> VisualStudioFolders;
|
std::map<std::string, cmVisualStudioFolder> VisualStudioFolders;
|
||||||
|
|
||||||
// Set during OutputSLNFile with the name of the current project.
|
// Set during OutputSLNFile with the name of the current project.
|
||||||
// There is one SLN file per project.
|
// There is one SLN file per project.
|
||||||
|
|||||||
Reference in New Issue
Block a user