[CMake] communicat variables from sub directories

Axel Roebel Axel.Roebel at ircam.fr
Thu Apr 6 15:10:19 EDT 2006


On Thursday 06 April 2006 18:00, James Bigler wrote:
> Brad King wrote:
> > Axel Roebel wrote:
> >> Hello,
> >>
> >> I am trying to collect source file lists from sub directories
> >> into the main cmake cache.
> >>
> >> The idea is that the main directory gets a collection of all source
> >> files and header files such that it may run a doxygen whenever one of
> >> these files has changed.
> >>
> >> Imagine
> >>
> >> SET(DOCFILES "" CACHE INTERNAL "list of all files containing doc")
> >> ADD_SUBDIRECTORY(src )
> >> ADD_SUBDIRECTORY(include)
> >>
> >> and in each subdir I tried various versions like
> >>
> >> SET(DOCFILES ${DOCFILES}${LISTOFSRCS} )
> >>
> >> or what I considered more likely to be correct
> >>
> >> SET(DOCFILES ${DOCFILES}${LISTOFSRCS} CACHE INTERNAL "list of all
> >> files containing doc")
> >>
> >>
> >> This gives me a correct list of files in the subdirectory
> >> but the variable in the main directory is not changed.
> >>
> >> For now I found that  I need to create a new cache variable in the
> >> sub directories to be able to read the content of that variable in the
> >> main directory so that's what I do now.
> >> Does anybody know how to make that work with a more elegant
> >> solution ?
> >
> > See "bin/cmake --help-command GET_DIRECTORY_PROPERTY".
> >
> > GET_DIRECTORY_PROPERTY(
> >   subdir_SOMEVAR DIRECTORY subdir DEFINITION SOMEVAR
> > )
>
> What I've done is to use the INCLUDE() function.  This will work with older
> versions of CMake that don't have the newer GET_DIRECTORY_PROPERTY
> functionality.
>
> INCLUDE(subdir/CMakeLists.txt)  or
> INCLUDE(subdir/sources.cmake)
>
> Inside these directories paths are relative to the CMakeLists.txt file that
> included it.
>
> sources.cmake :
>
> SET(MY_SOURCES
>     subdir/Source.cc
>     subdir/Source2.cc
>     subdir/Source3.cc
>     )

Thanks James,

for the moment I am assuming the last version.

BTW, I always store all files with complete path, this avoids all problems 
with relative paths.

Cheers,

> James
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake

-- 
Axel Roebel    
IRCAM Analysis/Synthesis Team
Email: Axel.Roebel at ircam.fr | Phone: ++33-1-4478 4845 | Fax: ++33-1-4478 1540


More information about the CMake mailing list