[CMake] An observation about CTest

Alan W. Irwin irwin at beluga.phys.uvic.ca
Mon Jun 28 11:22:47 EDT 2010


On 2010-06-28 07:03+0200 Andreas Mohr wrote:

> Hello,
>
> On Sun, Jun 27, 2010 at 05:09:41PM -0400, cmake-request at cmake.org wrote:
>> Your remarks focus on old-fashioned macros so it is possible you are not
>> aware of functions? As far as I know, most or all macros can be replaced by
>> functions which do have the nice property of not polluting the global
>> namespace.  So newly developed build systems should use functions wherever
>> possible, and certainly for old CMake-based build systems I am associated
>> with I am trying to move to functions as time permits.
>
> That's all fine and dandy (and you've written some nice prose about
> it :), but I've just been reading man cmakecommands of Debian cmake
> 2.8.1-5(!) from top to bottom and bottom to top, and nowhere does it
> mention _any_ underlying difference between macros and functions.

Look for "scope" within the documentation.  In particular in the set command
documentation you will find

"If PARENT_SCOPE is present, the variable will be set in the scope
above the current scope.  Each new directory or function creates a new
scope."

Note macros are not mentioned there so there is a clear difference between
macros and functions that you were searching for.  From experience that last
sentence means that without PARENT_SCOPE (and without CACHE) variables set
in directories are only available to that directory and sub-directories.  I
therefore have assumed (and IIRC this was mentioned when functions was first
discussed on the list here) that without PARENT_SCOPE (and without CACHE),
variables set in functions are only available to that function (and
functions it calls?)

The above documentation assumes everybody knows what is meant by scope, but
an explicit paragraph about that somewhere in the documentation would be
worthwhile.  Also, I think there should be a sentence in the documentation
of macros that deprecates them in favor of functions (because of the known
scope issue with macros).

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 libLASi project (unifont.org/lasi); 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