Background: I need to build a Windows Runtime Component as part of a system that's set up to use CMake to generate its build system. As a preparatory step I'm trying to build it on the command line.
Starting with a bare-bones .idl file (MyType.idl)
namespace NS
{
[default_interface]
runtimeclass MyType
{
}
}
I'm trying to generate a matching .winmd file using the midlrt.exe tool. The following command line (split across several lines for readability)
midlrt
/metadata_dir "%WindowsSdkDir%References\%WindowsSDKVersion%Windows.Foundation.FoundationContract\3.0.0.0"
/reference "%WindowsSdkDir%References\%WindowsSDKVersion%Windows.Foundation.FoundationContract\3.0.0.0\Windows.Foundation.FoundationContract.winmd"
/winmd MyType.winmd
/notlb
/winrt
/nomidl
/nologo
/enum_class
/ns_prefix
/client none
/server none
MyType.idl
generates the MyType.winmd file just fine, but I don't know why. I'm particularly confused about the /metadata_dir
and /reference
options. Running midlrt /help
offers the following:
/metadata_dir Specify one or more directories containing platform metadata files
/reference Specify one or more WinMD files to import
The official documentation on /metadata_dir doesn't add much to that (other than a confusing remark: "Use this switch to specify the location of the main metadata file for Windows, which is named windows.winmd."). There is no documentation for /reference
.
Here's what I need help with:
- What do I really need to pass for the
/metadata_dir
option? As used in the command line above it looks like a redundant replication of part of the/reference
option. Leaving it out produces compiler errors, though. - How do I determine the list of required
/reference
s including their particular version(s)?