[CMake] Possible bug in cmake version 2.4-patch 6 with macro argument testing

Alan W. Irwin irwin at beluga.phys.uvic.ca
Mon May 28 18:00:41 EDT 2007


On 2007-05-28 18:27+0100 Trevor Kellaway wrote:

> Alan,
>
> Do you concur the following is a real problem?

No, but then I am not really a CMake expert.  Instead, I am a goal-oriented
CMake user (i.e., I just want PLplot or whatever to build with no problems)
so I just try stuff until something works.  So when I discovered the
behaviour you have documented with macro parameters, I always used an
additional ${} (i.e., take contents of) operator when dealing with macro
parameters, and it seemed to work out.  So, for example, here is a complete
CMakeLists.txt example that works regardless of whether the argument is a
variable or constant.

****************
MACRO (MYMACRO boolarg)
   MESSAGE ("MYMACRO(${${boolarg}})")
   IF (${boolarg})
     MESSAGE ("${boolarg}=${${boolarg}} [True path]")
   ELSE (${boolarg})
     MESSAGE ("${boolarg}=${${boolarg}} [False path]")
   ENDIF (${boolarg})
ENDMACRO(MYMACRO)
set(whatever ON)
mymacro(whatever)
set(whatever OFF)
mymacro(whatever)
mymacro(1)
mymacro(0)
****************

The result of running cmake (2.4.6) on the above file is

MYMACRO(ON)
whatever=ON [True path]
MYMACRO(OFF)
whatever=OFF [False path]
MYMACRO()
1= [True path]
MYMACRO()
0= [False path]
-- Configuring done
-- Generating done
.....

That result (obtained by using an extra ${} for macro parameters ) seems
fine to me, but perhaps I have worked around a bug so long in CMake that I
am just not sensitive to something that may be legitimately bothering you.

So perhaps it is time for some real CMake experts to chime in here
about the interpretation of macro parameters.

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