Sorry for my late weigh in on this one, but there are instances where this would be useful.  <div><br></div><div>E.g. redistro-ing libMyOneLargeLib.a which may be comprised of several other smaller libs.  </div><div><br></div>

<div>Basically I would like to build once, and pass the .o&#39;s into MyOneLargeLib.  </div><div><br></div><div>My only other alternative to add a custom build target to archive mundge, which is not a fun alternative.  </div>

<div><br></div><div>Cheers,</div><div>Tim<br><br><div class="gmail_quote">On Mon, May 24, 2010 at 4:12 AM, Alexander Neundorf <span dir="ltr">&lt;<a href="mailto:a.neundorf-work@gmx.net">a.neundorf-work@gmx.net</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On Friday 21 May 2010, Christoph Rüdiger wrote:<br>
&gt; Am 20.05.2010 um 13:33 schrieb Michael Hertling:<br>
&gt; &gt; On 05/20/2010 01:04 PM, &quot;Christoph Rüdiger&quot; wrote:<br>
&gt; &gt;&gt; [...]<br>
&gt; &gt;&gt; I&#39;ve a directory src containing the complete source code of the<br>
&gt; &gt;&gt; program and<br>
&gt; &gt;&gt; another directory called test containing the source code for the<br>
&gt; &gt;&gt; unit tests.<br>
&gt; &gt;&gt; In the top level directory is a CMakeLists.txt that points to the<br>
&gt; &gt;&gt; subdirectories containing each an own CMakeLists.txt for building<br>
&gt; &gt;&gt; the program or the unit tests.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Now I want to use the already build object files from the src<br>
&gt; &gt;&gt; directory one time for linking the program and one time for linking<br>
&gt; &gt;&gt; to the unit tests.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; My current way is building a static library in the src directory<br>
&gt; &gt;&gt; and link the unit tests against this library. But the sources would<br>
&gt; &gt;&gt; be compiled twice: One time for the static library and one time for<br>
&gt; &gt;&gt; the program itself.<br>
&gt; &gt;<br>
&gt; &gt; Link the program against the static library, too, while removing<br>
&gt; &gt; the latter&#39;s source files from the program&#39;s ADD_EXECUTABLE().<br>
&gt;<br>
&gt; Then I need either one big library which I can link against each unit<br>
&gt; test, resulting in a unit test of the size of the whole program plus<br>
&gt; the size of the unit test,<br>
<br>
</div>A static library consists on UNIX just of a bunch of object files.<br>
When linking a program against a static library, only those object files will<br>
be included in the resulting executable, which contain symbols which are<br>
referenced.<br>
So if your unit test uses only stuff from one object file (and this object<br>
file doesn&#39;t use symbols from other object files in the static library), only<br>
this one object file will be included in the resulting executable.<br>
<br>
So, the unit tests shouldn&#39;t become too big.<br>
<br>
I guess it&#39;s somewhat similar under Windows.<br>
<br>
Alex<br>
<div><div></div><div class="h5">_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Cheers,<br>Timothy St. Clair<br><br>
</div>