[Cmake] separate compiling and linking

Iker Arizmendi iker at research.att.com
Tue, 27 Apr 2004 12:59:44 -0400


Andy Cedilnik wrote:
 > Hi Iker,
 >
 > Why don't you just create a dummy library which you then
 > not link to anything?

That's what I do at the moment. The problem is that
I have no easy way to get at the .o files in each of
the subdirectories that has a dummy library in order
to create a big library.

Bill has suggested using the source files in each of
the component subdirectories to derive the name of
the objects. However, this doesn't work for
subdirectories that create objects from non-standard
sources (eg, from generated files with weird extensions).

Ideally something like so would be the ticket (I think):

    SUBDIRS(lib1dir lib2dir)
    FILES(GLOB_RECURSE DOT_OS ${CMAKE_CURRENT_BINARY_DIR}/*.o)
    ADD_LIBRARY(biglib ${DOT_OS})

So that the top-level directory wouldn't have to know
anything about how the underlying object files are created.
But as Bill pointed out, this doesn't work because
no objects files are created until after CMake is run.

Iker