Domanda

If I have a my_library.lib file which links against several other .lib files like:

add_library( my_library ...)
target_link_libraries( my_library LINK_PUBLIC lib1 lib2 ...)

if I now link this my_library.lib file into another library (which also needs lib1, lib2, etc.. that's the reason of the LINK_PUBLIC in the code above) with LINK_PRIVATE

target_link_libraries( some_other_library LINK_PRIVATE my_library )

will I "protect" the lib1, lib2 and other libraries I only used to compile my_library?

È stato utile?

Soluzione

LINK_PUBLIC: makes transitive dependencies of the currently linked target visible to other targets which are going to be linked against the current one. So lib1 and lib2 will be linked along with my_library when my_library is linked against something else.

LINK_PRIVATE: makes transitive dependencies of the currently linked target invisible to other targets which are going to be linked against the current one. So lib1 and lib2 will not be linked along with my_library when my_library is linked against something else.

To conclude, when some_other_library will be linked against something else, its dependencies will not be seen to those targets it is linked against because of the final LINK_PRIVATE.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top