Add a second set call after the first one in the top level CMakeLists.txt file. That will clear the local definition such that the toplevel CMakeLists will get the cache definition. For example...
# initialize the cachwe value set(myvar easterbunny CACHE INTERNAL "stored subdir values") # clear the local definition set(myvar) # let the subdir add to the cache add_subdirectory(subdir) # display the result message("${myvar}") it is a little odd but it should work for you. Another way to do this is with GET_DIRECTORY_PROPERTIES to get the value of the variable from the subdirs. Thanks Ken Ken Martin PhD Kitware Inc. 28 Corporate Drive Clifton Park NY 12065 518 371 3971 -----Original Message----- From: Luigi Calori [mailto:[EMAIL PROTECTED] Sent: Thursday, March 15, 2007 12:36 PM To: Ken Martin; cmake@cmake.org Subject: Re: [CMake] getting values from subdirs Ken Martin wrote: >I believe the following will work. In the top CMakeLists file... > >set(myvar initial-value CACHE INTERNAL "stored subdir values") >add_subdirectory(subdir) >message("${myvar}") > >Then in subdir.... > >set(myvar ${myvar} ${other-values-from-this-subdir} CACHE INTERNAL "stored >subdir values") > >Ken > > > I' v etried... but this don' t work: i have set(myvar initial-value CACHE INTERNAL "stored subdir values") add_subdirectory(subdir1) add_subdirectory(subdir2) add_subdirectory(subdir3) message("${myvar}") and seem that the init code in the main get galled before each subdir (this is a known issue).... I was searching for a workaround... >Ken Martin PhD >Kitware Inc. >28 Corporate Drive >Clifton Park NY 12065 >518 371 3971 > >-----Original Message----- >From: [EMAIL PROTECTED] >[mailto:[EMAIL PROTECTED] On Behalf Of Luigi >Calori >Sent: Thursday, March 15, 2007 12:06 PM >To: cmake@cmake.org >Subject: [CMake] getting values from subdirs > >I would like to being able to collect a list of values from a macro that >get called from several subdirs >The obvious solutions to init it into the main CMakeLists and update >whithin the macro does not work as (probably) the init inside the main >CmakeLists get executed >anyway for each subdir >If declare it CACH INTERNAL and I do no init, it get updated but retain >values on different CMake runs.... any thougt? >A possible solution is to write a file....but it does not seem much elegant > >Thanks anyway for the help >_______________________________________________ >CMake mailing list >CMake@cmake.org >http://www.cmake.org/mailman/listinfo/cmake > > > > > _______________________________________________ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake