VS: Fix WinRT component references

WinRT components need to be referenced in a similar way that managed
code libraries are referenced.  Validate that the library reference is a
WinRT component and reference it through the project.

Add test coverage for `VS_WINRT_COMPONENT`.  While at it, fix the IOT
reference failing on Win10 SDK 17763 which doesn't include it anymore.

Fixes: #18846
This commit is contained in:
Gilles Khouzam
2019-02-01 09:40:58 -08:00
committed by Brad King
parent 6c21722adb
commit cff026dbc0
6 changed files with 54 additions and 4 deletions

View File

@@ -3884,8 +3884,8 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences(Elem& e0)
this->WriteDotNetReferenceCustomTags(e2, name);
// If the dependency target is not managed (compiled with /clr or
// C# target) we cannot reference it and have to set
// 'ReferenceOutputAssembly' to false.
// C# target) and not a WinRT component we cannot reference it and
// have to set 'ReferenceOutputAssembly' to false.
auto referenceNotManaged =
dt->GetManagedType("") < cmGeneratorTarget::ManagedType::Mixed;
// Workaround to check for manually set /clr flags.
@@ -3902,6 +3902,12 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences(Elem& e0)
if (referenceNotManaged && dt->GetType() == cmStateEnums::STATIC_LIBRARY) {
referenceNotManaged = !dt->IsCSharpOnly();
}
// Referencing WinRT components is okay.
if (referenceNotManaged) {
referenceNotManaged = !dt->GetPropertyAsBool("VS_WINRT_COMPONENT");
}
if (referenceNotManaged) {
e2.Element("ReferenceOutputAssembly", "false");
e2.Element("CopyToOutputDirectory", "Never");