[CMake] Re: How to update a variable inside a subfolder?

Peter Soetens peter.soetens at fmtc.be
Tue Jan 30 15:23:52 EST 2007


Quoting kitts <kitts.mailinglists at gmail.com>:
> On Monday 29 Jan 2007 IST, Alan W. Irwin wrote:
>> BTW, my understanding of why variables set in subdirectories do not
>> propagate to parent directories is the CMake developers are using this
>> rule to (rightly) limit variable scope to make it more difficult to have
>> cross-directory bugs.

What is a cross-directory bug ?

>
> I agree it's the right way. Its pass-by-value but i also wanted the option
> of a pass-by-reference when one knows exactly what he/she is doing. ;-)

We are using ENV{MY_SOURCES_LIST} to do the trick. This bypasses the 
use of CMake variables:

in subdir:
SET( ENV{MY_SOURCES_LIST} "$ENV{MY_SOURCES_LIST} Src1.cpp Src2.cpp")

in main dir:
SET(ENV{MY_SOURCES_LIST} "")
ADD_SUBDIRECTORY( subdir )
SET(FINAL_SOURCES $ENV{MY_SOURCES_LIST})

Now my $100.000.000 question is: And how does this trigger the 
cross-directory bug ?

Peter
-- 
www.fmtc.be


----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.



More information about the CMake mailing list