[CMake] Targets organisation of complex project

Mateusz Loskot mateusz at loskot.net
Sun Oct 11 15:41:27 EDT 2009


Hi,

Me and my friend, we are porting build configuration of quite complex
project (http://trac.osgeo.org/gdal/) from hand-written makefiles (with
partial support autotools) to CMake.

The sources are organised in large number of subdirectories and
sort of logical sub-libraries, but the binary output of compilation
is a single library.

Trying to figure out how to organise targets I got an idea to
configure these sub-libraries as static library targets
(e.g. libgdal_cpl, libgdal_alg, libgdal_gcore, etc.) which
eventually link to single shared library (libgdal.so).
Learning CMake best practices, I stepped across an interesting
thread: "build a shared library from static libraries"

http://www.cmake.org/pipermail/cmake/2008-March/020315.html

It actually smashed my original idea :-)
It looks like the best portable approach is to walk through the whole
tree of project, collect all .c and .cpp files (assigning list of files
to global variables) and, back in the main CMakeLists.txt, stream all
source files to single ADD_LIBRARY call.

Is that the best option?

What would be best way to configure such complex source tree that
outputs single library?

Best regards,
-- 
Mateusz Loskot, http://mateusz.loskot.net
Charter Member of OSGeo, http://osgeo.org


More information about the CMake mailing list