[CMake] find_program search order
William A. Hoffman
billlist at nycap.rr.com
Fri Jul 28 09:49:45 EDT 2006
At 07:20 PM 7/27/2006, Andreas Beckermann wrote:
>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?
The key word is NAMES and not name, that is the problem. It should be :
Either this:
FIND_PROGRAM(KDE3_DCOPIDL_EXECUTABLE NAMES dcopidl
PATHS
$ENV{KDEDIR}/bin
${KDE3PREFIX}/bin
/opt/kde/bin
/opt/kde3/bin
NO_DEFAULT_PATH
)
FIND_PROGRAM(KDE3_DCOPIDL_EXECUTABLE NAMES dcopidl)
Or this:
FIND_PROGRAM(KDE3_DCOPIDL_EXECUTABLE dcopidl
PATHS
$ENV{KDEDIR}/bin
${KDE3PREFIX}/bin
/opt/kde/bin
/opt/kde3/bin
NO_DEFAULT_PATH
)
FIND_PROGRAM(KDE3_DCOPIDL_EXECUTABLE dcopidl)
http://www.cmake.org/HTML/Documentation.html
FIND_PROGRAM(
<VAR>
name | NAMES name1 [name2 ...]
PATHS path1 [path2 ... ENV var]
[PATH_SUFFIXES suffix1 [suffix2 ...]]
[DOC "cache documentation string"]
[NO_DEFAULT_PATH]
[NO_CMAKE_ENVIRONMENT_PATH]
[NO_CMAKE_PATH]
[NO_SYSTEM_ENVIRONMENT_PATH]
[NO_CMAKE_SYSTEM_PATH]
)
-Bill
More information about the CMake
mailing list