diff options
author | Michael Stürmer <michael.stuermer@schaeffler.com> | 2017-06-13 12:57:59 (GMT) |
---|---|---|
committer | Michael Stürmer <michael.stuermer@schaeffler.com> | 2017-06-13 14:04:22 (GMT) |
commit | c90630c501fed40078b280fe940535ff9545c2c9 (patch) | |
tree | 8700678375be57258a12ea462a2908a0594d61e9 /Source | |
parent | 4ba2d2e3d76cb1ec04c612f9646c47d3f1231ad2 (diff) | |
download | CMake-c90630c501fed40078b280fe940535ff9545c2c9.zip CMake-c90630c501fed40078b280fe940535ff9545c2c9.tar.gz CMake-c90630c501fed40078b280fe940535ff9545c2c9.tar.bz2 |
Vs: add support for VS_CSHARP_* target property for additional file extensions
Fixes: #16726
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 68 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.h | 5 |
2 files changed, 49 insertions, 24 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 46c2894..d935f21 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1565,6 +1565,10 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf) toolHasSettings = true; } + // Collect VS_CSHARP_* property values (if some are set) + std::map<std::string, std::string> sourceFileTags; + this->GetCSharpSourceProperties(sf, sourceFileTags); + if (this->NsightTegra) { // Nsight Tegra needs specific file types to check up-to-dateness. std::string name = cmSystemTools::LowerCase(sf->GetLocation().GetName()); @@ -1681,7 +1685,8 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf) (*this->BuildFileStream) << cmVS10EscapeXML(includeInVsix) << "</IncludeInVSIX>\n"; } - + // write source file specific tags + this->WriteCSharpSourceProperties(sourceFileTags); this->WriteString("</", 2); (*this->BuildFileStream) << tool << ">\n"; } else { @@ -2017,34 +2022,13 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( sourceFileTags["Link"] = link; } } - const cmPropertyMap& props = sf.GetProperties(); - for (cmPropertyMap::const_iterator p = props.begin(); p != props.end(); - ++p) { - static const std::string propNamePrefix = "VS_CSHARP_"; - if (p->first.find(propNamePrefix.c_str()) == 0) { - std::string tagName = p->first.substr(propNamePrefix.length()); - if (!tagName.empty()) { - const std::string val = props.GetPropertyValue(p->first); - if (!val.empty()) { - sourceFileTags[tagName] = val; - } else { - sourceFileTags.erase(tagName); - } - } - } - } + this->GetCSharpSourceProperties(&sf, sourceFileTags); // write source file specific tags if (!sourceFileTags.empty()) { hasFlags = true; (*this->BuildFileStream) << firstString; firstString = ""; - for (CsPropMap::const_iterator i = sourceFileTags.begin(); - i != sourceFileTags.end(); ++i) { - this->WriteString("<", 3); - (*this->BuildFileStream) - << i->first << ">" << cmVS10EscapeXML(i->second) << "</" << i->first - << ">\n"; - } + this->WriteCSharpSourceProperties(sourceFileTags); } } @@ -4280,6 +4264,42 @@ bool cmVisualStudio10TargetGenerator::ForceOld(const std::string& source) const return true; } +void cmVisualStudio10TargetGenerator::GetCSharpSourceProperties( + cmSourceFile const* sf, std::map<std::string, std::string>& tags) +{ + if (csproj == this->ProjectType) { + const cmPropertyMap& props = sf->GetProperties(); + for (cmPropertyMap::const_iterator p = props.begin(); p != props.end(); + ++p) { + static const std::string propNamePrefix = "VS_CSHARP_"; + if (p->first.find(propNamePrefix.c_str()) == 0) { + std::string tagName = p->first.substr(propNamePrefix.length()); + if (!tagName.empty()) { + const std::string val = props.GetPropertyValue(p->first); + if (!val.empty()) { + tags[tagName] = val; + } else { + tags.erase(tagName); + } + } + } + } + } +} + +void cmVisualStudio10TargetGenerator::WriteCSharpSourceProperties( + const std::map<std::string, std::string>& tags) +{ + if (!tags.empty()) { + for (std::map<std::string, std::string>::const_iterator i = tags.begin(); + i != tags.end(); ++i) { + this->WriteString("<", 3); + (*this->BuildFileStream) << i->first << ">" << cmVS10EscapeXML(i->second) + << "</" << i->first << ">\n"; + } + } +} + std::string cmVisualStudio10TargetGenerator::GetCMakeFilePath( const char* relativeFilePath) const { diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 6106615..9c10624 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -153,6 +153,11 @@ private: bool ForceOld(const std::string& source) const; + void GetCSharpSourceProperties(cmSourceFile const* sf, + std::map<std::string, std::string>& tags); + void WriteCSharpSourceProperties( + const std::map<std::string, std::string>& tags); + private: typedef cmVisualStudioGeneratorOptions Options; typedef std::map<std::string, Options*> OptionsMap; |