<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2017-07-17 17:31 GMT+02:00 Robert Dailey <span dir="ltr"><<a href="mailto:rcdailey.lists@gmail.com" target="_blank">rcdailey.lists@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Suppose I have the following:<br>
<br>
```<br>
add_library( A STATIC ${files} )<br>
<br>
add_library( B SHARED ${more_files} )<br>
target_link_libraries( B PUBLIC A )<br>
<br>
add_library( C STATIC ${even_more_files} )<br>
target_link_libraries( C PUBLIC B )<br>
<br>
<br>
add_executable( D ${exe_files} )<br>
target_link_libraries( D PRIVATE C )<br>
```<br>
<br>
Does the linker command for target `D` ever see target A's static link<br>
library? I'm hoping the only thing the linker gets is `libB.so` and<br>
`libC.a`, without `libA.a`.<br></blockquote><div><br></div><div>I guess it does otherwise you may be missing symbols.</div><div>As explain by Peter some time ago:</div><div>  <a href="https://cmake.org/pipermail/cmake/2017-April/065347.html">https://cmake.org/pipermail/cmake/2017-April/065347.html</a></div><div>when you</div><div><div>target_link_libraries( B PUBLIC A )</div></div><div><br></div><div>with A being STATIC you do not really link A into B (which is shared in your example)</div><div>but you add A as a PUBLIC item of the link interface of B such that when actual linking</div><div>occurs if you build an executable linked to B then A is automagically brought to the link step. </div><div><br></div><div>More info on that topic by Craig:</div><div><div><a href="https://cmake.org/pipermail/cmake/2016-May/063400.html">https://cmake.org/pipermail/cmake/2016-May/063400.html</a></div></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
It seems like A to everyone outside of B should just be a set of<br>
public include directories and compile definitions, since the link<br>
file aspect of it should be hidden across shared library boundaries.<br></blockquote><div><br></div><div>No it is not, because the binary object inside A are NOT embedded into B.</div><div>If you want that then you need to make A an OBJECT library and not a STATIC library.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Hoping someone can explain how this works. I want to make sure static<br>
libs sitting behind shared libs in the dependency tree do not get<br>
exposed.<br></blockquote><div><br></div><div>My understanding is that you cannot do what you want with static lib.</div><div>You can do that with OBJECT lib though.</div><div>Knowing that you cannot use target_link_libraries with OBJECT lib:</div><div><a href="https://cmake.org/cmake/help/v3.9/manual/cmake-buildsystem.7.html#object-libraries">https://cmake.org/cmake/help/v3.9/manual/cmake-buildsystem.7.html#object-libraries</a><br></div><div><br></div><div>Hope this helps.</div></div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Eric<br></div></div></div></div></div>
</div></div>