cmGlobalVisualStudio7Generator: Factor target collection out of write method

This commit is contained in:
Brad King
2025-08-29 14:54:16 -04:00
parent 5582eb292e
commit 6ae4ed30d9
4 changed files with 17 additions and 14 deletions

View File

@@ -25,7 +25,7 @@ cmGlobalVisualStudio71Generator::cmGlobalVisualStudio71Generator(cmake* cm)
void cmGlobalVisualStudio71Generator::WriteSLNFile(
std::ostream& fout, cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators)
OrderedTargetDependSet const& orderedProjectTargets)
{
std::vector<std::string> configs =
root->GetMakefile()->GetGeneratorConfigs(cmMakefile::ExcludeEmptyConfig);
@@ -33,14 +33,6 @@ void cmGlobalVisualStudio71Generator::WriteSLNFile(
// Write out the header for a SLN file
this->WriteSLNHeader(fout);
// 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));
// 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.

View File

@@ -28,8 +28,9 @@ public:
cmGlobalVisualStudio71Generator(cmake* cm);
protected:
void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators) override;
void WriteSLNFile(
std::ostream& fout, cmLocalGenerator* root,
OrderedTargetDependSet const& orderedProjectTargets) override;
virtual void WriteSolutionConfigurations(
std::ostream& fout, std::vector<std::string> const& configs);
void WriteProject(std::ostream& fout, std::string const& name,

View File

@@ -316,13 +316,22 @@ void cmGlobalVisualStudio7Generator::OutputSLNFile(
if (generators.empty()) {
return;
}
// 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));
std::string fname = GetSLNFile(root);
cmGeneratedFileStream fout(fname);
fout.SetCopyIfDifferent(true);
if (!fout) {
return;
}
this->WriteSLNFile(fout, root, generators);
this->WriteSLNFile(fout, root, orderedProjectTargets);
if (fout.Close()) {
this->FileReplacedDuringGenerate(fname);
}

View File

@@ -141,8 +141,9 @@ protected:
virtual void OutputSLNFile(cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators);
virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators) = 0;
virtual void WriteSLNFile(
std::ostream& fout, cmLocalGenerator* root,
OrderedTargetDependSet const& orderedProjectTargets) = 0;
virtual void WriteProject(std::ostream& fout, std::string const& name,
std::string const& path,
cmGeneratorTarget const* t) = 0;