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

Alan W. Irwin irwin at beluga.phys.uvic.ca
Wed Oct 18 16:24:52 EDT 2006


I just ran across the following code in FindSWIG.cmake which I just don't
understand.

FIND_PATH(SWIG_DIR
   SWIGConfig.cmake
   /usr/share/swig1.3
   /usr/lib/swig1.3
   /usr/local/share/swig1.3)
FIND_PATH(SWIG_DIR
   swig.swg
   /usr/share/swig1.3
   /usr/lib/swig1.3
   /usr/local/share/swig1.3)

I don't have SWIGConfig.cmake installed on my platform so that first call to
FIND_PATH should set SWIG_DIR to "SWIG_DIR-NOTFOUND".  However, the results
of FIND_PATH are always cached according to the documentation of that
function so according to my mental model of caching, the second FIND_PATH
should never be able to change SWIG_DIR (even though I do have swig.swg
installed on my platform), and therefore according to that mental model
FindSWIG.cmake should always set SWIG_DIR as "SWIG_DIR-NOTFOUND" on my
platform.

Well, obviously I am missing something because FindSWIG.cmake actually sets 
SWIG_DIR:PATH=/usr/share/swig1.3 in CMakeCache.txt for my platform so could
somebody explain how my mental model of caching is incorrect?  Are FALSE
variable values such as "SWIG_DIR-NOTFOUND" allowed to be overwritten by
FIND_PATH even though they are cached from a previous FIND_PATH call?  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?

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