mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 13:20:47 -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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1,
|
void cmVisualStudio10TargetGenerator::WriteExtraSource(
|
||||||
cmSourceFile const* sf)
|
Elem& e1, cmSourceFile const* sf, ConfigToSettings& toolSettings)
|
||||||
{
|
{
|
||||||
bool toolHasSettings = false;
|
bool toolHasSettings = false;
|
||||||
const char* tool = "None";
|
const char* tool = "None";
|
||||||
@@ -1876,10 +1876,6 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1,
|
|||||||
std::string copyToOutDir;
|
std::string copyToOutDir;
|
||||||
std::string includeInVsix;
|
std::string includeInVsix;
|
||||||
std::string ext = cmSystemTools::LowerCase(sf->GetExtension());
|
std::string ext = cmSystemTools::LowerCase(sf->GetExtension());
|
||||||
ConfigToSettings toolSettings;
|
|
||||||
for (const auto& config : this->Configurations) {
|
|
||||||
toolSettings[config];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this->ProjectType == csproj && !this->InSourceBuild) {
|
if (this->ProjectType == csproj && !this->InSourceBuild) {
|
||||||
toolHasSettings = true;
|
toolHasSettings = true;
|
||||||
@@ -2047,10 +2043,6 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmProp p = sf->GetProperty("VS_SETTINGS")) {
|
|
||||||
ParseSettingsProperty(*p, toolSettings);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!toolSettings.empty()) {
|
if (!toolSettings.empty()) {
|
||||||
toolHasSettings = true;
|
toolHasSettings = true;
|
||||||
}
|
}
|
||||||
@@ -2060,27 +2052,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1,
|
|||||||
if (toolHasSettings) {
|
if (toolHasSettings) {
|
||||||
e2.SetHasElements();
|
e2.SetHasElements();
|
||||||
|
|
||||||
std::vector<std::string> writtenSettings;
|
this->FinishWritingSource(e2, toolSettings);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!deployContent.empty()) {
|
if (!deployContent.empty()) {
|
||||||
cmGeneratorExpression ge;
|
cmGeneratorExpression ge;
|
||||||
@@ -2217,6 +2189,15 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0)
|
|||||||
// Skip explicit reference to CMakeLists.txt source.
|
// Skip explicit reference to CMakeLists.txt source.
|
||||||
continue;
|
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;
|
const char* tool = nullptr;
|
||||||
switch (si.Kind) {
|
switch (si.Kind) {
|
||||||
case cmGeneratorTarget::SourceKindAppManifest:
|
case cmGeneratorTarget::SourceKindAppManifest:
|
||||||
@@ -2244,7 +2225,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case cmGeneratorTarget::SourceKindExtra:
|
case cmGeneratorTarget::SourceKindExtra:
|
||||||
this->WriteExtraSource(e1, si.Source);
|
this->WriteExtraSource(e1, si.Source, toolSettings);
|
||||||
break;
|
break;
|
||||||
case cmGeneratorTarget::SourceKindHeader:
|
case cmGeneratorTarget::SourceKindHeader:
|
||||||
this->WriteHeaderSource(e1, si.Source);
|
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(
|
void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
|
||||||
Elem& e2, cmSourceFile const* source)
|
Elem& e2, cmSourceFile const* source)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -58,6 +58,10 @@ private:
|
|||||||
struct Elem;
|
struct Elem;
|
||||||
struct OptionsHelper;
|
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 ConvertPath(std::string const& path, bool forceRelative);
|
||||||
std::string CalcCondition(const std::string& config) const;
|
std::string CalcCondition(const std::string& config) const;
|
||||||
void WriteProjectConfigurations(Elem& e0);
|
void WriteProjectConfigurations(Elem& e0);
|
||||||
@@ -67,11 +71,13 @@ private:
|
|||||||
void WriteMSToolConfigurationValuesManaged(Elem& e1,
|
void WriteMSToolConfigurationValuesManaged(Elem& e1,
|
||||||
std::string const& config);
|
std::string const& config);
|
||||||
void WriteHeaderSource(Elem& e1, cmSourceFile const* sf);
|
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,
|
void WriteNsightTegraConfigurationValues(Elem& e1,
|
||||||
std::string const& config);
|
std::string const& config);
|
||||||
void WriteAndroidConfigurationValues(Elem& e1, std::string const& config);
|
void WriteAndroidConfigurationValues(Elem& e1, std::string const& config);
|
||||||
void WriteSource(Elem& e2, cmSourceFile const* sf);
|
void WriteSource(Elem& e2, cmSourceFile const* sf);
|
||||||
|
void FinishWritingSource(Elem& e2, ConfigToSettings const& toolSettings);
|
||||||
void WriteExcludeFromBuild(Elem& e2,
|
void WriteExcludeFromBuild(Elem& e2,
|
||||||
std::vector<size_t> const& exclude_configs);
|
std::vector<size_t> const& exclude_configs);
|
||||||
void WriteAllSources(Elem& e0);
|
void WriteAllSources(Elem& e0);
|
||||||
@@ -252,9 +258,6 @@ private:
|
|||||||
void ClassifyAllConfigSources();
|
void ClassifyAllConfigSources();
|
||||||
void ClassifyAllConfigSource(cmGeneratorTarget::AllConfigSource const& acs);
|
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;
|
std::unordered_map<std::string, ConfigToSettings> ParsedToolTargetSettings;
|
||||||
bool PropertyIsSameInAllConfigs(const ConfigToSettings& toolSettings,
|
bool PropertyIsSameInAllConfigs(const ConfigToSettings& toolSettings,
|
||||||
const std::string& propName);
|
const std::string& propName);
|
||||||
|
|||||||
Reference in New Issue
Block a user