VS: Do not accumulate configurations globally (#15577)

Drop the VS >= 7 generator's global Configurations member and instead
lookup configurations using cmMakefile::GetConfigurations where needed.
This avoids accumulating all CMAKE_CONFIGURATION_TYPES values ever
encountered by a project() or enable_language() command and allows
the final value to be used in each directory.  We don't officially
support per-directory CMAKE_CONFIGURATION_TYPES values but we certainly
should not generate configurations not in the final value in the top
level directory.
This commit is contained in:
Brad King
2015-05-20 13:55:21 -04:00
parent 3541fc73a1
commit 2f4bb4e9b0
10 changed files with 119 additions and 176 deletions
+12 -7
View File
@@ -83,6 +83,9 @@ void cmGlobalVisualStudio71Generator
cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators)
{
std::vector<std::string> configs;
root->GetMakefile()->GetConfigurations(configs);
// Write out the header for a SLN file
this->WriteSLNHeader(fout);
@@ -104,11 +107,11 @@ void cmGlobalVisualStudio71Generator
// Write out the configurations information for the solution
fout << "Global\n";
// Write out the configurations for the solution
this->WriteSolutionConfigurations(fout);
this->WriteSolutionConfigurations(fout, configs);
fout << "\tGlobalSection(" << this->ProjectConfigurationSectionName
<< ") = postSolution\n";
// Write out the configurations for all the targets in the project
this->WriteTargetConfigurations(fout, orderedProjectTargets);
this->WriteTargetConfigurations(fout, configs, orderedProjectTargets);
fout << "\tEndGlobalSection\n";
if (useFolderProperty)
@@ -129,11 +132,12 @@ void cmGlobalVisualStudio71Generator
//----------------------------------------------------------------------------
void
cmGlobalVisualStudio71Generator
::WriteSolutionConfigurations(std::ostream& fout)
::WriteSolutionConfigurations(std::ostream& fout,
std::vector<std::string> const& configs)
{
fout << "\tGlobalSection(SolutionConfiguration) = preSolution\n";
for(std::vector<std::string>::iterator i = this->Configurations.begin();
i != this->Configurations.end(); ++i)
for(std::vector<std::string>::const_iterator i = configs.begin();
i != configs.end(); ++i)
{
fout << "\t\t" << *i << " = " << *i << "\n";
}
@@ -269,14 +273,15 @@ void cmGlobalVisualStudio71Generator
void cmGlobalVisualStudio71Generator
::WriteProjectConfigurations(
std::ostream& fout, const std::string& name, cmTarget::TargetType,
std::vector<std::string> const& configs,
const std::set<std::string>& configsPartOfDefaultBuild,
std::string const& platformMapping)
{
const std::string& platformName =
!platformMapping.empty() ? platformMapping : this->GetPlatformName();
std::string guid = this->GetGUID(name);
for(std::vector<std::string>::iterator i = this->Configurations.begin();
i != this->Configurations.end(); ++i)
for(std::vector<std::string>::const_iterator i = configs.begin();
i != configs.end(); ++i)
{
fout << "\t\t{" << guid << "}." << *i
<< ".ActiveCfg = " << *i << "|" << platformName << std::endl;