Variables can be a PITA :) They have unusual scoping, mixed documentation, etc. In CVS there have been some changes. We have extended the concept of properties which are scoped to an object (source file, target, directory, global, test, for example) and are documented, can be inherited, and can be tested to verify they are documented. This is nice and meets some needs of CMake. But ... there are still variables. Recently Bill and I have started documenting variables in the source code (cmake --help-variables works) such that you can get documentation on supported variables in cmake. These documented variables are the ones we will try to keep backwards compatible (tm), all others are up in the air.
But to the question at hand...adding scope to variables. Variables have scope right now of 1) the CMakeListfile they are defined in 2) any included files that are included after the variable is set 3) and subdirectories of the directory they were defined in and processed after the setting of the variable 4) they can be access globally using get_directory_property and specifying the directory etc the macro command is like a cpp macro so scoping does not make a lot of sense for it. What would/could make sense is a function command that creates a function. (think of the difference in a macro versus a function in c, macros have no inherent scope they are just string replacements, functions do have scope built in). With a function command we could probably figure out some way to create variables that are scoped to the function only. Most of the places we are using macros really could/should be functions. My main question would be if we had a function, how would you want variables handled. 1) all set commands create "local" variables to the function (a mess for functions that do an include of other cmake code) 2) a special set command or signature that creates a local variable scoped to the current function 3) a mode to switch the behavior of set (yuck) 4) something else Ken Ken Martin PhD Kitware Inc. 28 Corporate Drive Clifton Park NY 12065 518 371 3971 > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of KSpam > Sent: Friday, November 02, 2007 1:32 PM > To: cmake@cmake.org > Subject: Re: [CMake] lexical scoping > > On Friday 02 November 2007 09:54:51 Brandon Van Every wrote: > > Is it feasible to modify the CMake language to have lexical scoping? > > I agree. The lack of variable scoping is currently my > biggest annoyance with > custom macros. Additionally, I believe that custom macros > are pretty much > required for any mid to large scale project. Life in the > CMake scripting > language would be so much nicer if we could scope variables > at the macro > and/or file level. > > Justin > _______________________________________________ > CMake mailing list > CMake@cmake.org > http://www.cmake.org/mailman/listinfo/cmake _______________________________________________ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake