[CMake] Find preferentially in /usr/local/lib not working

Timenkov Yuri ytimenkov at parallels.com
Fri Mar 28 06:16:19 EDT 2008


On Friday 28 March 2008 12:48:49 Stephen Collyer wrote:
> I'm trying to change some find* modules to prefer /usr/local/lib
>
> over /usr/lib and I can't get it to work. I have, for example:
> > FIND_PATH(CURL_INCLUDE_DIR
> >     NAMES
> >       curl/curl.h
> >     PATHS
> >       /usr/local/include
> >       /usr/include
> > )
>
> but this sets CURL_INCLUDE_DIR to /usr/include even though I have
> a curl/curl.h in /usr/local/include.
>
> Can someone tell me what I'm doing wrong here ?
1) Explicitly pass -DCURL_INCLUDE_DIR=/usr/local/include to cmake.
2) Point -DCMAKE_INCLUDE_PATH command line parameter or environment variable 
to /usr/local/include. This forces cmake to search in /usr/local/include 
first.
3) make 2-step find_path call (from cmake --help-command find_path)
>        The reason the paths listed in the call to the command are searched
>        last is that most users of CMake would expect things to be found
> first in the locations specified by their environment.  Projects may
> override this behavior by simply calling the command twice:
>
>           FIND_PATH(<VAR> NAMES name PATHS paths NO_DEFAULT_PATH)
>           FIND_PATH(<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.
Therefore, you first specify /usr/local/include in PATHS (as you done it) and 
set NO_DEFAULT_PATH. And make second call to use usual search order.


More information about the CMake mailing list