target_link_libraries takes target names as its arguments as well as full paths to libraries. Just use CMake target names in target_link_libraries calls and do NOT use add_dependencies for libraries.<div><br></div><div>add_dependencies is very useful for custom targets and custom commands to guarantee build order. I have never heard of anybody else using it to add library-to-library or executable-to-library dependencies.<br>
<br></div><div>target_link_libraries is really the way to go.</div><div><br></div><div><br><div class="gmail_quote">On Thu, Dec 4, 2008 at 5:12 PM, Robert Dailey <span dir="ltr"><<a href="mailto:rcdailey@gmail.com">rcdailey@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="Ih2E3d">On Thu, Dec 4, 2008 at 4:06 PM, Alexander Neundorf <span dir="ltr"><<a href="mailto:a.neundorf-work@gmx.net" target="_blank">a.neundorf-work@gmx.net</a>></span> wrote:<br>
<div class="gmail_quote"><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
But, if you do in cmake:<br>
target_link_libraries(staticLibB staticLibA)<br>
this will not really link (as it would for a shared lib), but it will<br>
nevertheless keep track of the dependencies.<br>
So when liking<br>
target_link_libraries(myApp staticLibB)<br>
cmake knows that it has to add staticLibA to the linker command.</blockquote></div><br></div>But that's one of the things that really bothers me. This is that redundancy I was talking about earlier. If I do:<br><br>add_dependencies( C B )<br>
target_link_libraries( C staticLibB )<br><br>It's a bit pointless. For example, CMake should be smart enough to know that by adding a dependency to B, it should look at the library that it is outputting (In this case, staticLibB.lib) and add that to an implicit call to target_link_libraries(). I only want to use target_link_libraries() to link against external third party libraries that aren't explicitly represented as a project in my CMake build process.<br>
<br>If I decide to change the output name for the static library B outputs, I'm forced to then revisit all of the target_link_libraries() calls and rename staticLibB. This is a management issue (amongst other things).<br>
<br>_______________________________________________<br>
CMake mailing list<br>
<a href="mailto:CMake@cmake.org">CMake@cmake.org</a><br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br></blockquote></div><br></div>