[CMake] linking question

Bill Newcomb bnewcomb at nvidia.com
Wed Apr 15 18:07:47 EDT 2015


The following is all on Linux (with gcc, gnu binutils, etc).

I'm trying to build libfred.so that uses code from libjoe.a, but I want 
libfred.so to be complete, i.e. I don't want any program that I build 
that links to libfred.so also need libjoe.a.

Then I want to build executable mike that is dynamically linked with 
libfred.so .  However, the link script for mike puts libjoe.a on the 
command line.

add_library(joe STATIC joe.c joe_a.c)
add_library(fred SHARED fred.c fred_a.c)
target_link_libraries(fred joe)

add_executable(mike mike.c)
# mike only contains calls to functions in fred
target_link_libraries(mike fred)


The docs give me the impression that I should set the 
INTERFACE_LINK_LIBRARIES property on moo to override the inherited 
transitive dependencies, but setting it to "" has no effect.  Same for 
LINK_INTERFACE_LIBRARIES.

Any idea how to make this work?

Thanks,
B.

-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------


More information about the CMake mailing list