<div dir="ltr"><div><div><div><div><div>Hi Tom,<br><br></div>linking the static archive into the DLL should not be done by add_dependencies(), but by target_link_libraries(). There, you can explicitly list the archive as PRIVATE so that it does not become a part of the linking interface of the DLL:<br><br></div>add_library(staticArchive STATIC ...)<br></div><br>add_library(theDLL SHARED ...)<br><br></div>target_link_libraries(theDLL PRIVATE staticArchive)<br><br></div>Petr</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 14, 2015 at 3:34 PM, Tom Kacvinsky <span dir="ltr"><<a href="mailto:tom.kacvinsky@vectorcast.com" target="_blank">tom.kacvinsky@vectorcast.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I am getting link errors because cmake is adding transitive<br>
dependencies.  I am building a DLL which depends on a static archive<br>
(and is marked as such with add_dependencies), but when I link an<br>
executable that depends on the DLL, both libraries (import library for<br>
the DLL and static archive) are specified on the link. leading to<br>
duplicate symbol errors as the symbol are exported form the DLL and<br>
defined in the static archive.<br>
<br>
How do I work around this?  This is the one thing that has frustrated<br>
me over the last couple of years - I have never received an answer<br>
telling me how to turn off transitive dependencies.<br>
<br>
Sorry for the minor rant.<br>
<br>
Regards,<br>
<br>
Tom<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/CMake_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/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.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/opensource/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/mailman/listinfo/cmake</a><br>
</blockquote></div><br></div>