[CMake] lexical scoping

Miguel A. Figueroa-Villanueva miguelf at ieee.org
Sat Nov 3 09:25:14 EDT 2007


On 11/3/07, Alexander Neundorf wrote:
> On Friday 02 November 2007, KSpam wrote:
> > Brandon,
> >
> > You missed the part where Bill mentioned that variable_scope would take
> >
> > multiple arguments.  Your example:
> > > variable_scope_begin(scratch_preamble)
> > > variable_scope_begin(got_match)
> > > variable_scope_begin(not_trail)
> > > variable_scope_begin(empty)
> > > # [...]
> > > # my actual code, blah blah blah
> > > # [...]
> > > variable_scope_end(scratch_preamble)
> > > variable_scope_end(got_match)
> > > variable_scope_end(not_trail)
> > > variable_scope_end(empty)
> >
> > would reduce to:
> >
> >       variable_scope_begin(scratch_preamble got_match not_trail empty)
> >       # [...]
> >       # my actual code, blah blah blah
> >       # [...]
> >       variable_scope_end(scratch_preamble got_match not_trail empty)
>
> How about naming it "declare_local_vars(<vars>)" or just "local(<vars>)"
> instead of variable_scope_begin() and have it end always at endmacro() ?

I like both alternative names better, but can't rely on endmacro() for
ending since this causes an unnecessary limitation. That is, you'd
want to use this in FindXXX.cmake modules and other scripts not only
macros.

--Miguel


More information about the CMake mailing list