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

Stephen Collyer scollyer at netspinner.co.uk
Fri Mar 28 06:26:43 EDT 2008


Timenkov Yuri wrote:
> 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.

Right, but that isn't a good solution for me.

> 2) Point -DCMAKE_INCLUDE_PATH command line parameter or environment variable 
> to /usr/local/include. This forces cmake to search in /usr/local/include 

I've tried setting CMAKE_INCLUDE_PATH explicitly prior to running the
find script in a CMakeList.txt file, and it makes no difference. See
my later posting.

> 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.

Right. So, if I understand correctly, I force FIND_PATH to look in
/usr/local with, say:

FIND_PATH(IDIR NAMES curl/curl.h PATHS /usr/local/include NO_DEFAULT_PATH)

If that succeeds, the following FIND_PATH is a no-op, whereas if
it fails then the default paths are searched ?

-- 
Regards

Steve Collyer
Netspinner Ltd


More information about the CMake mailing list