<div class="gmail_quote">On Fri, Feb 27, 2009 at 2:09 PM, Bill O&#39;Hara <span dir="ltr">&lt;<a href="mailto:billtohara@gmail.com">billtohara@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Lets say I have a CMakeLists.txt like this:<br><br>add_library(foo STATIC foo.c bar.c)<br>add_executable(test test.c)<br>target_link_libraries(test foo)<br><br>where test.c uses only functions defined in foo.c but not bar.c (assume some other target will use foo as well and use functions from both foo.c and bar.c).<br>

<br>Is it possible to avoid the relink of test when foo is changed because of a change in bar.c? Just as an optimization to avoid unnecessary relinks to speed up the user experience?</blockquote><div><br>You could just link test.c against bar.c if that&#39;s all it needs, or just compile &quot;bar.c&quot; directly into the test app.<br>
<br>Barring that I don&#39;t see a way to tell CMake that the &quot;test&quot; executable only cares about symbols from certain source files in a static library.  The static library is a collection of all of the symbols.  When it is regenerated due to dependencies CMake will relink test against it.<br>
<br>For your particular case, if you&#39;re using a shared library you could just type &quot;make foo&quot; and then run test without relinking it.  Of course, CMake will still relink test on a regular &quot;make&quot; as it should.<br>
</div></div><br>-- <br>Philip Lowman<br>