Hi,

I am in the process of deploying CMake into the build process of our 
department. I got already quite a lot of it working but I get stuck at one 
point: I can't see how we can combine several static libraries into a single 
static library with CMake.

I'll give some background first, to help you understand my problem. Our code is 
split up in more than 100 projects. Echo of those project is built into static 
libraries. In our department we work with static libraries because we target 
embedded systems that don't have support shared libraries, so shared libraries 
are not allowed. The static libraries can have dependencies on other projects. 
We build these project on many different platforms so CMake will definitely 
help in our build system.
With our current build system, we combine these static libraries into  "Release 
libraries". "Release libraries" are a combination of all required static 
libraries (no dependencies left anymore) into a single static library without 
any new code being added. This makes it very easy to release the combined 
functionality to a 3rd Party (such as another department or customer). We have 
a lot of "Release Libraries" with different combinations of the projects 
because we target different applications.

So I could simplify our build structure as below:
/Project01 (Static library)
/Project02 (Static library)
/Project03 (Static library)
...
/Project99 (Static library)
/ReleaseLibrary01 (Static library links e.g. Project01, Project02 and Project03)
/ReleaseLibrary02 (Static library links e.g. Project01, Project02 and Project04)
/ReleaseLibrary02 (Static library links e.g. Project05, Project06 and Project99)
/...

We already succeeded in building all our projects into static libraries with 
CMake. We also succeeded in building our test applications based upon those 
static libraries including the resolution of the dependencies (CMake is easy 
for this).
But we are not able to build our "Release Libraries". Simply adding a target 
with add_library for the "Release Library" does not work.

What I already read so far is that there are several workarounds: (e.g. rebuild 
the "Release Library" with the source of all dependent projects, unpack all 
libraries and repack again with platform specific commands, etc.). Some 
references I found are: 
https://svn.jmodelica.org/FMILibrary/trunk/Config.cmake/mergestaticlibs.cmake, 
https://code.google.com/p/toadlet/source/browse/cmake/Modules/MergeStaticLibraries.cmake,
 http://www.cmake.org/pipermail/cmake/2011-February/043002.html. I also saw 
that CMake supports an OBJECT library which might be helpful.

All of this seems very clumsy to me and I can't find any convergence on the 
best way to approach this. Is there any good reference where it is guided how 
to combine static libraries into a single static library with CMake ?

Thanks already for the support.

Johan Laneau
Software Architect, NXP Software

Interleuvenlaan 80, B-3001 Leuven, Belgium
Phone: +32 495 354 839, Fax: +32 16 390 855
E-mail: johan.lan...@nxp.com<mailto:johan.lan...@nxp.com>, 
http://www.nxpsoftware.com


-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to