[CMake] communicat variables from sub directories

Brad King brad.king at kitware.com
Thu Apr 6 10:42:45 EDT 2006


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
)

-Brad


More information about the CMake mailing list