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

View File

@ -83,6 +83,9 @@ void cmGlobalVisualStudio71Generator
cmLocalGenerator* root, cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators) std::vector<cmLocalGenerator*>& generators)
{ {
std::vector<std::string> configs;
root->GetMakefile()->GetConfigurations(configs);
// Write out the header for a SLN file // Write out the header for a SLN file
this->WriteSLNHeader(fout); this->WriteSLNHeader(fout);
@ -104,11 +107,11 @@ void cmGlobalVisualStudio71Generator
// Write out the configurations information for the solution // Write out the configurations information for the solution
fout << "Global\n"; fout << "Global\n";
// Write out the configurations for the solution // Write out the configurations for the solution
this->WriteSolutionConfigurations(fout); this->WriteSolutionConfigurations(fout, configs);
fout << "\tGlobalSection(" << this->ProjectConfigurationSectionName fout << "\tGlobalSection(" << this->ProjectConfigurationSectionName
<< ") = postSolution\n"; << ") = postSolution\n";
// Write out the configurations for all the targets in the project // Write out the configurations for all the targets in the project
this->WriteTargetConfigurations(fout, orderedProjectTargets); this->WriteTargetConfigurations(fout, configs, orderedProjectTargets);
fout << "\tEndGlobalSection\n"; fout << "\tEndGlobalSection\n";
if (useFolderProperty) if (useFolderProperty)
@ -129,11 +132,12 @@ void cmGlobalVisualStudio71Generator
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void void
cmGlobalVisualStudio71Generator cmGlobalVisualStudio71Generator
::WriteSolutionConfigurations(std::ostream& fout) ::WriteSolutionConfigurations(std::ostream& fout,
std::vector<std::string> const& configs)
{ {
fout << "\tGlobalSection(SolutionConfiguration) = preSolution\n"; fout << "\tGlobalSection(SolutionConfiguration) = preSolution\n";
for(std::vector<std::string>::iterator i = this->Configurations.begin(); for(std::vector<std::string>::const_iterator i = configs.begin();
i != this->Configurations.end(); ++i) i != configs.end(); ++i)
{ {
fout << "\t\t" << *i << " = " << *i << "\n"; fout << "\t\t" << *i << " = " << *i << "\n";
} }
@ -269,14 +273,15 @@ void cmGlobalVisualStudio71Generator
void cmGlobalVisualStudio71Generator void cmGlobalVisualStudio71Generator
::WriteProjectConfigurations( ::WriteProjectConfigurations(
std::ostream& fout, const std::string& name, cmTarget::TargetType, std::ostream& fout, const std::string& name, cmTarget::TargetType,
std::vector<std::string> const& configs,
const std::set<std::string>& configsPartOfDefaultBuild, const std::set<std::string>& configsPartOfDefaultBuild,
std::string const& platformMapping) std::string const& platformMapping)
{ {
const std::string& platformName = const std::string& platformName =
!platformMapping.empty() ? platformMapping : this->GetPlatformName(); !platformMapping.empty() ? platformMapping : this->GetPlatformName();
std::string guid = this->GetGUID(name); std::string guid = this->GetGUID(name);
for(std::vector<std::string>::iterator i = this->Configurations.begin(); for(std::vector<std::string>::const_iterator i = configs.begin();
i != this->Configurations.end(); ++i) i != configs.end(); ++i)
{ {
fout << "\t\t{" << guid << "}." << *i fout << "\t\t{" << guid << "}." << *i
<< ".ActiveCfg = " << *i << "|" << platformName << std::endl; << ".ActiveCfg = " << *i << "|" << platformName << std::endl;

View File

@ -54,7 +54,8 @@ protected:
virtual void WriteSLNFile(std::ostream& fout, virtual void WriteSLNFile(std::ostream& fout,
cmLocalGenerator* root, cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators); std::vector<cmLocalGenerator*>& generators);
virtual void WriteSolutionConfigurations(std::ostream& fout); virtual void WriteSolutionConfigurations(
std::ostream& fout, std::vector<std::string> const& configs);
virtual void WriteProject(std::ostream& fout, virtual void WriteProject(std::ostream& fout,
const std::string& name, const char* path, const std::string& name, const char* path,
cmTarget const& t); cmTarget const& t);
@ -63,6 +64,7 @@ protected:
cmTarget const& t); cmTarget const& t);
virtual void WriteProjectConfigurations( virtual void WriteProjectConfigurations(
std::ostream& fout, const std::string& name, cmTarget::TargetType type, std::ostream& fout, const std::string& name, cmTarget::TargetType type,
std::vector<std::string> const& configs,
const std::set<std::string>& configsPartOfDefaultBuild, const std::set<std::string>& configsPartOfDefaultBuild,
const std::string& platformMapping = ""); const std::string& platformMapping = "");
virtual void WriteExternalProject(std::ostream& fout, virtual void WriteExternalProject(std::ostream& fout,

View File

@ -122,7 +122,6 @@ void cmGlobalVisualStudio7Generator
// Create list of configurations requested by user's cache, if any. // Create list of configurations requested by user's cache, if any.
this->cmGlobalGenerator::EnableLanguage(lang, mf, optional); this->cmGlobalGenerator::EnableLanguage(lang, mf, optional);
this->GenerateConfigurations(mf);
// if this environment variable is set, then copy it to // if this environment variable is set, then copy it to
// a static cache entry. It will be used by // 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); 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() void cmGlobalVisualStudio7Generator::Generate()
{ {
// first do the superclass method // first do the superclass method
@ -436,6 +391,7 @@ void cmGlobalVisualStudio7Generator::OutputSLNFile()
void cmGlobalVisualStudio7Generator::WriteTargetConfigurations( void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
std::ostream& fout, std::ostream& fout,
std::vector<std::string> const& configs,
OrderedTargetDependSet const& projectTargets) OrderedTargetDependSet const& projectTargets)
{ {
// loop over again and write out configurations for each target // loop over again and write out configurations for each target
@ -451,23 +407,22 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
const char* expath = target->GetProperty("EXTERNAL_MSPROJECT"); const char* expath = target->GetProperty("EXTERNAL_MSPROJECT");
if(expath) if(expath)
{ {
std::set<std::string> allConfigurations(this->Configurations.begin(), std::set<std::string> allConfigurations(configs.begin(), configs.end());
this->Configurations.end());
const char* mapping = target->GetProperty("VS_PLATFORM_MAPPING"); const char* mapping = target->GetProperty("VS_PLATFORM_MAPPING");
this->WriteProjectConfigurations( this->WriteProjectConfigurations(
fout, target->GetName().c_str(), target->GetType(), fout, target->GetName().c_str(), target->GetType(),
allConfigurations, mapping ? mapping : ""); configs, allConfigurations, mapping ? mapping : "");
} }
else else
{ {
const std::set<std::string>& configsPartOfDefaultBuild = const std::set<std::string>& configsPartOfDefaultBuild =
this->IsPartOfDefaultBuild(projectTargets, target); this->IsPartOfDefaultBuild(configs, projectTargets, target);
const char *vcprojName = const char *vcprojName =
target->GetProperty("GENERATOR_FILE_NAME"); target->GetProperty("GENERATOR_FILE_NAME");
if (vcprojName) if (vcprojName)
{ {
this->WriteProjectConfigurations(fout, vcprojName, target->GetType(), this->WriteProjectConfigurations(fout, vcprojName, target->GetType(),
configsPartOfDefaultBuild); configs, configsPartOfDefaultBuild);
} }
} }
} }
@ -602,6 +557,9 @@ void cmGlobalVisualStudio7Generator
cmLocalGenerator* root, cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators) std::vector<cmLocalGenerator*>& generators)
{ {
std::vector<std::string> configs;
root->GetMakefile()->GetConfigurations(configs);
// Write out the header for a SLN file // Write out the header for a SLN file
this->WriteSLNHeader(fout); this->WriteSLNHeader(fout);
@ -625,8 +583,8 @@ void cmGlobalVisualStudio7Generator
<< "\tGlobalSection(SolutionConfiguration) = preSolution\n"; << "\tGlobalSection(SolutionConfiguration) = preSolution\n";
int c = 0; int c = 0;
for(std::vector<std::string>::iterator i = this->Configurations.begin(); for(std::vector<std::string>::iterator i = configs.begin();
i != this->Configurations.end(); ++i) i != configs.end(); ++i)
{ {
fout << "\t\tConfigName." << c << " = " << *i << "\n"; fout << "\t\tConfigName." << c << " = " << *i << "\n";
c++; c++;
@ -647,7 +605,7 @@ void cmGlobalVisualStudio7Generator
// Write out the configurations for all the targets in the project // Write out the configurations for all the targets in the project
fout << "\tGlobalSection(ProjectConfiguration) = postSolution\n"; fout << "\tGlobalSection(ProjectConfiguration) = postSolution\n";
this->WriteTargetConfigurations(fout, orderedProjectTargets); this->WriteTargetConfigurations(fout, configs, orderedProjectTargets);
fout << "\tEndGlobalSection\n"; fout << "\tEndGlobalSection\n";
// Write out global sections // Write out global sections
@ -803,14 +761,15 @@ cmGlobalVisualStudio7Generator
void cmGlobalVisualStudio7Generator void cmGlobalVisualStudio7Generator
::WriteProjectConfigurations( ::WriteProjectConfigurations(
std::ostream& fout, const std::string& name, cmTarget::TargetType, std::ostream& fout, const std::string& name, cmTarget::TargetType,
std::vector<std::string> const& configs,
const std::set<std::string>& configsPartOfDefaultBuild, const std::set<std::string>& configsPartOfDefaultBuild,
const std::string& platformMapping) const std::string& platformMapping)
{ {
const std::string& platformName = const std::string& platformName =
!platformMapping.empty() ? platformMapping : this->GetPlatformName(); !platformMapping.empty() ? platformMapping : this->GetPlatformName();
std::string guid = this->GetGUID(name); std::string guid = this->GetGUID(name);
for(std::vector<std::string>::iterator i = this->Configurations.begin(); for(std::vector<std::string>::const_iterator i = configs.begin();
i != this->Configurations.end(); ++i) i != configs.end(); ++i)
{ {
fout << "\t\t{" << guid << "}." << *i fout << "\t\t{" << guid << "}." << *i
<< ".ActiveCfg = " << *i << "|" << platformName << "\n"; << ".ActiveCfg = " << *i << "|" << platformName << "\n";
@ -928,6 +887,8 @@ void cmGlobalVisualStudio7Generator::WriteSLNHeader(std::ostream& fout)
std::string std::string
cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget const* target) cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget const* target)
{ {
std::vector<std::string> configs;
target->GetMakefile()->GetConfigurations(configs);
std::string pname = target->GetName(); std::string pname = target->GetName();
pname += "_UTILITY"; pname += "_UTILITY";
std::string fname = target->GetMakefile()->GetCurrentBinaryDirectory(); std::string fname = target->GetMakefile()->GetCurrentBinaryDirectory();
@ -951,8 +912,8 @@ cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget const* target)
"\t<Platforms><Platform Name=\"Win32\"/></Platforms>\n" "\t<Platforms><Platform Name=\"Win32\"/></Platforms>\n"
"\t<Configurations>\n" "\t<Configurations>\n"
; ;
for(std::vector<std::string>::iterator i = this->Configurations.begin(); for(std::vector<std::string>::iterator i = configs.begin();
i != this->Configurations.end(); ++i) i != configs.end(); ++i)
{ {
fout << fout <<
"\t\t<Configuration\n" "\t\t<Configuration\n"
@ -1017,11 +978,6 @@ void cmGlobalVisualStudio7Generator::CreateGUID(const std::string& name)
cmState::INTERNAL); cmState::INTERNAL);
} }
std::vector<std::string> *cmGlobalVisualStudio7Generator::GetConfigurations()
{
return &this->Configurations;
};
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalVisualStudio7Generator void cmGlobalVisualStudio7Generator
::GetDocumentation(cmDocumentationEntry& entry) ::GetDocumentation(cmDocumentationEntry& entry)
@ -1048,6 +1004,7 @@ cmGlobalVisualStudio7Generator
std::set<std::string> std::set<std::string>
cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild( cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
std::vector<std::string> const& configs,
OrderedTargetDependSet const& projectTargets, cmTarget const* target) OrderedTargetDependSet const& projectTargets, cmTarget const* target)
{ {
std::set<std::string> activeConfigs; std::set<std::string> activeConfigs;
@ -1060,8 +1017,8 @@ cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
if(target->GetName() == "INSTALL") if(target->GetName() == "INSTALL")
{ {
// inspect CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD properties // inspect CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD properties
for(std::vector<std::string>::iterator i = this->Configurations.begin(); for(std::vector<std::string>::const_iterator i = configs.begin();
i != this->Configurations.end(); ++i) i != configs.end(); ++i)
{ {
const char* propertyValue = target->GetMakefile() const char* propertyValue = target->GetMakefile()
->GetDefinition("CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD"); ->GetDefinition("CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD");
@ -1081,8 +1038,8 @@ cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
return activeConfigs; return activeConfigs;
} }
// inspect EXCLUDE_FROM_DEFAULT_BUILD[_<CONFIG>] properties // inspect EXCLUDE_FROM_DEFAULT_BUILD[_<CONFIG>] properties
for(std::vector<std::string>::iterator i = this->Configurations.begin(); for(std::vector<std::string>::const_iterator i = configs.begin();
i != this->Configurations.end(); ++i) i != configs.end(); ++i)
{ {
const char* propertyValue = const char* propertyValue =
target->GetFeature("EXCLUDE_FROM_DEFAULT_BUILD", i->c_str()); target->GetFeature("EXCLUDE_FROM_DEFAULT_BUILD", i->c_str());

View File

@ -78,11 +78,6 @@ public:
*/ */
virtual void OutputSLNFile(); virtual void OutputSLNFile();
/**
* Get the list of configurations
*/
std::vector<std::string> *GetConfigurations();
///! Create a GUID or get an existing one. ///! Create a GUID or get an existing one.
void CreateGUID(const std::string& name); void CreateGUID(const std::string& name);
std::string GetGUID(const std::string& name); std::string GetGUID(const std::string& name);
@ -134,6 +129,7 @@ protected:
cmTarget const&t); cmTarget const&t);
virtual void WriteProjectConfigurations( virtual void WriteProjectConfigurations(
std::ostream& fout, const std::string& name, cmTarget::TargetType type, std::ostream& fout, const std::string& name, cmTarget::TargetType type,
std::vector<std::string> const& configs,
const std::set<std::string>& configsPartOfDefaultBuild, const std::set<std::string>& configsPartOfDefaultBuild,
const std::string& platformMapping = ""); const std::string& platformMapping = "");
virtual void WriteSLNGlobalSections(std::ostream& fout, virtual void WriteSLNGlobalSections(std::ostream& fout,
@ -151,10 +147,9 @@ protected:
OrderedTargetDependSet const& projectTargets); OrderedTargetDependSet const& projectTargets);
virtual void WriteTargetConfigurations( virtual void WriteTargetConfigurations(
std::ostream& fout, std::ostream& fout,
std::vector<std::string> const& configs,
OrderedTargetDependSet const& projectTargets); OrderedTargetDependSet const& projectTargets);
void GenerateConfigurations(cmMakefile* mf);
virtual void WriteExternalProject(std::ostream& fout, virtual void WriteExternalProject(std::ostream& fout,
const std::string& name, const std::string& name,
const char* path, const char* path,
@ -165,11 +160,11 @@ protected:
std::string ConvertToSolutionPath(const char* path); std::string ConvertToSolutionPath(const char* path);
std::set<std::string> std::set<std::string>
IsPartOfDefaultBuild(OrderedTargetDependSet const& projectTargets, IsPartOfDefaultBuild(std::vector<std::string> const& configs,
OrderedTargetDependSet const& projectTargets,
cmTarget const* target); cmTarget const* target);
bool IsDependedOn(OrderedTargetDependSet const& projectTargets, bool IsDependedOn(OrderedTargetDependSet const& projectTargets,
cmTarget const* target); cmTarget const* target);
std::vector<std::string> Configurations;
std::map<std::string, std::string> GUIDMap; std::map<std::string, std::string> GUIDMap;
virtual void WriteFolders(std::ostream& fout); virtual void WriteFolders(std::ostream& fout);

View File

@ -375,11 +375,12 @@ void cmGlobalVisualStudio8Generator::Generate()
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void void
cmGlobalVisualStudio8Generator cmGlobalVisualStudio8Generator
::WriteSolutionConfigurations(std::ostream& fout) ::WriteSolutionConfigurations(std::ostream& fout,
std::vector<std::string> const& configs)
{ {
fout << "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n"; fout << "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n";
for(std::vector<std::string>::iterator i = this->Configurations.begin(); for(std::vector<std::string>::const_iterator i = configs.begin();
i != this->Configurations.end(); ++i) i != configs.end(); ++i)
{ {
fout << "\t\t" << *i << "|" << this->GetPlatformName() fout << "\t\t" << *i << "|" << this->GetPlatformName()
<< " = " << *i << "|" << this->GetPlatformName() << "\n"; << " = " << *i << "|" << this->GetPlatformName() << "\n";
@ -392,12 +393,13 @@ void
cmGlobalVisualStudio8Generator cmGlobalVisualStudio8Generator
::WriteProjectConfigurations( ::WriteProjectConfigurations(
std::ostream& fout, const std::string& name, cmTarget::TargetType type, std::ostream& fout, const std::string& name, cmTarget::TargetType type,
std::vector<std::string> const& configs,
const std::set<std::string>& configsPartOfDefaultBuild, const std::set<std::string>& configsPartOfDefaultBuild,
std::string const& platformMapping) std::string const& platformMapping)
{ {
std::string guid = this->GetGUID(name); std::string guid = this->GetGUID(name);
for(std::vector<std::string>::iterator i = this->Configurations.begin(); for(std::vector<std::string>::const_iterator i = configs.begin();
i != this->Configurations.end(); ++i) i != configs.end(); ++i)
{ {
fout << "\t\t{" << guid << "}." << *i fout << "\t\t{" << guid << "}." << *i
<< "|" << this->GetPlatformName() << ".ActiveCfg = " << *i << "|" << "|" << this->GetPlatformName() << ".ActiveCfg = " << *i << "|"

View File

@ -81,9 +81,11 @@ protected:
static cmIDEFlagTable const* GetExtraFlagTableVS8(); static cmIDEFlagTable const* GetExtraFlagTableVS8();
virtual void WriteSLNHeader(std::ostream& fout); virtual void WriteSLNHeader(std::ostream& fout);
virtual void WriteSolutionConfigurations(std::ostream& fout); virtual void WriteSolutionConfigurations(
std::ostream& fout, std::vector<std::string> const& configs);
virtual void WriteProjectConfigurations( virtual void WriteProjectConfigurations(
std::ostream& fout, const std::string& name, cmTarget::TargetType type, std::ostream& fout, const std::string& name, cmTarget::TargetType type,
std::vector<std::string> const& configs,
const std::set<std::string>& configsPartOfDefaultBuild, const std::set<std::string>& configsPartOfDefaultBuild,
const std::string& platformMapping = ""); const std::string& platformMapping = "");
virtual bool ComputeTargetDepends(); virtual bool ComputeTargetDepends();

View File

@ -339,17 +339,14 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule()
} }
} }
void cmLocalVisualStudio7Generator::WriteConfigurations(std::ostream& fout, void cmLocalVisualStudio7Generator::WriteConfigurations(
const std::string& libName, std::ostream& fout, std::vector<std::string> const& configs,
cmTarget &target) const std::string& libName, cmTarget &target
)
{ {
std::vector<std::string> *configs =
static_cast<cmGlobalVisualStudio7Generator *>
(this->GlobalGenerator)->GetConfigurations();
fout << "\t<Configurations>\n"; fout << "\t<Configurations>\n";
for( std::vector<std::string>::iterator i = configs->begin(); for (std::vector<std::string>::const_iterator i = configs.begin();
i != configs->end(); ++i) i != configs.end(); ++i)
{ {
this->WriteConfiguration(fout, i->c_str(), libName, target); this->WriteConfiguration(fout, i->c_str(), libName, target);
} }
@ -1468,10 +1465,8 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
const std::string& libName, const std::string& libName,
cmTarget &target) cmTarget &target)
{ {
// get the configurations std::vector<std::string> configs;
std::vector<std::string> *configs = this->Makefile->GetConfigurations(configs);
static_cast<cmGlobalVisualStudio7Generator *>
(this->GlobalGenerator)->GetConfigurations();
// We may be modifying the source groups temporarily, so make a copy. // We may be modifying the source groups temporarily, so make a copy.
std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups(); std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups();
@ -1504,7 +1499,7 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
// open the project // open the project
this->WriteProjectStart(fout, libName, target, sourceGroups); this->WriteProjectStart(fout, libName, target, sourceGroups);
// write the configuration information // write the configuration information
this->WriteConfigurations(fout, libName, target); this->WriteConfigurations(fout, configs, libName, target);
fout << "\t<Files>\n"; fout << "\t<Files>\n";
@ -1561,7 +1556,7 @@ public:
cmLocalVisualStudio7GeneratorFCInfo(cmLocalVisualStudio7Generator* lg, cmLocalVisualStudio7GeneratorFCInfo(cmLocalVisualStudio7Generator* lg,
cmTarget& target, cmTarget& target,
cmSourceFile const& sf, cmSourceFile const& sf,
std::vector<std::string>* configs); std::vector<std::string> const& configs);
std::map<std::string, cmLVS7GFileConfig> FileConfigMap; std::map<std::string, cmLVS7GFileConfig> FileConfigMap;
}; };
@ -1569,7 +1564,7 @@ cmLocalVisualStudio7GeneratorFCInfo
::cmLocalVisualStudio7GeneratorFCInfo(cmLocalVisualStudio7Generator* lg, ::cmLocalVisualStudio7GeneratorFCInfo(cmLocalVisualStudio7Generator* lg,
cmTarget& target, cmTarget& target,
cmSourceFile const& sf, cmSourceFile const& sf,
std::vector<std::string>* configs) std::vector<std::string> const& configs)
{ {
cmGeneratorTarget* gt = cmGeneratorTarget* gt =
lg->GetGlobalGenerator()->GetGeneratorTarget(&target); lg->GetGlobalGenerator()->GetGeneratorTarget(&target);
@ -1580,8 +1575,8 @@ cmLocalVisualStudio7GeneratorFCInfo
} }
// Compute per-source, per-config information. // Compute per-source, per-config information.
for(std::vector<std::string>::iterator i = configs->begin(); for(std::vector<std::string>::const_iterator i = configs.begin();
i != configs->end(); ++i) i != configs.end(); ++i)
{ {
std::string configUpper = cmSystemTools::UpperCase(*i); std::string configUpper = cmSystemTools::UpperCase(*i);
cmLVS7GFileConfig fc; cmLVS7GFileConfig fc;
@ -1691,13 +1686,13 @@ std::string
cmLocalVisualStudio7Generator cmLocalVisualStudio7Generator
::ComputeLongestObjectDirectory(cmTarget& target) const ::ComputeLongestObjectDirectory(cmTarget& target) const
{ {
std::vector<std::string> *configs = std::vector<std::string> configs;
static_cast<cmGlobalVisualStudio7Generator *> target.GetMakefile()->GetConfigurations(configs);
(this->GlobalGenerator)->GetConfigurations();
// Compute the maximum length configuration name. // Compute the maximum length configuration name.
std::string config_max; std::string config_max;
for(std::vector<std::string>::iterator i = configs->begin(); for(std::vector<std::string>::iterator i = configs.begin();
i != configs->end(); ++i) i != configs.end(); ++i)
{ {
if(i->size() > config_max.size()) if(i->size() > config_max.size())
{ {
@ -1721,7 +1716,7 @@ cmLocalVisualStudio7Generator
bool cmLocalVisualStudio7Generator bool cmLocalVisualStudio7Generator
::WriteGroup(const cmSourceGroup *sg, cmTarget& target, ::WriteGroup(const cmSourceGroup *sg, cmTarget& target,
std::ostream &fout, const std::string& libName, std::ostream &fout, const std::string& libName,
std::vector<std::string> *configs) std::vector<std::string> const& configs)
{ {
cmGlobalVisualStudio7Generator* gg = cmGlobalVisualStudio7Generator* gg =
static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator); static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
@ -1771,7 +1766,8 @@ bool cmLocalVisualStudio7Generator
fout << "\t\t\t\tRelativePath=\"" << d << "\">\n"; fout << "\t\t\t\tRelativePath=\"" << d << "\">\n";
if(cmCustomCommand const* command = (*sf)->GetCustomCommand()) if(cmCustomCommand const* command = (*sf)->GetCustomCommand())
{ {
this->WriteCustomRule(fout, source.c_str(), *command, fcinfo); this->WriteCustomRule(fout, configs, source.c_str(),
*command, fcinfo);
} }
else if(!fcinfo.FileConfigMap.empty()) else if(!fcinfo.FileConfigMap.empty())
{ {
@ -1887,6 +1883,7 @@ bool cmLocalVisualStudio7Generator
void cmLocalVisualStudio7Generator:: void cmLocalVisualStudio7Generator::
WriteCustomRule(std::ostream& fout, WriteCustomRule(std::ostream& fout,
std::vector<std::string> const& configs,
const char* source, const char* source,
const cmCustomCommand& command, const cmCustomCommand& command,
FCInfo& fcinfo) FCInfo& fcinfo)
@ -1895,10 +1892,6 @@ WriteCustomRule(std::ostream& fout,
static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator); static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
// Write the rule for each configuration. // Write the rule for each configuration.
std::vector<std::string>::iterator i;
std::vector<std::string> *configs =
static_cast<cmGlobalVisualStudio7Generator *>
(this->GlobalGenerator)->GetConfigurations();
const char* compileTool = "VCCLCompilerTool"; const char* compileTool = "VCCLCompilerTool";
if(this->FortranProject) if(this->FortranProject)
{ {
@ -1909,7 +1902,8 @@ WriteCustomRule(std::ostream& fout,
{ {
customTool = "VFCustomBuildTool"; customTool = "VFCustomBuildTool";
} }
for(i = configs->begin(); i != configs->end(); ++i) for (std::vector<std::string>::const_iterator i = configs.begin();
i != configs.end(); ++i)
{ {
cmCustomCommandGenerator ccg(command, *i, this->Makefile); cmCustomCommandGenerator ccg(command, *i, this->Makefile);
cmLVS7GFileConfig const& fc = fcinfo.FileConfigMap[*i]; cmLVS7GFileConfig const& fc = fcinfo.FileConfigMap[*i];

View File

@ -77,6 +77,7 @@ private:
void WriteVCProjFile(std::ostream& fout, const std::string& libName, void WriteVCProjFile(std::ostream& fout, const std::string& libName,
cmTarget &tgt); cmTarget &tgt);
void WriteConfigurations(std::ostream& fout, void WriteConfigurations(std::ostream& fout,
std::vector<std::string> const& configs,
const std::string& libName, cmTarget &tgt); const std::string& libName, cmTarget &tgt);
void WriteConfiguration(std::ostream& fout, void WriteConfiguration(std::ostream& fout,
const std::string& configName, const std::string& configName,
@ -101,6 +102,7 @@ private:
void WriteVCProjEndGroup(std::ostream& fout); void WriteVCProjEndGroup(std::ostream& fout);
void WriteCustomRule(std::ostream& fout, void WriteCustomRule(std::ostream& fout,
std::vector<std::string> const& configs,
const char* source, const char* source,
const cmCustomCommand& command, const cmCustomCommand& command,
FCInfo& fcinfo); FCInfo& fcinfo);
@ -109,7 +111,7 @@ private:
bool WriteGroup(const cmSourceGroup *sg, bool WriteGroup(const cmSourceGroup *sg,
cmTarget& target, std::ostream &fout, cmTarget& target, std::ostream &fout,
const std::string& libName, const std::string& libName,
std::vector<std::string> *configs); std::vector<std::string> const& configs);
friend class cmLocalVisualStudio7GeneratorFCInfo; friend class cmLocalVisualStudio7GeneratorFCInfo;
friend class cmLocalVisualStudio7GeneratorInternals; friend class cmLocalVisualStudio7GeneratorInternals;

View File

@ -173,6 +173,7 @@ cmVisualStudio10TargetGenerator(cmTarget* target,
this->Target = target; this->Target = target;
this->GeneratorTarget = gg->GetGeneratorTarget(target); this->GeneratorTarget = gg->GetGeneratorTarget(target);
this->Makefile = target->GetMakefile(); this->Makefile = target->GetMakefile();
this->Makefile->GetConfigurations(this->Configurations);
this->LocalGenerator = this->LocalGenerator =
(cmLocalVisualStudio7Generator*) (cmLocalVisualStudio7Generator*)
this->Makefile->GetLocalGenerator(); this->Makefile->GetLocalGenerator();
@ -525,10 +526,9 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup()
std::string hFileName = obj.substr(0, obj.find_last_of(".")) + ".h"; std::string hFileName = obj.substr(0, obj.find_last_of(".")) + ".h";
(*this->BuildFileStream) << hFileName << "</DependentUpon>\n"; (*this->BuildFileStream) << hFileName << "</DependentUpon>\n";
std::vector<std::string> const * configs = for(std::vector<std::string>::const_iterator
this->GlobalGenerator->GetConfigurations(); i = this->Configurations.begin();
for(std::vector<std::string>::const_iterator i = configs->begin(); i != this->Configurations.end(); ++i)
i != configs->end(); ++i)
{ {
this->WritePlatformConfigTag("LogicalName", i->c_str(), 3); this->WritePlatformConfigTag("LogicalName", i->c_str(), 3);
if(this->Target->GetProperty("VS_GLOBAL_ROOTNAMESPACE")) if(this->Target->GetProperty("VS_GLOBAL_ROOTNAMESPACE"))
@ -629,11 +629,9 @@ void cmVisualStudio10TargetGenerator::WriteWinRTReferences()
void cmVisualStudio10TargetGenerator::WriteProjectConfigurations() void cmVisualStudio10TargetGenerator::WriteProjectConfigurations()
{ {
this->WriteString("<ItemGroup Label=\"ProjectConfigurations\">\n", 1); this->WriteString("<ItemGroup Label=\"ProjectConfigurations\">\n", 1);
std::vector<std::string> *configs = for(std::vector<std::string>::const_iterator
static_cast<cmGlobalVisualStudio7Generator *> i = this->Configurations.begin();
(this->GlobalGenerator)->GetConfigurations(); i != this->Configurations.end(); ++i)
for(std::vector<std::string>::iterator i = configs->begin();
i != configs->end(); ++i)
{ {
this->WriteString("<ProjectConfiguration Include=\"", 2); this->WriteString("<ProjectConfiguration Include=\"", 2);
(*this->BuildFileStream ) << *i << "|" << this->Platform << "\">\n"; (*this->BuildFileStream ) << *i << "|" << this->Platform << "\">\n";
@ -649,11 +647,9 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurations()
void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues()
{ {
std::vector<std::string> *configs = for(std::vector<std::string>::const_iterator
static_cast<cmGlobalVisualStudio7Generator *> i = this->Configurations.begin();
(this->GlobalGenerator)->GetConfigurations(); i != this->Configurations.end(); ++i)
for(std::vector<std::string>::iterator i = configs->begin();
i != configs->end(); ++i)
{ {
this->WritePlatformConfigTag("PropertyGroup", this->WritePlatformConfigTag("PropertyGroup",
i->c_str(), i->c_str(),
@ -864,14 +860,12 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile const* source,
} }
} }
cmLocalVisualStudio7Generator* lg = this->LocalGenerator; cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
std::vector<std::string> *configs =
static_cast<cmGlobalVisualStudio7Generator *>
(this->GlobalGenerator)->GetConfigurations();
this->WriteSource("CustomBuild", source, ">\n"); this->WriteSource("CustomBuild", source, ">\n");
for(std::vector<std::string>::iterator i = configs->begin(); for(std::vector<std::string>::const_iterator
i != configs->end(); ++i) i = this->Configurations.begin();
i != this->Configurations.end(); ++i)
{ {
cmCustomCommandGenerator ccg(command, *i, this->Makefile); cmCustomCommandGenerator ccg(command, *i, this->Makefile);
std::string comment = lg->ConstructComment(ccg); std::string comment = lg->ConstructComment(ccg);
@ -1340,8 +1334,6 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
if(!deployContent.empty()) if(!deployContent.empty())
{ {
std::vector<std::string> const* configs =
this->GlobalGenerator->GetConfigurations();
cmGeneratorExpression ge; cmGeneratorExpression ge;
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(deployContent); ge.Parse(deployContent);
@ -1353,13 +1345,14 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
<< "\\%(FileName)%(Extension)"; << "\\%(FileName)%(Extension)";
this->WriteString("</Link>\n", 0); this->WriteString("</Link>\n", 0);
} }
for(size_t i = 0; i != configs->size(); ++i) for(size_t i = 0; i != this->Configurations.size(); ++i)
{ {
if(0 == strcmp(cge->Evaluate(this->Makefile, (*configs)[i]), "1")) if(0 == strcmp(cge->Evaluate(this->Makefile,
this->Configurations[i]), "1"))
{ {
this->WriteString("<DeploymentContent Condition=\"" this->WriteString("<DeploymentContent Condition=\""
"'$(Configuration)|$(Platform)'=='", 3); "'$(Configuration)|$(Platform)'=='", 3);
(*this->BuildFileStream) << (*configs)[i] << "|" (*this->BuildFileStream) << this->Configurations[i] << "|"
<< this->Platform << "'\">true"; << this->Platform << "'\">true";
this->WriteString("</DeploymentContent>\n", 0); this->WriteString("</DeploymentContent>\n", 0);
} }
@ -1367,7 +1360,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
{ {
this->WriteString("<ExcludedFromBuild Condition=\"" this->WriteString("<ExcludedFromBuild Condition=\""
"'$(Configuration)|$(Platform)'=='", 3); "'$(Configuration)|$(Platform)'=='", 3);
(*this->BuildFileStream) << (*configs)[i] << "|" (*this->BuildFileStream) << this->Configurations[i] << "|"
<< this->Platform << "'\">true"; << this->Platform << "'\">true";
this->WriteString("</ExcludedFromBuild>\n", 0); this->WriteString("</ExcludedFromBuild>\n", 0);
} }
@ -1655,11 +1648,9 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
(*this->BuildFileStream ) (*this->BuildFileStream )
<< "$(IntDir)/" << objectName << "</ObjectFileName>\n"; << "$(IntDir)/" << objectName << "</ObjectFileName>\n";
} }
std::vector<std::string> *configs = for(std::vector<std::string>::const_iterator
static_cast<cmGlobalVisualStudio7Generator *> config = this->Configurations.begin();
(this->GlobalGenerator)->GetConfigurations(); config != this->Configurations.end(); ++config)
for( std::vector<std::string>::iterator config = configs->begin();
config != configs->end(); ++config)
{ {
std::string configUpper = cmSystemTools::UpperCase(*config); std::string configUpper = cmSystemTools::UpperCase(*config);
std::string configDefines = defines; std::string configDefines = defines;
@ -1737,11 +1728,9 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions()
this->WriteString("<PropertyGroup>\n", 2); this->WriteString("<PropertyGroup>\n", 2);
this->WriteString("<_ProjectFileVersion>10.0.20506.1" this->WriteString("<_ProjectFileVersion>10.0.20506.1"
"</_ProjectFileVersion>\n", 3); "</_ProjectFileVersion>\n", 3);
std::vector<std::string> *configs = for(std::vector<std::string>::const_iterator
static_cast<cmGlobalVisualStudio7Generator *> config = this->Configurations.begin();
(this->GlobalGenerator)->GetConfigurations(); config != this->Configurations.end(); ++config)
for(std::vector<std::string>::iterator config = configs->begin();
config != configs->end(); ++config)
{ {
if(ttype >= cmTarget::UTILITY) if(ttype >= cmTarget::UTILITY)
{ {
@ -1855,10 +1844,9 @@ OutputLinkIncremental(std::string const& configName)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmVisualStudio10TargetGenerator::ComputeClOptions() bool cmVisualStudio10TargetGenerator::ComputeClOptions()
{ {
std::vector<std::string> const* configs = for(std::vector<std::string>::const_iterator
this->GlobalGenerator->GetConfigurations(); i = this->Configurations.begin();
for(std::vector<std::string>::const_iterator i = configs->begin(); i != this->Configurations.end(); ++i)
i != configs->end(); ++i)
{ {
if(!this->ComputeClOptions(*i)) if(!this->ComputeClOptions(*i))
{ {
@ -2026,10 +2014,9 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmVisualStudio10TargetGenerator::ComputeRcOptions() bool cmVisualStudio10TargetGenerator::ComputeRcOptions()
{ {
std::vector<std::string> const* configs = for(std::vector<std::string>::const_iterator
this->GlobalGenerator->GetConfigurations(); i = this->Configurations.begin();
for(std::vector<std::string>::const_iterator i = configs->begin(); i != this->Configurations.end(); ++i)
i != configs->end(); ++i)
{ {
if(!this->ComputeRcOptions(*i)) if(!this->ComputeRcOptions(*i))
{ {
@ -2092,10 +2079,9 @@ bool cmVisualStudio10TargetGenerator::ComputeMasmOptions()
{ {
return true; return true;
} }
std::vector<std::string> const* configs = for(std::vector<std::string>::const_iterator
this->GlobalGenerator->GetConfigurations(); i = this->Configurations.begin();
for(std::vector<std::string>::const_iterator i = configs->begin(); i != this->Configurations.end(); ++i)
i != configs->end(); ++i)
{ {
if(!this->ComputeMasmOptions(*i)) if(!this->ComputeMasmOptions(*i))
{ {
@ -2239,10 +2225,9 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions()
this->Target->GetType() == cmTarget::SHARED_LIBRARY || this->Target->GetType() == cmTarget::SHARED_LIBRARY ||
this->Target->GetType() == cmTarget::MODULE_LIBRARY) this->Target->GetType() == cmTarget::MODULE_LIBRARY)
{ {
std::vector<std::string> const* configs = for(std::vector<std::string>::const_iterator
this->GlobalGenerator->GetConfigurations(); i = this->Configurations.begin();
for(std::vector<std::string>::const_iterator i = configs->begin(); i != this->Configurations.end(); ++i)
i != configs->end(); ++i)
{ {
if(!this->ComputeLinkOptions(*i)) if(!this->ComputeLinkOptions(*i))
{ {
@ -2591,11 +2576,9 @@ WriteMidlOptions(std::string const& /*config*/,
void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups() void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups()
{ {
std::vector<std::string> *configs = for(std::vector<std::string>::const_iterator
static_cast<cmGlobalVisualStudio7Generator *> i = this->Configurations.begin();
(this->GlobalGenerator)->GetConfigurations(); i != this->Configurations.end(); ++i)
for(std::vector<std::string>::iterator i = configs->begin();
i != configs->end(); ++i)
{ {
std::vector<std::string> includes; std::vector<std::string> includes;
this->LocalGenerator->GetIncludeDirectories(includes, this->LocalGenerator->GetIncludeDirectories(includes,

View File

@ -137,6 +137,7 @@ private:
OptionsMap MasmOptions; OptionsMap MasmOptions;
OptionsMap LinkOptions; OptionsMap LinkOptions;
std::string PathToVcxproj; std::string PathToVcxproj;
std::vector<std::string> Configurations;
cmTarget* Target; cmTarget* Target;
cmGeneratorTarget* GeneratorTarget; cmGeneratorTarget* GeneratorTarget;
cmMakefile* Makefile; cmMakefile* Makefile;