1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 10:47:59 +08:00

cmGlobalVisualStudioGenerator: Consolidate solution generation methods

This commit is contained in:
Brad King
2025-09-16 11:27:38 -04:00
parent 6b1c101410
commit 6a77c80834
2 changed files with 11 additions and 18 deletions

View File

@@ -39,7 +39,7 @@
#include "cmake.h"
namespace {
std::string GetSLNFile(cmLocalGenerator* root)
std::string GetSLNFile(cmLocalGenerator const* root)
{
return cmStrCat(root->GetCurrentBinaryDirectory(), '/',
root->GetProjectName(), ".sln");
@@ -1099,7 +1099,7 @@ void cmGlobalVisualStudioGenerator::Generate()
// Now write out the VS Solution files.
for (auto& it : this->ProjectMap) {
this->OutputSLNFile(it.second[0], it.second);
this->GenerateSolution(it.second[0], it.second);
}
// If any solution or project files changed during the generation,
@@ -1131,8 +1131,9 @@ void cmGlobalVisualStudioGenerator::Generate()
}
}
void cmGlobalVisualStudioGenerator::OutputSLNFile(
cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators)
void cmGlobalVisualStudioGenerator::GenerateSolution(
cmLocalGenerator const* root,
std::vector<cmLocalGenerator*> const& generators)
{
if (generators.empty()) {
return;
@@ -1149,16 +1150,11 @@ void cmGlobalVisualStudioGenerator::OutputSLNFile(
if (!fout) {
return;
}
this->WriteSLNFile(fout, root, projectTargets);
cm::VS::Solution const solution = this->CreateSolution(root, projectTargets);
WriteSln(fout, solution);
if (fout.Close()) {
this->FileReplacedDuringGenerate(fname);
}
}
void cmGlobalVisualStudioGenerator::WriteSLNFile(
std::ostream& fout, cmLocalGenerator* root,
TargetDependSet const& projectTargets) const
{
cm::VS::Solution const solution = this->CreateSolution(root, projectTargets);
WriteSln(fout, solution);
}

View File

@@ -198,11 +198,8 @@ protected:
void Generate() override;
void OutputSLNFile(cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators);
void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root,
TargetDependSet const& projectTargets) const;
void GenerateSolution(cmLocalGenerator const* root,
std::vector<cmLocalGenerator*> const& generators);
private:
virtual std::string GetVSMakeProgram() = 0;