[CMake] lexical scoping

Brandon Van Every bvanevery at gmail.com
Sat Nov 3 11:39:18 EDT 2007


On Nov 3, 2007 11:13 AM, Bill Hoffman <bill.hoffman at kitware.com> wrote:
> David Cole wrote:
> > After all the discussion / suggestions that have been part of this
> > thread, I like the following best:
> >
> > local(scope_name)
> >   set(var1 "value1")
> >   set(var2 "value2")
> > endlocal(scope_name)
> >
> I would prefer to declare the variables that are part of the scope.  I
> think you would want to reference and set global variables from within a
> scope.

True.  Must admit my objection_meter goes down now that the reserved
words are much shorter.

> The PARENT_SCOPE maybe needed as well.

Why?  If you have local and global variables in the same scope, you
can set a global variable to the value of a local variable.  You don't
need a PARENT_SCOPE keyword, and you don't need a CACHE keyword.  I
think those keywords are a bad idea as far as making CMake scripting
more likeable.

> local(scope_name var1 var2 ... varN)
>
> endlocal(scope_name)

That would solve some retyping problems.  It's also consistent with
CMake scripting style elsewhere.  I can live with this.


Cheers,
Brandon Van Every


More information about the CMake mailing list