[CMake] Testing whether a variable has already been assigned a non-null value

Alan W. Irwin irwin at beluga.phys.uvic.ca
Sun Oct 1 22:27:15 EDT 2006


I have noticed tests like

IF("${VARIABLE}" MATCHES "^${VARIABLE}$")

in, e.g., CheckFunctionExists.cmake where VARIABLE is a macro argument. From
the context I assume it is a test for whether the actual variable used in
the macro call has been assigned a non-null value, but I don't get why
it works. Could somebody please explain?

What is the best way to decide if the variable X has been assigned a
non-null value when X is not an argument of a macro?  Something like "IF(NOT
X)" ?  Or is there some transformation of the above MATCHES text that is
recommended?

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 Yorick front-end to PLplot (yplot.sf.net); 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