mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-20 04:24:36 +08:00
VS: add VS_CSHARP_<tagname> sourcefile property
This commit is contained in:

committed by
Brad King

parent
6cbad490c2
commit
9588d0a2e2
@@ -366,6 +366,7 @@ Properties on Source Files
|
|||||||
/prop_sf/SKIP_AUTOUIC
|
/prop_sf/SKIP_AUTOUIC
|
||||||
/prop_sf/SYMBOLIC
|
/prop_sf/SYMBOLIC
|
||||||
/prop_sf/VS_COPY_TO_OUT_DIR
|
/prop_sf/VS_COPY_TO_OUT_DIR
|
||||||
|
/prop_sf/VS_CSHARP_tagname
|
||||||
/prop_sf/VS_DEPLOYMENT_CONTENT
|
/prop_sf/VS_DEPLOYMENT_CONTENT
|
||||||
/prop_sf/VS_DEPLOYMENT_LOCATION
|
/prop_sf/VS_DEPLOYMENT_LOCATION
|
||||||
/prop_sf/VS_INCLUDE_IN_VSIX
|
/prop_sf/VS_INCLUDE_IN_VSIX
|
||||||
|
19
Help/prop_sf/VS_CSHARP_tagname.rst
Normal file
19
Help/prop_sf/VS_CSHARP_tagname.rst
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
VS_CSHARP_<tagname>
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
Visual Studio and CSharp source-file-specific configuration.
|
||||||
|
|
||||||
|
Tell the Visual Studio generator to set the source file tag
|
||||||
|
``<tagname>`` to a given value in the generated Visual Studio CSharp
|
||||||
|
project. Ignored on other generators and languages. This property
|
||||||
|
can be used to define dependencies between source files or set any
|
||||||
|
other Visual Studio specific parameters.
|
||||||
|
|
||||||
|
Example usage:
|
||||||
|
|
||||||
|
.. code-block:: cmake
|
||||||
|
|
||||||
|
set_source_files_property(<filename>
|
||||||
|
PROPERTIES
|
||||||
|
VS_CSHARP_DependentUpon <other file>
|
||||||
|
VS_CSHARP_SubType "Form")
|
@@ -34,15 +34,6 @@ C#
|
|||||||
Visual Studio (``VS_*``) are worth a look (for setting toolset
|
Visual Studio (``VS_*``) are worth a look (for setting toolset
|
||||||
versions, root namespaces, assembly icons, ...).
|
versions, root namespaces, assembly icons, ...).
|
||||||
|
|
||||||
* Auto-linking in ``.csproj`` files: In C#/.NET development with
|
|
||||||
Visual Studio there are a number of visual editors used which
|
|
||||||
generate code. Both the generated files and the ones edited
|
|
||||||
with the UI are connected in the ``.csproj`` file using
|
|
||||||
``<DependentUpon>`` tags. If CMake finds within a C# project
|
|
||||||
any source file with extension ``.Designer.cs`` or ``.xaml.cs``,
|
|
||||||
it checks sibling files with extension ``.xaml``, ``.settings``,
|
|
||||||
``.resx`` or ``.cs`` and establishes the dependency connection.
|
|
||||||
|
|
||||||
CUDA
|
CUDA
|
||||||
^^^^
|
^^^^
|
||||||
|
|
||||||
|
@@ -86,6 +86,7 @@ public:
|
|||||||
|
|
||||||
// Get the properties
|
// Get the properties
|
||||||
cmPropertyMap& GetProperties() { return this->Properties; }
|
cmPropertyMap& GetProperties() { return this->Properties; }
|
||||||
|
const cmPropertyMap& GetProperties() const { return this->Properties; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether the given source file location could refer to this
|
* Check whether the given source file location could refer to this
|
||||||
|
@@ -680,6 +680,7 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup()
|
|||||||
if (const char* g = (*oi)->GetProperty("VS_RESOURCE_GENERATOR")) {
|
if (const char* g = (*oi)->GetProperty("VS_RESOURCE_GENERATOR")) {
|
||||||
generator = g;
|
generator = g;
|
||||||
}
|
}
|
||||||
|
if (!generator.empty()) {
|
||||||
this->WriteString("<Generator>", 3);
|
this->WriteString("<Generator>", 3);
|
||||||
(*this->BuildFileStream) << cmVS10EscapeXML(generator)
|
(*this->BuildFileStream) << cmVS10EscapeXML(generator)
|
||||||
<< "</Generator>\n";
|
<< "</Generator>\n";
|
||||||
@@ -693,7 +694,26 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup()
|
|||||||
}
|
}
|
||||||
this->ConvertToWindowsSlash(designerResource);
|
this->ConvertToWindowsSlash(designerResource);
|
||||||
this->WriteString("<LastGenOutput>", 3);
|
this->WriteString("<LastGenOutput>", 3);
|
||||||
(*this->BuildFileStream) << designerResource << "</LastGenOutput>\n";
|
(*this->BuildFileStream) << designerResource
|
||||||
|
<< "</LastGenOutput>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const cmPropertyMap& props = (*oi)->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()) {
|
||||||
|
std::string value = props.GetPropertyValue(p->first);
|
||||||
|
if (!value.empty()) {
|
||||||
|
this->WriteString("<", 3);
|
||||||
|
(*this->BuildFileStream) << tagName << ">";
|
||||||
|
(*this->BuildFileStream) << cmVS10EscapeXML(value);
|
||||||
|
(*this->BuildFileStream) << "</" << tagName << ">\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1940,42 +1960,21 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
|
|||||||
sourceFileTags["Link"] = link;
|
sourceFileTags["Link"] = link;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// check if file is a generated .Designer.cs or .xaml.cs file
|
const cmPropertyMap& props = sf.GetProperties();
|
||||||
// to add additional necessary tags
|
for (cmPropertyMap::const_iterator p = props.begin(); p != props.end();
|
||||||
const std::string fileExtension =
|
++p) {
|
||||||
cmsys::SystemTools::GetFilenameExtension(f);
|
static const std::string propNamePrefix = "VS_CSHARP_";
|
||||||
if (fileExtension == ".Designer.cs" || fileExtension == ".xaml.cs") {
|
if (p->first.find(propNamePrefix.c_str()) == 0) {
|
||||||
f = f.substr(0, f.length() - fileExtension.length());
|
std::string tagName = p->first.substr(propNamePrefix.length());
|
||||||
if (sourceFileTags.find("Link") == sourceFileTags.end() &&
|
if (!tagName.empty()) {
|
||||||
!this->InSourceBuild) {
|
const std::string val = props.GetPropertyValue(p->first);
|
||||||
// add link fallback
|
if (!val.empty()) {
|
||||||
sourceFileTags["Link"] =
|
sourceFileTags[tagName] = val;
|
||||||
cmsys::SystemTools::GetFilenameName(f) + fileExtension;
|
} else {
|
||||||
}
|
sourceFileTags.erase(tagName);
|
||||||
std::vector<std::string> extensions;
|
|
||||||
extensions.push_back(".resx");
|
|
||||||
extensions.push_back(".settings");
|
|
||||||
extensions.push_back(".xaml");
|
|
||||||
extensions.push_back(".cs");
|
|
||||||
std::string dependencyExtension;
|
|
||||||
for (std::vector<std::string>::iterator i = extensions.begin();
|
|
||||||
i != extensions.end(); ++i) {
|
|
||||||
if (cmsys::SystemTools::FileExists(f + *i)) {
|
|
||||||
dependencyExtension = *i;
|
|
||||||
// There should never be more than one match. Otherwise
|
|
||||||
// one cannot tell on which match the file depends.
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dependencyExtension == ".resx") {
|
|
||||||
sourceFileTags["DesignTime"] = "True";
|
|
||||||
sourceFileTags["AutoGen"] = "True";
|
|
||||||
} else if (dependencyExtension == ".settings") {
|
|
||||||
sourceFileTags["DesignTimeSharedInput"] = "True";
|
|
||||||
sourceFileTags["AutoGen"] = "True";
|
|
||||||
}
|
}
|
||||||
sourceFileTags["DependentUpon"] =
|
|
||||||
cmsys::SystemTools::GetFilenameName(f) + dependencyExtension;
|
|
||||||
}
|
}
|
||||||
// write source file specific tags
|
// write source file specific tags
|
||||||
if (!sourceFileTags.empty()) {
|
if (!sourceFileTags.empty()) {
|
||||||
|
Reference in New Issue
Block a user