Mandatory export of a static library dependency

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Mandatory export of a static library dependency

Lassi Niemistö



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 J



-Lassi Niemistö


Powered by

Please keep messages on-topic and check the CMake FAQ at:

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support:
CMake Consulting:
CMake Training Courses:

Visit other Kitware open-source projects at

Follow this link to subscribe/unsubscribe: