VS: Factor out common MS tool configuration

De-duplicate code writing `PlatformToolset`.
This commit is contained in:
Brad King 2024-02-15 13:53:01 -05:00
parent 14b0ebd4ca
commit 0ae372daee
2 changed files with 18 additions and 15 deletions

View File

@ -1512,7 +1512,6 @@ void cmVisualStudio10TargetGenerator::WriteCEDebugProjectConfigurationValues(
void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValues( void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValues(
Elem& e1, std::string const& config) Elem& e1, std::string const& config)
{ {
cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
cmValue mfcFlag = this->Makefile->GetDefinition("CMAKE_MFC_FLAG"); cmValue mfcFlag = this->Makefile->GetDefinition("CMAKE_MFC_FLAG");
if (mfcFlag) { if (mfcFlag) {
std::string const mfcFlagValue = std::string const mfcFlagValue =
@ -1543,12 +1542,9 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValues(
} else { } else {
e1.Element("CharacterSet", "MultiByte"); e1.Element("CharacterSet", "MultiByte");
} }
if (cmValue projectToolsetOverride =
this->GeneratorTarget->GetProperty("VS_PLATFORM_TOOLSET")) { this->WriteMSToolConfigurationValuesCommon(e1, config);
e1.Element("PlatformToolset", *projectToolsetOverride);
} else if (const char* toolset = gg->GetPlatformToolset()) {
e1.Element("PlatformToolset", toolset);
}
if (this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT") || if (this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT") ||
this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_EXTENSIONS")) { this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_EXTENSIONS")) {
e1.Element("WindowsAppContainer", "true"); e1.Element("WindowsAppContainer", "true");
@ -1579,8 +1575,6 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged(
return; return;
} }
cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
Options& o = *(this->ClOptions[config]); Options& o = *(this->ClOptions[config]);
if (o.IsDebug()) { if (o.IsDebug()) {
@ -1598,12 +1592,7 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged(
o.RemoveFlag("Platform"); o.RemoveFlag("Platform");
} }
if (cmValue projectToolsetOverride = this->WriteMSToolConfigurationValuesCommon(e1, config);
this->GeneratorTarget->GetProperty("VS_PLATFORM_TOOLSET")) {
e1.Element("PlatformToolset", *projectToolsetOverride);
} else if (const char* toolset = gg->GetPlatformToolset()) {
e1.Element("PlatformToolset", toolset);
}
std::string postfixName = std::string postfixName =
cmStrCat(cmSystemTools::UpperCase(config), "_POSTFIX"); cmStrCat(cmSystemTools::UpperCase(config), "_POSTFIX");
@ -1623,6 +1612,18 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged(
oh.OutputFlagMap(); oh.OutputFlagMap();
} }
void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesCommon(
Elem& e1, std::string const& config)
{
cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
if (cmValue projectToolsetOverride =
this->GeneratorTarget->GetProperty("VS_PLATFORM_TOOLSET")) {
e1.Element("PlatformToolset", *projectToolsetOverride);
} else if (const char* toolset = gg->GetPlatformToolset()) {
e1.Element("PlatformToolset", toolset);
}
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmVisualStudio10TargetGenerator::WriteNsightTegraConfigurationValues( void cmVisualStudio10TargetGenerator::WriteNsightTegraConfigurationValues(
Elem& e1, std::string const&) Elem& e1, std::string const&)

View File

@ -72,6 +72,8 @@ private:
void WriteCEDebugProjectConfigurationValues(Elem& e0); void WriteCEDebugProjectConfigurationValues(Elem& e0);
void WriteMSToolConfigurationValuesManaged(Elem& e1, void WriteMSToolConfigurationValuesManaged(Elem& e1,
std::string const& config); std::string const& config);
void WriteMSToolConfigurationValuesCommon(Elem& e1,
std::string const& config);
void WriteHeaderSource(Elem& e1, cmSourceFile const* sf, void WriteHeaderSource(Elem& e1, cmSourceFile const* sf,
ConfigToSettings const& toolSettings); ConfigToSettings const& toolSettings);
void WriteExtraSource(Elem& e1, cmSourceFile const* sf, void WriteExtraSource(Elem& e1, cmSourceFile const* sf,