[CMake] How to use LINK_INTERFACE_LIBRARIES

Nils Gladitz nilsgladitz at gmail.com
Sat May 24 12:45:08 EDT 2014


On 24.05.2014 18:15, Lucas Soltic wrote:
> Hello!
>
> I'm having a hard time at properly using LINK_INTERFACE_LIBRARIES.
>  From what I understood, setting this property empty for a target avoids transitive dependencies linking.
>
> But whatever I try, it doesn't work.
> I have created a lib A linked against lib B.
> I'm also creating an exe linked against lib A. But I really don't want it to be linked against lib B.
>
> Till now I've tried
> target_link_libraries(myexe A)
> target_link_libraries(myexe LINK_INTERFACE_LIBRARIES "")
> and
> target_link_libraries(myexe A)
> set_target_properties(myexe PROPERTIES LINK_INTERFACE_LIBRARIES "")
> and
> target_link_libraries(myexe LINK_INTERFACE_LIBRARIES A)
>
> But in all these cases the exe gets linked against B :( (which causes loading issues due to RPATH stuff)
> Does someone know how to use this property? (if it's the right one?)
>
> Kind regards,
> Lucas

target_link_libraries(A PRIVATE B) # A links to B but B is not added to 
the interface of A
target_link_libraries(myexe A) # myexe links to A without B

Nils


More information about the CMake mailing list