[CMake] Transitive linking and static libraries

James Bigler jamesbigler at gmail.com
Wed Oct 16 14:05:47 EDT 2013


Is it possible to stop known static libraries from being carried through
shared libraries?

add_library(mystatic1 STATIC ...)
add_library(mystatic2 STATIC ...)
add_library(myshared SHARED ...)
target_link_libraries(myshared mystatic1 mystatic2)
add_executable(myexe)
target_link_libraries(myexe myshared)

Once a shared library is created, all the information about what libraries
are needed should be encoded in the shared library.  In addition if myexe
links against only myshared then only the symbols being exported by
myshared should be visible to myexe.

I'm seeing problems where symbols from mystatic1 are being seen by myexe,
when myexe should only be seeing symbols from myshared.  This is because
CMake links myshared, mystatic1, and mystatic2 to myexe all in the same
link line.

James
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20131016/0a5a7f86/attachment.htm>


More information about the CMake mailing list