[CMake] find_program search order

William A. Hoffman billlist at nycap.rr.com
Fri Jul 28 10:37:38 EDT 2006


At 10:21 AM 7/28/2006, Andreas Beckermann wrote:
>Anyway I'd like to know why 
>  FIND_PROGRAM(KDE3_DCOPIDL_EXECUTABLE NAME dcopidl)
>works at all then. From the docs I'd say find_program should search for a 
>program named "NAME" now, which of course does not exist.
>However if KDE3_DCOPIDL_EXECUTABLE is not set, this call _does_ 
>find /usr/bin/dcopidl, although the "dcopidl" is at a meaningless (according 
>to the docs) position.
>
>Why is that so?
>And why does it behave differently when KDE3_DCOPIDL_EXECUTABLE has been set 
>to something before?
>I'd really like to understand tha

FIND_PROGRAM(KDE3_DCOPIDL_EXECUTABLE NAMES dcopidl) looks for 
NAMES then dcopidl it is a backwards compatibility for FIND_PROGRAM,
that is not documented.   The NAMES keyword was not required in prior
versions of cmake, so FIND(foovar foo1 foo2) is the same as 
FIND(foovar NAMES foo1 foo2)


If KDE3_DCOPIDL_EXECUTABLE has not been set at all, then FIND_* will run.
If KDE3_DCOPIDL_EXECUTABLE has any value other than:
KDE3_DCOPIDL_EXECUTABLE-NOTFOUND or NOTFOUND
FIND_* will not run.   The idea is once it is found or set by the user
in ccmake or CMakeSetup, you do not want to find it again.  So, if you 
set it to "" that is a value, and the FIND_* will not look for it again.
The VARNAME-NOTFOUND syntax is used to give better error messages.  
If you try to use a variable for something and it is set to VARNAME-NOTFOUND,
cmake can say, Error: this project is using the variable VARNAME but it has
not been correctly found by cmake.

-Bill



More information about the CMake mailing list