diff options
author | Steven Boswell <ulatekh@yahoo.com> | 2021-09-03 00:09:37 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-09-09 18:19:28 (GMT) |
commit | 3bf013632d26241672897e4aab10823d219f025c (patch) | |
tree | 8f86a1f837755cd7f8a5c3fd473852930243cb0d | |
parent | ed9abd99772cbdcb2e4dd195eb4a62104ce86c95 (diff) | |
download | CMake-3bf013632d26241672897e4aab10823d219f025c.zip CMake-3bf013632d26241672897e4aab10823d219f025c.tar.gz CMake-3bf013632d26241672897e4aab10823d219f025c.tar.bz2 |
cmVisualStudio10TargetGenerator: Factor out helper to write VS_SETTINGS
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 71 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.h | 11 |
2 files changed, 46 insertions, 36 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 9407228..c7f608b 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1864,8 +1864,8 @@ bool cmVisualStudio10TargetGenerator::PropertyIsSameInAllConfigs( return true; } -void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1, - cmSourceFile const* sf) +void cmVisualStudio10TargetGenerator::WriteExtraSource( + Elem& e1, cmSourceFile const* sf, ConfigToSettings& toolSettings) { bool toolHasSettings = false; const char* tool = "None"; @@ -1876,10 +1876,6 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1, std::string copyToOutDir; std::string includeInVsix; std::string ext = cmSystemTools::LowerCase(sf->GetExtension()); - ConfigToSettings toolSettings; - for (const auto& config : this->Configurations) { - toolSettings[config]; - } if (this->ProjectType == csproj && !this->InSourceBuild) { toolHasSettings = true; @@ -2047,10 +2043,6 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1, } } - if (cmProp p = sf->GetProperty("VS_SETTINGS")) { - ParseSettingsProperty(*p, toolSettings); - } - if (!toolSettings.empty()) { toolHasSettings = true; } @@ -2060,27 +2052,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1, if (toolHasSettings) { e2.SetHasElements(); - std::vector<std::string> writtenSettings; - for (const auto& configSettings : toolSettings) { - for (const auto& setting : configSettings.second) { - - if (std::find(writtenSettings.begin(), writtenSettings.end(), - setting.first) != writtenSettings.end()) { - continue; - } - - if (PropertyIsSameInAllConfigs(toolSettings, setting.first)) { - e2.Element(setting.first, setting.second); - writtenSettings.push_back(setting.first); - } else { - e2.WritePlatformConfigTag(setting.first, - "'$(Configuration)|$(Platform)'=='" + - configSettings.first + "|" + - this->Platform + "'", - setting.second); - } - } - } + this->FinishWritingSource(e2, toolSettings); if (!deployContent.empty()) { cmGeneratorExpression ge; @@ -2217,6 +2189,15 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0) // Skip explicit reference to CMakeLists.txt source. continue; } + + ConfigToSettings toolSettings; + for (const auto& config : this->Configurations) { + toolSettings[config]; + } + if (cmProp p = si.Source->GetProperty("VS_SETTINGS")) { + ParseSettingsProperty(*p, toolSettings); + } + const char* tool = nullptr; switch (si.Kind) { case cmGeneratorTarget::SourceKindAppManifest: @@ -2244,7 +2225,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0) } break; case cmGeneratorTarget::SourceKindExtra: - this->WriteExtraSource(e1, si.Source); + this->WriteExtraSource(e1, si.Source, toolSettings); break; case cmGeneratorTarget::SourceKindHeader: this->WriteHeaderSource(e1, si.Source); @@ -2365,6 +2346,32 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0) } } +void cmVisualStudio10TargetGenerator::FinishWritingSource( + Elem& e2, ConfigToSettings const& toolSettings) +{ + std::vector<std::string> writtenSettings; + for (const auto& configSettings : toolSettings) { + for (const auto& setting : configSettings.second) { + + if (std::find(writtenSettings.begin(), writtenSettings.end(), + setting.first) != writtenSettings.end()) { + continue; + } + + if (PropertyIsSameInAllConfigs(toolSettings, setting.first)) { + e2.Element(setting.first, setting.second); + writtenSettings.push_back(setting.first); + } else { + e2.WritePlatformConfigTag(setting.first, + "'$(Configuration)|$(Platform)'=='" + + configSettings.first + "|" + + this->Platform + "'", + setting.second); + } + } + } +} + void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( Elem& e2, cmSourceFile const* source) { diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 55c5444..4de134f 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -58,6 +58,10 @@ private: struct Elem; struct OptionsHelper; + using ConfigToSettings = + std::unordered_map<std::string, + std::unordered_map<std::string, std::string>>; + std::string ConvertPath(std::string const& path, bool forceRelative); std::string CalcCondition(const std::string& config) const; void WriteProjectConfigurations(Elem& e0); @@ -67,11 +71,13 @@ private: void WriteMSToolConfigurationValuesManaged(Elem& e1, std::string const& config); void WriteHeaderSource(Elem& e1, cmSourceFile const* sf); - void WriteExtraSource(Elem& e1, cmSourceFile const* sf); + void WriteExtraSource(Elem& e1, cmSourceFile const* sf, + ConfigToSettings& toolSettings); void WriteNsightTegraConfigurationValues(Elem& e1, std::string const& config); void WriteAndroidConfigurationValues(Elem& e1, std::string const& config); void WriteSource(Elem& e2, cmSourceFile const* sf); + void FinishWritingSource(Elem& e2, ConfigToSettings const& toolSettings); void WriteExcludeFromBuild(Elem& e2, std::vector<size_t> const& exclude_configs); void WriteAllSources(Elem& e0); @@ -252,9 +258,6 @@ private: void ClassifyAllConfigSources(); void ClassifyAllConfigSource(cmGeneratorTarget::AllConfigSource const& acs); - using ConfigToSettings = - std::unordered_map<std::string, - std::unordered_map<std::string, std::string>>; std::unordered_map<std::string, ConfigToSettings> ParsedToolTargetSettings; bool PropertyIsSameInAllConfigs(const ConfigToSettings& toolSettings, const std::string& propName); |