<div class="gmail_quote">On Fri, Feb 27, 2009 at 2:32 PM, Jed Brown <span dir="ltr">&lt;<a href="mailto:jed@59a2.org">jed@59a2.org</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;">
<div><div></div><div class="Wj3C7c">On Fri 2009-02-27 20:26, Jed Brown wrote:<br>
&gt; On Fri 2009-02-27 11:09, Bill O&#39;Hara wrote:<br>
&gt; &gt; Lets say I have a CMakeLists.txt like this:<br>
&gt; &gt;<br>
&gt; &gt; add_library(foo STATIC foo.c bar.c)<br>
&gt; &gt; add_executable(test test.c)<br>
&gt; &gt; target_link_libraries(test foo)<br>
&gt; &gt;<br>
&gt; &gt; where test.c uses only functions defined in foo.c but not bar.c (assume some<br>
&gt; &gt; other target will use foo as well and use functions from both foo.c and bar.c).<br>
&gt; &gt;<br>
&gt; &gt; Is it possible to avoid the relink of test when foo is changed because of a<br>
&gt; &gt; change in bar.c? Just as an optimization to avoid unnecessary relinks to speed<br>
&gt; &gt; up the user experience?<br>
&gt;<br>
&gt; I&#39;m guessing this won&#39;t work because it requires very deep knowledge to<br>
&gt; determine that nothing in bar.c is called, even transitively, through<br>
&gt; foo.c.<br>
&gt;<br>
&gt; What I&#39;d like though is to not relink targets when a shared library<br>
&gt; changes.  That is, suppose libfoo is a shared library in the example<br>
&gt; above.  If relinking is required then a header must have changed so<br>
&gt; &#39;test.c&#39; would need to be recompiled.  If no headers have changed, then<br>
&gt; libfoo can be rebuilt and the executable &#39;test&#39; does not need to be<br>
&gt; rebuilt.  Presumably there is a reason this isn&#39;t the default, what is<br>
</div></div>  ^^^^^^^<br>
<br>
Should be &#39;relinked&#39;.  Philip says<br>
<div class="Ih2E3d"><br>
&gt; Of course, CMake will still relink test on a regular &quot;make&quot; as it should.<br>
<br>
</div>Why should it?  Shared libs are regularly updated on production machines<br>
without relinking the system.  If the interface hasn&#39;t changed, why<br>
should CMake relink everything anyway.</blockquote><div><br>I wasn&#39;t thinking of it in that context when I said that.  Yes, I think you&#39;re correct and I&#39;ve noticed that behavior before.  I usually work around it with make foo/fast assuming foo is the shared library I&#39;m patching.<br>
<br>Not sure why CMake does what it does.  For the Makefile generator (at least) it would seem that it would be fairly easy to avoid relinking against a shared library that has only had it&#39;s implementation changed.  A special file could be outputted alongside the &quot;.so&quot; that if present indicates that a header file changed and targets could depend on this instead of the shared library itself to handle relinking.<br>
<br>There must be some corner case neither of us can&#39;t think of.  Perhaps there is a way to break binary compatibility by modifying a cpp file? I can&#39;t think of any.<br><br></div></div>-- <br>Philip Lowman<br>