mirror of
https://github.com/reactos/CMake.git
synced 2025-04-02 07:11:33 +00:00
Merge topic 'vs-dotnet-custom-reference-tags'
07ec212a VS: add target property VS_DOTNET_REFERENCEPROP_<refname>_TAG_<tagname> Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !960
This commit is contained in:
commit
c8b4da5838
@ -291,6 +291,7 @@ Properties on Targets
|
||||
/prop_tgt/VS_DEBUGGER_WORKING_DIRECTORY
|
||||
/prop_tgt/VS_DESKTOP_EXTENSIONS_VERSION
|
||||
/prop_tgt/VS_DOTNET_REFERENCE_refname
|
||||
/prop_tgt/VS_DOTNET_REFERENCEPROP_refname_TAG_tagname
|
||||
/prop_tgt/VS_DOTNET_REFERENCES
|
||||
/prop_tgt/VS_DOTNET_REFERENCES_COPY_LOCAL
|
||||
/prop_tgt/VS_DOTNET_TARGET_FRAMEWORK_VERSION
|
||||
|
@ -0,0 +1,11 @@
|
||||
VS_DOTNET_REFERENCEPROP_<refname>_TAG_<tagname>
|
||||
-----------------------------------------------
|
||||
|
||||
Visual Studio managed project .NET reference with name ``<refname>``
|
||||
and hint path.
|
||||
|
||||
Adds one .NET reference to generated Visual Studio project. The
|
||||
reference will have the name ``<refname>`` and will point to the
|
||||
assembly given as value of the property.
|
||||
|
||||
See also the :prop_tgt:`VS_DOTNET_REFERENCE_<refname>` target property.
|
@ -0,0 +1,6 @@
|
||||
vs-dotnet-custom-reference-tags
|
||||
-------------------------------
|
||||
|
||||
* The :prop_tgt:`VS_DOTNET_REFERENCEPROP_<refname>_TAG_<tagname>`
|
||||
target property was added to support custom XML tags for reference
|
||||
assemblies in C# targets.
|
@ -658,9 +658,39 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReference(
|
||||
this->WriteString("<HintPath>", 3);
|
||||
(*this->BuildFileStream) << hint << "</HintPath>\n";
|
||||
}
|
||||
this->WriteDotNetReferenceCustomTags(ref);
|
||||
this->WriteString("</Reference>\n", 2);
|
||||
}
|
||||
|
||||
void cmVisualStudio10TargetGenerator::WriteDotNetReferenceCustomTags(
|
||||
std::string const& ref)
|
||||
{
|
||||
|
||||
static const std::string refpropPrefix = "VS_DOTNET_REFERENCEPROP_";
|
||||
static const std::string refpropInfix = "_TAG_";
|
||||
const std::string refPropFullPrefix = refpropPrefix + ref + refpropInfix;
|
||||
typedef std::map<std::string, std::string> CustomTags;
|
||||
CustomTags tags;
|
||||
cmPropertyMap const& props = this->GeneratorTarget->Target->GetProperties();
|
||||
for (cmPropertyMap::const_iterator i = props.begin(); i != props.end();
|
||||
++i) {
|
||||
if (i->first.find(refPropFullPrefix) == 0) {
|
||||
std::string refTag = i->first.substr(refPropFullPrefix.length());
|
||||
std::string refVal = i->second.GetValue();
|
||||
if (!refTag.empty() && !refVal.empty()) {
|
||||
tags[refTag] = refVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (CustomTags::const_iterator tag = tags.begin(); tag != tags.end();
|
||||
++tag) {
|
||||
this->WriteString("<", 3);
|
||||
(*this->BuildFileStream) << tag->first << ">"
|
||||
<< cmVS10EscapeXML(tag->second) << "</"
|
||||
<< tag->first << ">\n";
|
||||
}
|
||||
}
|
||||
|
||||
void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup()
|
||||
{
|
||||
std::vector<cmSourceFile const*> resxObjs;
|
||||
@ -3500,6 +3530,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences()
|
||||
(*this->BuildFileStream) << "</Project>\n";
|
||||
this->WriteString("<Name>", 3);
|
||||
(*this->BuildFileStream) << name << "</Name>\n";
|
||||
this->WriteDotNetReferenceCustomTags(name);
|
||||
this->WriteString("</ProjectReference>\n", 2);
|
||||
}
|
||||
this->WriteString("</ItemGroup>\n", 1);
|
||||
|
@ -66,6 +66,7 @@ private:
|
||||
void WriteAllSources();
|
||||
void WriteDotNetReferences();
|
||||
void WriteDotNetReference(std::string const& ref, std::string const& hint);
|
||||
void WriteDotNetReferenceCustomTags(std::string const& ref);
|
||||
void WriteEmbeddedResourceGroup();
|
||||
void WriteWinRTReferences();
|
||||
void WriteWinRTPackageCertificateKeyFile();
|
||||
|
@ -4,3 +4,4 @@ run_cmake(VsTargetsFileReferences)
|
||||
run_cmake(VsCustomProps)
|
||||
run_cmake(VsDebuggerWorkingDir)
|
||||
run_cmake(VsCSharpCustomTags)
|
||||
run_cmake(VsCSharpReferenceProps)
|
||||
|
@ -0,0 +1,49 @@
|
||||
set(csProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.csproj")
|
||||
if(NOT EXISTS "${csProjectFile}")
|
||||
set(RunCMake_TEST_FAILED "Project file ${csProjectFile} does not exist.")
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(test1Reference "System")
|
||||
set(test1Tag "Hello")
|
||||
set(test1Value "World")
|
||||
|
||||
set(test2Reference "foo2")
|
||||
set(test2Tag "Hallo")
|
||||
set(test2Value "Welt")
|
||||
|
||||
set(tag1Found FALSE)
|
||||
set(ref1Found FALSE)
|
||||
|
||||
file(STRINGS "${csProjectFile}" lines)
|
||||
|
||||
foreach(i 1 2)
|
||||
set(testReference "${test${i}Reference}")
|
||||
set(testTag "${test${i}Tag}")
|
||||
set(testValue "${test${i}Value}")
|
||||
foreach(line IN LISTS lines)
|
||||
if(line MATCHES "^ *<(Project|)Reference .*>$")
|
||||
set(validTag FALSE)
|
||||
if(line MATCHES "^ *<(Project|)Reference .*\".*${testReference}.*\".*>$")
|
||||
set(validTag TRUE)
|
||||
message(STATUS "foo.csproj is using reference ${testReference}")
|
||||
set(ref${i}Found TRUE)
|
||||
endif()
|
||||
endif()
|
||||
if(line MATCHES "^ *<${testTag}>${testValue}</${testTag}>$")
|
||||
if(validTag)
|
||||
message(STATUS "foo.csproj reference ${testReference} has tag ${testTag}")
|
||||
set(tag${i}Found TRUE)
|
||||
else()
|
||||
message(STATUS "tag ${testTag} found in wrong place!")
|
||||
set(tag${i}Found FALSE)
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
if(NOT tag1Found OR NOT ref1Found OR
|
||||
NOT tag2Found OR NOT ref2Found)
|
||||
set(RunCMake_TEST_FAILED "Custom reference XML tag not found.")
|
||||
return()
|
||||
endif()
|
19
Tests/RunCMake/VS10Project/VsCSharpReferenceProps.cmake
Normal file
19
Tests/RunCMake/VS10Project/VsCSharpReferenceProps.cmake
Normal file
@ -0,0 +1,19 @@
|
||||
enable_language(CSharp)
|
||||
add_library(foo foo.cs)
|
||||
add_library(foo2 foo.cs)
|
||||
|
||||
set(test1Reference "System")
|
||||
set(test1Tag "Hello")
|
||||
set(test1Value "World")
|
||||
|
||||
set(test2Reference "foo2")
|
||||
set(test2Tag "Hallo")
|
||||
set(test2Value "Welt")
|
||||
|
||||
target_link_libraries(foo foo2)
|
||||
|
||||
set_target_properties(foo PROPERTIES
|
||||
VS_DOTNET_REFERENCES "${test1Reference};Blubb"
|
||||
VS_DOTNET_REFERENCEPROP_${test1Reference}_TAG_${test1Tag} ${test1Value}
|
||||
VS_DOTNET_REFERENCEPROP_${test2Reference}_TAG_${test2Tag} ${test2Value}
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user