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'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"><<a href="mailto:a.neundorf-work@gmx.net">a.neundorf-work@gmx.net</a>></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>
> Am 20.05.2010 um 13:33 schrieb Michael Hertling:<br>
> > On 05/20/2010 01:04 PM, "Christoph Rüdiger" wrote:<br>
> >> [...]<br>
> >> I've a directory src containing the complete source code of the<br>
> >> program and<br>
> >> another directory called test containing the source code for the<br>
> >> unit tests.<br>
> >> In the top level directory is a CMakeLists.txt that points to the<br>
> >> subdirectories containing each an own CMakeLists.txt for building<br>
> >> the program or the unit tests.<br>
> >><br>
> >> Now I want to use the already build object files from the src<br>
> >> directory one time for linking the program and one time for linking<br>
> >> to the unit tests.<br>
> >><br>
> >> My current way is building a static library in the src directory<br>
> >> and link the unit tests against this library. But the sources would<br>
> >> be compiled twice: One time for the static library and one time for<br>
> >> the program itself.<br>
> ><br>
> > Link the program against the static library, too, while removing<br>
> > the latter's source files from the program's ADD_EXECUTABLE().<br>
><br>
> Then I need either one big library which I can link against each unit<br>
> test, resulting in a unit test of the size of the whole program plus<br>
> 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'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't become too big.<br>
<br>
I guess it'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>