Vladislav Vaintroub provided a solution (off-list) to my original query. With his permission, I am reposting it here, with code, in case someone else finds his code as useful as I do. Hopefully he will find the time someday to officially contribute it to CMake. :)
Eric Begin forwarded message: > From: Vladislav Vaintroub <wlad at sun.com> > Date: April 30, 2010 4:54:07 PM MDT > To: enodwell at ucalgary.ca > Subject: [CMake] Adding one static library into another > > Hi Eric, > Sorry for replying offlist (I'm not subscribed, too many mails already, but > lurking sometimes into CMake discussions) > > It is possible to do it in a platform independent way, I did it for MySQL. > It is not extremely simple, but I did not like the alternative to compile > most of MySQL sources MySQL 2 times with the same flags. > > > There are 3 platform specific methods I used and I think it covers > everything or almost everything supported by CMake > > 1) generic Unix + MinGW : I'm using "ar" to pack/unpack libs > 2) MSVC : I'm using (lib.exe) can merge static libraries > 3) OSX : libtool can merge static libraries (OSX libtool, not the GNU one). > libtool is only necessary for universal libraries, if you build for 1 > architecture only, "ar" will work fine. > > The main idea is to create a dummy library with empty source file, and in > the post-build step use ar/lib.exe/libtool to merge the all static libs > with it the dummy one. A subtlety in the implementation is how to force > build to rerun (and postbuild step to reexecute) when one of dependent > libraries changes. Another subtlety is maintaining correct dependencies > (TARGET_LINK_LIBRATIES) for resulting lib. > > Take a look at the attached file libutils.cmake, specifically > MERGE_STATIC_LIBS macro in it. To merge several libraries say lib1, lib2, > lib3 into biglib, you would use MERGE_STATIC_LIBS (biglib biglib > "lib1;lib2;lib3"). Second file (merge_archives_unix.cmake.in) contains hairy > details of "ar" unpacking and repacking and is used by libutils.cmake > > HTH, > Vladislav > > >
libutils.cmake
Description: Binary data
merge_archives_unix.cmake.in
Description: Binary data
_______________________________________________ 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