<div dir="ltr"><div dir="auto">You should check the options PUBLIC, PRIVATE, of the target_link_librairies. </div><div dir="auto">See: <a href="https://cmake.org/cmake/help/v3.7/command/target_link_libraries.html">https://cmake.org/cmake/help/v3.7/command/target_link_libraries.html</a></div><div dir="auto"><br></div><div>transitive linking is achieved through PUBLIC or INTERFACE whereas PRIVATE does not propagate.</div><div>AFAIU your shared lib should PRIVATEly target_link_librairies to your shared lib.</div><div>Moreover the way you describe it suggest that your static libs may well be OBJECT libraries:</div><div><a href="https://cmake.org/cmake/help/v3.7/command/add_library.html#object-libraries">https://cmake.org/cmake/help/v3.7/command/add_library.html#object-libraries</a><br></div><div><br></div><div>Next time, posting some excerpt of your CMakeLists.txt would make it easier to answer with example.</div><div>Eric</div><div class="gmail_extra"><br><div class="gmail_quote">Le 25 mars 2017 6:14 AM, "kipade" <<a href="mailto:kipade@163.com" target="_blank">kipade@163.com</a>> a écrit :<br type="attribution"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="line-height:1.7;color:rgb(0,0,0);font-size:14px;font-family:arial"><div>In my cmake project, there are some subdirectories within it, and some of them have to build as completed </div><div>static or shared libraries.</div><div>1. The top project is executable </div><div>2. a subdirectory is a shared project, which also have some subdirectoy compile as static libraries which</div><div>   of course should ONLY link into their parent shared library</div>
<div>I add link options to linking the shared library produced by its subdirectory(which linked as a shared library), </div><div>but I found the all sub-static library with the shared library project(the subdirectory) also double linked into</div><div>the top executable project. Of course I only want to link the shared library. How to resolve such problem </div><div>for the top CMakeLists.txt?</div></div><br><br><span title="neteasefooter"><p> </p></span><br>--<br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMak<wbr>e_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/su<wbr>pport.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/co<wbr>nsulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/tr<wbr>aining.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensou<wbr>rce/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" target="_blank">http://public.kitware.com/mail<wbr>man/listinfo/cmake</a><br></blockquote></div></div>
</div>