[CMake] Could somebody please explain how caching works with NOTFOUND variables?

Alan W. Irwin irwin at beluga.phys.uvic.ca
Wed Oct 18 19:31:49 EDT 2006


On 2006-10-18 22:54+0200 Alexander Neundorf wrote:

>
> Von: "Alan W. Irwin" <irwin at beluga.phys.uvic.ca>
>> Is there a general rule I can use to always predict the results of
>> trying to overwrite variables that have been cached by one of the FIND
>> commands?

> The find_xxx() calls try to load the value from the cache. If it's not
there they try to find the stuff. If it's in the case but it contains
"NOTFOUND" they search again. This way if something wasn't found and you
install the lib it searches the next time again and will find it.

Thanks, Alex, for that explanation (and thanks to Brad for his prior
explanation).  To state this important rule even more clearly I suggest
the following wording:

The FIND_xxx() commands try to load the value of <VAR> from the cache.  If
it is not there OR if it is there but set to a non-TRUE values such as
<VAR>-NOTFOUND then the find is attempted and the resulting value of <VAR>
cached.  Otherwise, the find is not attempted and the cached value of <VAR>
is left unchanged.  This special treatment of cached values for the
FIND_xxx() commands allows finding of newly installed files, etc., without
the old cached <VAR>-NOTFOUND value interfering.  This special treatment
also allows a useful combination of results from a succession of FIND_xxx()
commands if the same <VAR> is used for all of them.

I suggest this important additional caching rule concerning the FIND_xxx
commands should be stated prominently in the principal documentation that is
obtained by running the "cmake --help-full" command.  To be fair, somewhere
in the Wiki (I have lost the exact reference) I recall there is a specific
example of the above rule in action, but it wasn't as clearly explained as
above, and, in any case, I always assumed the Wiki was mistaken (or left
over from an older version of CMake) since the special rule wasn't
documented in the principal documentation.

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