On Mon, Mar 9, 2009 at 4:18 PM, Mathieu Malaterre
<[email protected]> 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".
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to