[CMake] One library with multiple sub-directories
Brad King
brad.king at kitware.com
Tue Nov 2 15:28:36 EST 2004
Bradley Lowekamp wrote:
> Hello,
> I am trying to generate a single library from multiple source
> sub-directories where in the subdirectories files may have the same
> name. Currently I have been making sure that each file had different
> names, but I can't be doing this any more. The way I have it currently
> set up is basically as follows:
>
> directory structure:
> /-
> -/foo
> default.cpp
> -/bar
> default.cpp
>
> top level cmake:
> SUBDIRS( foo)
> SUBDIRS(bar)
> SET (MY_LIB_SRC ${FOO_SRC} ${BAR_SRC})
> ADD_LIBRARIES(my ${MY_LIB_SRC}
Just leave out the SUBDIRS and build it all from the top:
ADD_LIBRARIES(my foo/default.cpp bar/default.cpp)
The object files will be built with the proper relative paths.
-Brad
More information about the CMake
mailing list