summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalVisualStudio7Generator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-05-20 17:55:21 (GMT)
committerBrad King <brad.king@kitware.com>2015-05-21 13:06:49 (GMT)
commit2f4bb4e9b033e1ac3daf63c0dc7c588ccbd70bf4 (patch)
tree6821eeb8c45ada58e8afe5209a4ccc16d629a9cf /Source/cmGlobalVisualStudio7Generator.cxx
parent3541fc73a12a52f87a2faa9790a65651658162d8 (diff)
downloadCMake-2f4bb4e9b033e1ac3daf63c0dc7c588ccbd70bf4.zip
CMake-2f4bb4e9b033e1ac3daf63c0dc7c588ccbd70bf4.tar.gz
CMake-2f4bb4e9b033e1ac3daf63c0dc7c588ccbd70bf4.tar.bz2
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.
Diffstat (limited to 'Source/cmGlobalVisualStudio7Generator.cxx')
-rw-r--r--Source/cmGlobalVisualStudio7Generator.cxx89
1 files changed, 23 insertions, 66 deletions
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index ca86987..08ed6ac 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -122,7 +122,6 @@ void cmGlobalVisualStudio7Generator
// Create list of configurations requested by user's cache, if any.
this->cmGlobalGenerator::EnableLanguage(lang, mf, optional);
- this->GenerateConfigurations(mf);
// if this environment variable is set, then copy it to
// a static cache entry. It will be used by
@@ -321,50 +320,6 @@ bool cmGlobalVisualStudio7Generator::SetGeneratorPlatform(std::string const& p,
return this->cmGlobalVisualStudioGenerator::SetGeneratorPlatform(p, mf);
}
-void cmGlobalVisualStudio7Generator::GenerateConfigurations(cmMakefile* mf)
-{
- // process the configurations
- const char* ct
- = this->CMakeInstance->GetCacheDefinition("CMAKE_CONFIGURATION_TYPES");
- if ( ct )
- {
- std::vector<std::string> argsOut;
- cmSystemTools::ExpandListArgument(ct, argsOut);
- for(std::vector<std::string>::iterator i = argsOut.begin();
- i != argsOut.end(); ++i)
- {
- if(std::find(this->Configurations.begin(),
- this->Configurations.end(),
- *i) == this->Configurations.end())
- {
- this->Configurations.push_back(*i);
- }
- }
- }
- // default to at least Debug and Release
- if(this->Configurations.size() == 0)
- {
- this->Configurations.push_back("Debug");
- this->Configurations.push_back("Release");
- }
-
- // Reset the entry to have a semi-colon separated list.
- std::string configs = this->Configurations[0];
- for(unsigned int i=1; i < this->Configurations.size(); ++i)
- {
- configs += ";";
- configs += this->Configurations[i];
- }
-
- mf->AddCacheDefinition(
- "CMAKE_CONFIGURATION_TYPES",
- configs.c_str(),
- "Semicolon separated list of supported configuration types, "
- "only supports Debug, Release, MinSizeRel, and RelWithDebInfo, "
- "anything else will be ignored.",
- cmState::STRING);
-}
-
void cmGlobalVisualStudio7Generator::Generate()
{
// first do the superclass method
@@ -436,6 +391,7 @@ void cmGlobalVisualStudio7Generator::OutputSLNFile()
void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
std::ostream& fout,
+ std::vector<std::string> const& configs,
OrderedTargetDependSet const& projectTargets)
{
// loop over again and write out configurations for each target
@@ -451,23 +407,22 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
const char* expath = target->GetProperty("EXTERNAL_MSPROJECT");
if(expath)
{
- std::set<std::string> allConfigurations(this->Configurations.begin(),
- this->Configurations.end());
+ std::set<std::string> allConfigurations(configs.begin(), configs.end());
const char* mapping = target->GetProperty("VS_PLATFORM_MAPPING");
this->WriteProjectConfigurations(
fout, target->GetName().c_str(), target->GetType(),
- allConfigurations, mapping ? mapping : "");
+ configs, allConfigurations, mapping ? mapping : "");
}
else
{
const std::set<std::string>& configsPartOfDefaultBuild =
- this->IsPartOfDefaultBuild(projectTargets, target);
+ this->IsPartOfDefaultBuild(configs, projectTargets, target);
const char *vcprojName =
target->GetProperty("GENERATOR_FILE_NAME");
if (vcprojName)
{
this->WriteProjectConfigurations(fout, vcprojName, target->GetType(),
- configsPartOfDefaultBuild);
+ configs, configsPartOfDefaultBuild);
}
}
}
@@ -602,6 +557,9 @@ void cmGlobalVisualStudio7Generator
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);
@@ -625,8 +583,8 @@ void cmGlobalVisualStudio7Generator
<< "\tGlobalSection(SolutionConfiguration) = preSolution\n";
int c = 0;
- for(std::vector<std::string>::iterator i = this->Configurations.begin();
- i != this->Configurations.end(); ++i)
+ for(std::vector<std::string>::iterator i = configs.begin();
+ i != configs.end(); ++i)
{
fout << "\t\tConfigName." << c << " = " << *i << "\n";
c++;
@@ -647,7 +605,7 @@ void cmGlobalVisualStudio7Generator
// Write out the configurations for all the targets in the project
fout << "\tGlobalSection(ProjectConfiguration) = postSolution\n";
- this->WriteTargetConfigurations(fout, orderedProjectTargets);
+ this->WriteTargetConfigurations(fout, configs, orderedProjectTargets);
fout << "\tEndGlobalSection\n";
// Write out global sections
@@ -803,14 +761,15 @@ cmGlobalVisualStudio7Generator
void cmGlobalVisualStudio7Generator
::WriteProjectConfigurations(
std::ostream& fout, const std::string& name, cmTarget::TargetType,
+ std::vector<std::string> const& configs,
const std::set<std::string>& configsPartOfDefaultBuild,
const std::string& 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 << "\n";
@@ -928,6 +887,8 @@ void cmGlobalVisualStudio7Generator::WriteSLNHeader(std::ostream& fout)
std::string
cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget const* target)
{
+ std::vector<std::string> configs;
+ target->GetMakefile()->GetConfigurations(configs);
std::string pname = target->GetName();
pname += "_UTILITY";
std::string fname = target->GetMakefile()->GetCurrentBinaryDirectory();
@@ -951,8 +912,8 @@ cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget const* target)
"\t<Platforms><Platform Name=\"Win32\"/></Platforms>\n"
"\t<Configurations>\n"
;
- for(std::vector<std::string>::iterator i = this->Configurations.begin();
- i != this->Configurations.end(); ++i)
+ for(std::vector<std::string>::iterator i = configs.begin();
+ i != configs.end(); ++i)
{
fout <<
"\t\t<Configuration\n"
@@ -1017,11 +978,6 @@ void cmGlobalVisualStudio7Generator::CreateGUID(const std::string& name)
cmState::INTERNAL);
}
-std::vector<std::string> *cmGlobalVisualStudio7Generator::GetConfigurations()
-{
- return &this->Configurations;
-};
-
//----------------------------------------------------------------------------
void cmGlobalVisualStudio7Generator
::GetDocumentation(cmDocumentationEntry& entry)
@@ -1048,6 +1004,7 @@ cmGlobalVisualStudio7Generator
std::set<std::string>
cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
+ std::vector<std::string> const& configs,
OrderedTargetDependSet const& projectTargets, cmTarget const* target)
{
std::set<std::string> activeConfigs;
@@ -1060,8 +1017,8 @@ cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
if(target->GetName() == "INSTALL")
{
// inspect CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD properties
- 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)
{
const char* propertyValue = target->GetMakefile()
->GetDefinition("CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD");
@@ -1081,8 +1038,8 @@ cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
return activeConfigs;
}
// inspect EXCLUDE_FROM_DEFAULT_BUILD[_<CONFIG>] properties
- 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)
{
const char* propertyValue =
target->GetFeature("EXCLUDE_FROM_DEFAULT_BUILD", i->c_str());