From 0ae372daee75e6d5305ec9f934c2adce3074ca5d Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 15 Feb 2024 13:53:01 -0500 Subject: VS: Factor out common MS tool configuration De-duplicate code writing `PlatformToolset`. --- Source/cmVisualStudio10TargetGenerator.cxx | 31 +++++++++++++++--------------- Source/cmVisualStudio10TargetGenerator.h | 2 ++ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index d572f30..ced7acd 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1512,7 +1512,6 @@ void cmVisualStudio10TargetGenerator::WriteCEDebugProjectConfigurationValues( void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValues( Elem& e1, std::string const& config) { - cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator; cmValue mfcFlag = this->Makefile->GetDefinition("CMAKE_MFC_FLAG"); if (mfcFlag) { std::string const mfcFlagValue = @@ -1543,12 +1542,9 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValues( } else { e1.Element("CharacterSet", "MultiByte"); } - if (cmValue projectToolsetOverride = - this->GeneratorTarget->GetProperty("VS_PLATFORM_TOOLSET")) { - e1.Element("PlatformToolset", *projectToolsetOverride); - } else if (const char* toolset = gg->GetPlatformToolset()) { - e1.Element("PlatformToolset", toolset); - } + + this->WriteMSToolConfigurationValuesCommon(e1, config); + if (this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT") || this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_EXTENSIONS")) { e1.Element("WindowsAppContainer", "true"); @@ -1579,8 +1575,6 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged( return; } - cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator; - Options& o = *(this->ClOptions[config]); if (o.IsDebug()) { @@ -1598,12 +1592,7 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged( o.RemoveFlag("Platform"); } - if (cmValue projectToolsetOverride = - this->GeneratorTarget->GetProperty("VS_PLATFORM_TOOLSET")) { - e1.Element("PlatformToolset", *projectToolsetOverride); - } else if (const char* toolset = gg->GetPlatformToolset()) { - e1.Element("PlatformToolset", toolset); - } + this->WriteMSToolConfigurationValuesCommon(e1, config); std::string postfixName = cmStrCat(cmSystemTools::UpperCase(config), "_POSTFIX"); @@ -1623,6 +1612,18 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged( 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( Elem& e1, std::string const&) diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 2080e9e..bafd5e9 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -72,6 +72,8 @@ private: void WriteCEDebugProjectConfigurationValues(Elem& e0); void WriteMSToolConfigurationValuesManaged(Elem& e1, std::string const& config); + void WriteMSToolConfigurationValuesCommon(Elem& e1, + std::string const& config); void WriteHeaderSource(Elem& e1, cmSourceFile const* sf, ConfigToSettings const& toolSettings); void WriteExtraSource(Elem& e1, cmSourceFile const* sf, -- cgit v0.12