From e6ff2f8bb4308b055b1f6b193b9cabb9f45c65ae Mon Sep 17 00:00:00 2001 From: Gilles Khouzam Date: Mon, 11 Aug 2014 14:40:09 -0400 Subject: [PATCH] VS: Generate Windows Metadata for WinRT components Inspired-by: Paul Annetts --- Source/cmVisualStudio10TargetGenerator.cxx | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 08daad43d..9e9011d6b 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1774,6 +1774,18 @@ cmVisualStudio10TargetGenerator::WriteLibOptions(std::string const& config) libOptions.OutputFlagMap(*this->BuildFileStream, " "); this->WriteString("\n", 2); } + + // We cannot generate metadata for static libraries. WindowsPhone + // and WindowsStore tools look at GenerateWindowsMetadata in the + // Link tool options even for static libraries. + if(this->GlobalGenerator->TargetsWindowsPhone() || + this->GlobalGenerator->TargetsWindowsStore()) + { + this->WriteString("\n", 2); + this->WriteString("false" + "\n", 3); + this->WriteString("\n", 2); + } } //---------------------------------------------------------------------------- @@ -1955,6 +1967,21 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) linkOptions.AddFlag("ImportLibrary", imLib.c_str()); linkOptions.AddFlag("ProgramDataBaseFile", pdb.c_str()); + + // A Windows Runtime component uses internal .NET metadata, + // so does not have an import library. + if(this->Target->GetPropertyAsBool("VS_WINRT_COMPONENT")) + { + linkOptions.AddFlag("GenerateWindowsMetadata", "true"); + } + else if (this->GlobalGenerator->TargetsWindowsPhone() || + this->GlobalGenerator->TargetsWindowsStore()) + { + // WindowsPhone and WindowsStore components are in an app container + // and produce WindowsMetadata. If we are not producing a WINRT + // component, then do not generate the metadata here. + linkOptions.AddFlag("GenerateWindowsMetadata", "false"); + } } linkOptions.Parse(flags.c_str());