[CMake] adding to variables within subdirectories

Eric Noulard eric.noulard at gmail.com
Tue Oct 14 02:07:10 EDT 2008


2008/10/14 Paul Harris <harris.pc at gmail.com>:
> Hi,
>
> In the root CMakeLists.txt, I have a variable - a list of files...
>
> set( TRANSFILES )   ? how do i create an empty list ?
>
>
> then i add a subdirectory
> add_subdirectory(whatever)
>
> and in whatever/CMakeLists.txt, i want to add some files...
>
> file (GLOB CPPFILES *.cpp)
>
> set (TRANSFILES ${TRANSFILES} ${CPPFILES})
>
>
>
> and now, back in the root CMakeLists.txt, I want to do something on that
> list of files...
>
> qt4_create_translation(QM_FILES ${TRANSFILES} translation/app_fr.tr)
>
>
> But, I find that whatever I do to the variable in the subdirectory is not
> seen in the root dir... How should I do this ?

If you are using CMake 2.6.x you should try with "PARENT_SCOPE"

set (TRANSFILES ${TRANSFILES} ${CPPFILES} PARENT_SCOPE)

look at SET documentation.



-- 
Erk


More information about the CMake mailing list