简体   繁体   中英

CMake - Linking Pre-built Libraries to C# Project

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.

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).

How can I accomplish this with CMake?

Normally in a VS C# project file you would add:

<Reference Include="somelibrary">
    <HintPath>path/to/some/library</HintPath>
</Reference>

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")

Be sure to not only provide the path to the library, but also the full library name somelibrary.dll .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM