<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7653.38">
<TITLE>TARGET_LINK_LIBRARIES for library targets?</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P><FONT SIZE=2 FACE="Arial">I've got three libraries, A, B, C. C uses symbols from B, and B uses symbols from A.</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">When I build these libraries as static libraries (libA.a, libB.a, and libC.a), the linker is perfectly happy to produce libC.a even if I haven't told it about B. It seems that all that matters is, when I'm linking together some executable program that uses libC.a, I have to tell the linker about libB.a and (presumably) libA.a.</FONT></P>
<P><FONT SIZE=2 FACE="Arial">When I tried building my libraries as shared objects, however, the linker seemed much fussier. When the linker was trying to produce libC.so, it got very upset about the unresolved symbols in libC.so's object code. </FONT></P>
<P><FONT SIZE=2 FACE="Arial">To remedy this, I added this line: "TARGET_LINK_LIBRARIES(C, B)" and "TARGET_LINK_LIBRARIES(B, A)". But I'm not sure I understand all the ramifications of solving the problem this way.</FONT></P>
<P><FONT SIZE=2 FACE="Arial">For example, does that mean that libC.so will export not only its own symbols, but also those provided by B and A? And would that answer change if I had build B and A as static libraries, while still building C as a shared object?</FONT></P>
<P><FONT SIZE=2 FACE="Arial">Also, suppose I go back to building all my libraries as static libraries. Will there be any harm in having those TARGET_LINK_LIBRARIES statements still in my CMakeLists.txt files? And if I do leave them there, does this mean that I can get away with just writing this:</FONT></P>
<P><FONT SIZE=2 FACE="Arial"> TARGET_LINK_LIBRARIES(myApp C)</FONT>
<BR><FONT SIZE=2 FACE="Arial">rather than</FONT>
<BR><FONT SIZE=2 FACE="Arial"> TARGET_LINK_LIBRARIES(myApp C B A)</FONT>
<BR><FONT SIZE=2 FACE="Arial">since CMake could (potentially) have enough information to realize that myApp has a transitive link-time dependency on B and A?</FONT></P>
<P><FONT SIZE=2 FACE="Arial">Thanks,</FONT>
<BR><FONT SIZE=2 FACE="Arial">Christian</FONT>
</P>
</BODY>
</HTML>