[CMake] Joining multiple directories into one
Jussi Pakkanen
jpakkane at gmail.com
Mon Mar 9 19:40:30 EDT 2009
On Mon, Mar 9, 2009 at 4:18 PM, Mathieu Malaterre
<mathieu.malaterre at gmail.com> wrote:
> This is the easiest way indeed. If you are still very picky (style,
> convention, user mood) on where to list src file you can always list
> file within subdirectory and from the toplevel directory request the
> src for each directory:
>
> toplevel/
> ADD_SUBDIRECTORY(dir1)
> GET_DIRECTORY_PROPERTY(dir1_srcs DIRECTORY dir1 DEFINITION DIR1_SRCS)
> dir1/
> SET(DIR1_SRCS
> foo.cxx
> foo2.cxx
> )
Thanks for this. What I wanted to accomplish can be done with the
following macro:
macro(append_subdir_files variable dirname)
get_directory_property(holder DIRECTORY ${dirname} DEFINITION ${variable})
foreach(depfile ${holder})
list(APPEND ${variable} "${dirname}/${depfile}")
endforeach()
endmacro()
In dir1 I do:
set(files foo.cxx foo2.cxx)
and then in parent directory
append_subdir_files(files dir1)
ends up with "dir1/foo.cxx;dir1/foo2.cxx".
More information about the CMake
mailing list