[CMake] Hi.. a New bie question

Rolf Eike Beer eike at sf-mail.de
Fri Apr 8 01:32:21 EDT 2011


> Hi all,
>
>      I want to create a library out of several sources distributed in
> various directory structures. It seems, i need to specify name of all
> sources to ADD_LIBRARY command. Is there any other way to do it ?
> Keeping CMakeLists.txt file in every sub directory will really help
> as i need to create library out of all sources not with the sources
> of a single directory?. In this case, however, how to get the list of
> source files in my main CMakeLists.txt file so as to pass this to
> ADD_LIBRARY command. Can anyone out there to help me in this ?

SET(SOURCES foo.cpp bar.cpp PARENT_SCOPE) in each subdirectory and use
those variables in ADD_LIBRARY() in the parent directory. Make sure to
dive into the subdirs before calling ADD_LIBRARY() as those variables
would otherwise be empty.

Eike


More information about the CMake mailing list