<div dir="ltr">Hi all,<br><br>I figured I would dig up this question as I found a decent solution to this issue.<br><br>After having a look at how Microsoft Visual Studio is doing to include references to external libraries, I came to realise that it is using a tool called TlbImp, which is short for Type Library Importer.<div><br></div><div>The solution is pretty simple from there: use TlbImp to generate a library that CSharp will be able to import and add it via CMake to the project. My code for Windows Media Player boils down to this:<br><div><br>set(_outLib ${CMAKE_CURRENT_BINARY_DIR}/<wbr>generated/Interop.WMPLib.dll)</div><div>execute_process(COMMAND ${TLBIMP_EXECUTABLE} ${WMP_LIBRARY} /namespace:WMPLib /out:${_outLib}</div><div><span style="white-space:pre-wrap"> </span>RESULT_VARIABLE tlbimp_result</div><div><span style="white-space:pre-wrap"> </span>ERROR_FILE ${CMAKE_CURRENT_BINARY_DIR}/<wbr>tlbimp_log.txt</div><div>)<br><br><div>set_target_properties(<wbr>myproject<br></div><div><span style="white-space:pre-wrap"> </span>VS_DOTNET_REFERENCES "WMPLib"</div><div><span style="white-space:pre-wrap"> </span>VS_DOTNET_REFERENCEPROP_<wbr>WMPLib_TAG_HintPath "${_outLib}"</div><div>)<br><br>And there you have it!<br><br>If you would like to see it used in a project, I have just uploaded a small project to my github that uses just that: <a href="https://github.com/cyrilBoucher/space-invaders" target="_blank">https://github.com/<wbr>cyrilBoucher/space-invaders</a><br><br>Hope this helps!<br>Cyril Boucher</div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2018-02-01 21:57 GMT+01:00 Cyril Boucher <span dir="ltr"><<a href="mailto:cyril.boucher94260@gmail.com" target="_blank">cyril.boucher94260@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi all,<br><br>I am trying to use CMake and the CSharp support for a small project of mine but I cannot seem to find a way to add a reference to the Windows Media Player library. One of the reason for that is that I need to link my project to wmp.dll which then needs to generate Interop.WMPLib.dll and a reference needs to be added with its path pointing to the latter library.<br><br>Adding wmp.dll to my project is as simple as a target_link_libraries call but this does not seem to trigger the whole generation and add reference sort of process.<br><br>Has anyone ever had an experience with adding such libraries? Is there support for these scenarios?<br><br>Thanks!<span class="HOEnZb"><font color="#888888"><br>Cyril Boucher</font></span></div>
</blockquote></div><br></div>