[Cmake] Collecting files from subdirs

William A. Hoffman bill.hoffman at kitware.com
Mon Mar 31 10:04:06 EST 2003


Each subdir is treated as its own makefile and scope.   Only
cached variables are passed from one sub dir to another.
You have some choices:

1. use the INCLUDE command instead of the SUBDIRS command to include
the lists file in the subdir.
2. List out the sources in the parent directory explicitly
SET(SRCS subdir/file1.cxx subdir/file2.cxx ....)
3. Use AUX_SOURCE_DIRECTORY, but that is really just a variation on 2, its main
use is really having cmake collect all the source names instead of listing 
them one
by one.

-Bill


At 05:36 PM 3/30/2003 -0500, Emmanuel Idi wrote:
>See: AUX_SOURCE_DIRECTORY()
>
>Nils H. Busch wrote:
>>Hi,
>>probably something very easy, but I can't get it to work.
>>I want to add source files from several subdirs in one cmake var to use
>>it in a call to
>>ADD_LIBRARY(somelib ${SRCS}).
>>This is to collect source files from several subdirs and make one
>>library out of it.
>>I have tried a few things, but my list is always empty.
>>Something like in a top-level CmakeLists.txt
>>SET(SRCS "")
>>SUBDIRS(dir1 dir 2)
>>and then in subdir CMakeLists.txt
>>SET(SRCS "${SRCS} foo")
>>does not work.
>>I'd like to retain the structure of those subdirs to organize code, but
>>combine it into one library.
>>Any hints?
>
>_______________________________________________
>Cmake mailing list
>Cmake at public.kitware.com
>http://public.kitware.com/mailman/listinfo/cmake






More information about the CMake mailing list