mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-02 03:39:43 -06:00
cmVisualStudio10TargetGenerator: Factor out helper to write VS_SETTINGS
This commit is contained in:
committed by
Brad King
parent
ed9abd9977
commit
3bf013632d
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user