CMake-将预建库链接到C#项目 [英] CMake - Linking Pre-built Libraries to C# Project
问题描述
我正在使用CMake构建C#库。该库依赖于已经建立的库(.dll)。
I am building a C# library with CMake. The library depends on an already built library (.dll).
我似乎无法使库链接到我的库中。
I cannot seem to get library to link in to my library.
我尝试使用 target_link_libraries(mylib $ {external_lib})
。
我还尝试过强制使用 / reference:$ {external_lib}
作为编译选项(但CMake在构建时将其删除)。
I have tried using target_link_libraries(mylib ${external_lib})
.
I have also tried brute-forcing a /reference:${external_lib}
as a compile option (but CMake removes it at build time).
如何使用CMake完成此操作?
How can I accomplish this with CMake?
通常在VS C#项目文件中,您会添加:
Normally in a VS C# project file you would add:
<Reference Include="somelibrary">
<HintPath>path/to/some/library</HintPath>
</Reference>
推荐答案
根据此,您应该可以设置 VS_DOTNET_REFERENCE_< refname>
位于 mylib
目标的属性,像这样:
According to this, you should be able to set VS_DOTNET_REFERENCE_<refname>
property on mylib
target, like this:
set_target_properties(mylib PROPERTIES
VS_DOTNET_REFERENCE_somelibrary "/path/to/libs/somelibrary.dll")
确保不仅提供库的路径,而且还要提供完整的库名称 somelibrary.dll
。
Be sure to not only provide the path to the library, but also the full library name somelibrary.dll
.
这篇关于CMake-将预建库链接到C#项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!