Knitschi
Knitschi

Reputation: 3112

Which cmake property should hold privately linked shared libraries for imported targets?

Consider importing a target with find_package( foo REQUIRED ) that provides a shared library. Target foo itself depends on another shared library bar.dll, which is only used in its implementation and not visible in its headers. But as a client of foo I also have to deploy bar.dll in order to run my code.

So which property of the imported target foo should give me the information that I also have to deploy bar?

Should it be in LINK_INTERFACE_LIBRARIES, IMPORTED_LINK_INTERFACE_LIBRARIES, LINK_LIBRARIES, IMPORTED_LINK_DEPENDENT_LIBRARIES or something else?

Thank you for your time.

Upvotes: 4

Views: 1235

Answers (1)

chadsgilbert
chadsgilbert

Reputation: 410

Assuming you're on a "modern" version of cmake (3.anything), then you are looking for IMPORTED_LINK_DEPENDENT_LIBRARIES.

LINK_INTERFACE_LIBRARIES and IMPORTED_LINK_INTERFACE_LIBRARIES are both deprecated, so don't consider them.

LINK_LIBRARIES is for building a target; since you're importing a library with find_package, it shouldn't be of much use.

INTERFACE_LINK_LIBRARIES, on an imported target, tells you which libraries are dependencies in the interface (visible in the headers).

Upvotes: 4

Related Questions