[CMake] Mandatory export of a static library dependency

Lassi Niemistö lassi.niemisto at wapice.com
Wed Feb 20 08:33:16 EST 2019


Hello,

I use CMake 3.13RC1. My project produces, installs and exports a shared library target "fooshared". Some logical parts of "fooshared" are reused in an executable, so I have placed those sources into an internal static library target "barstatic". I have used target_link_libraries(fooshared barstatic) to make this work.

Problem: when I try to:
install(TARGETS fooshared DESTINATION <dest> EXPORT myexport)
install(EXPORT myexport DESTINATION <dest>)
..I get a whine about dependency to "barstatic" which is not in the export group "myexport".

I wouldn't like to export "barstatic" at all, it should remain under the hood. I tried to use target_link_libraries(fooshared PRIVATE barstatic) which cut the export chaining, but then symbols from "barstatic" were not available for users of "fooshared" anymore. So I worked around this by converting "barstatic" into an object library, but it feels ugly.

Why would CMake require exporting statically linked dependency targets among the targets that use them? Feels like a bug to me...unless someone can explain why :)

Regards,
-Lassi Niemistö
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190220/e4d6bf72/attachment-0001.html>


More information about the CMake mailing list