[CMake] Re: How to update a variable inside a subfolder?
Alan W. Irwin
irwin at beluga.phys.uvic.ca
Tue Jan 30 16:09:37 EST 2007
On 2007-01-30 21:23+0100 Peter Soetens wrote:
> 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 ?
If you limit scope, then you can have variables of the same name in
different directories not interfering with each other.
>
> 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 ?
Not "the" cross-directory bug. However, environment variables introduce the
possibility of cross-directory bugs. Since such variables have global scope
in every directory you will have to be extra careful to give unique names to
them.
Please send a cheque for $100.000.000. :-)
Alan
__________________________
Alan W. Irwin
Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).
Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the Yorick front-end to PLplot (yplot.sf.net); the
Loads of Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________
Linux-powered Science
__________________________
More information about the CMake
mailing list