[CMake] FIND_FILE Issue

Alan W. Irwin irwin at beluga.phys.uvic.ca
Mon Dec 17 13:26:33 EST 2007


On 2007-12-17 14:55+0530 Surya Kiran Gullapalli wrote:

> Hello all,
> I'm a newbie to Cmake and I'm having trouble in FIND_FILE.
>
> I'm using FIND_FILE in a loop like this.
>
> SET (${THIS_FILE} INTERNAL "Temporary Variable" FORCE)
> # I Tried this one also
> # SET (THIS_FILE INTERNAL "Temporary variable" FORCE). But this one
> threw errors.
> FOREACH (ofile ${FILES})
> FIND_FILE (THIS_FILE ${ofile} PATHS ${path1} ${path2} ${path3})
> MESSAGE (${THIS_FILE})
> # I've used MARK_AS_ADVANCED (CLEAR THIS_FILE), but the result was the same.
> ENDFOREACH (ofile)
>
> FInd_file runs for the first time and if the file is found it sets the
> variable THIS_FILE and it is cached. For the second time, FIND_FILE
> does not gets executed due to the presence of cached variable
> THIS_FILE. So in the end I end up with only one file.
>
> Questions.
>
> 1. How do i clear a cached variable ?
> 2. How do i tell CMAKE not to write the variable to Cache ?
> 3. How do i use FIND_FILE to locate multiple files (like the one I've
> explained above)?

Try setting <VAR> to <VAR>-NOTFOUND (i.e., set(THIS_FILE THIS_FILE-NOTFOUND)
before each FIND_FILE in the loop.  For some additional documentation of
<VAR>-NOTFOUND see the FIND_FILE 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 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