[CMake] find_program search order

Andreas Beckermann b_mann at gmx.de
Thu Jul 27 19:20:21 EDT 2006


Hi
I have a problem with the search order of FIND_PROGRAM in cmake 2.4.2. The 
docs say:

[...]
Projects may override this behavior by simply calling the command twice:
          FIND_PROGRAM(<VAR> NAMES name PATHS paths NO_DEFAULT_PATH)
          FIND_PROGRAM(<VAR> NAMES name)
Once one of these calls succeeds the result variable will be set and stored in 
the cache so that neither call will search again

I use this as follows:

FIND_PROGRAM(KDE3_DCOPIDL_EXECUTABLE NAME dcopidl
  PATHS
  $ENV{KDEDIR}/bin
  ${KDE3PREFIX}/bin
  /opt/kde/bin
  /opt/kde3/bin
  NO_DEFAULT_PATH
)
FIND_PROGRAM(KDE3_DCOPIDL_EXECUTABLE NAME dcopidl)

If I make sure that $KDEDIR is not set, this code will fail on my debian 
system, although dcopidl is installed in /usr/bin. If I remove 
NO_DEFAULT_PATH, this code works perfectly.
The code _also_ works correctly, if I remove the first FIND_PROGRAM() call 
completely. Once the KDE3_DCOPIDL_EXECUTABLE variable is set to anything, 
FIND_PROGRAM is apparently a noop.

The following code confirms that:
SET(KDE3_DCOPIDL_EXECUTABLE "")
FIND_PROGRAM(KDE3_DCOPIDL_EXECUTABLE NAME dcopidl)

This code won't find dcopidl. If I remove the SET() line however, dcopidl _is_ 
found.

So to me this looks like a cmake bug. Any idea how to work around this?

CU
Andi


More information about the CMake mailing list