[CMake] Passing values back from SUBDIRS

John Biddiscombe biddisco at cscs.ch
Wed Mar 23 03:41:36 EST 2005


>  (Perhaps I could write data to a file using append and then read it 
> back somehow)

I am having trouble with this too.
If I write a blank file at the start of the CMakelists file in the top 
dir, it does not actually write anything until after the subdirs have 
written their stuff. So it overwrites them. Additionally, the Subdirs 
write out stuff 3 times (3? seems a strange number of times to scan each 
cmake file).
So the subdirs are evaluated before the main dir has a chance to 
initialize things and if you attempt to read the file, it occurts before 
the sub dirs have written anything

FILE(WRITE filename "STUFF")
SUBDIR(subdir writes "MORE STUFF" into same file using APPEND)
FILE(READ filename variable)

variable now holds "STUFF". Blinkin Flip.  If I remove the FILE(WRITE 
filename "STUFF") from the top level cmake file, then I get
MORE STUFF MORE STUFF MORE STUFF
as my contents - and the next time I run it I get 6 of them because I've 
not reset the file with blank at start.

hmmm. There must be an easy way of doing this.

JB




More information about the CMake mailing list