Sorry for my late weigh in on this one, but there are instances where this would be useful.
E.g. redistro-ing libMyOneLargeLib.a which may be comprised of several other smaller libs. Basically I would like to build once, and pass the .o's into MyOneLargeLib. My only other alternative to add a custom build target to archive mundge, which is not a fun alternative. Cheers, Tim On Mon, May 24, 2010 at 4:12 AM, Alexander Neundorf <[email protected] > wrote: > On Friday 21 May 2010, Christoph Rüdiger wrote: > > Am 20.05.2010 um 13:33 schrieb Michael Hertling: > > > On 05/20/2010 01:04 PM, "Christoph Rüdiger" wrote: > > >> [...] > > >> I've a directory src containing the complete source code of the > > >> program and > > >> another directory called test containing the source code for the > > >> unit tests. > > >> In the top level directory is a CMakeLists.txt that points to the > > >> subdirectories containing each an own CMakeLists.txt for building > > >> the program or the unit tests. > > >> > > >> Now I want to use the already build object files from the src > > >> directory one time for linking the program and one time for linking > > >> to the unit tests. > > >> > > >> My current way is building a static library in the src directory > > >> and link the unit tests against this library. But the sources would > > >> be compiled twice: One time for the static library and one time for > > >> the program itself. > > > > > > Link the program against the static library, too, while removing > > > the latter's source files from the program's ADD_EXECUTABLE(). > > > > Then I need either one big library which I can link against each unit > > test, resulting in a unit test of the size of the whole program plus > > the size of the unit test, > > A static library consists on UNIX just of a bunch of object files. > When linking a program against a static library, only those object files > will > be included in the resulting executable, which contain symbols which are > referenced. > So if your unit test uses only stuff from one object file (and this object > file doesn't use symbols from other object files in the static library), > only > this one object file will be included in the resulting executable. > > So, the unit tests shouldn't become too big. > > I guess it's somewhat similar under Windows. > > Alex > _______________________________________________ > Powered by www.kitware.com > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Follow this link to subscribe/unsubscribe: > http://www.cmake.org/mailman/listinfo/cmake > -- Cheers, Timothy St. Clair
_______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
