[CMake] FIND_LIBRARY - always true - very strange...

Christian Kienle Christian-kienle at losg.org
Wed May 11 14:30:48 EDT 2005


Hi Brad,

thanks for your quick response.

I grepped the CMakeCache.txt and found the "problem".

cmks-Computer:/Volumes/Files/Users/cmk/cppp/cmksql/libloader cmk$ cat  
CMakeCache.txt  | grep dl
//Flags used by the linker during the creation of dll's.
//Where can the dl library be found
PATH_OF_LIB_DL:FILEPATH=/usr/lib/libdl.dylib

Just deleted this file and all begun again and worked.

But do I have to delete this file every time I want to test my build  
process?



On May 11, 2005, at 8:03 PM, Brad King wrote:

> Christian Kienle wrote:
>
>> Hi all,
>> I have a strange problem - see my CMakeLists.txt file:
>>       1 PROJECT(LIBLOADER)
>>       2
>>       3 # let's look for libdl (libloader needs this for dlopen()   
>> and so on.
>>       4 FIND_LIBRARY(PATH_OF_LIB_DL NAMES dadfdfasdf PATHS /usr/lib)
>>       5 MESSAGE("-- checking for aNiceLib... ${PATH_OF_LIB_DL}")
>>       6 IF (PATH_OF_LIB_DL)
>>       7         MESSAGE("FOUND")
>>       8 ELSE (PATH_OF_LIB_DL)
>>       9         MESSAGE("-- error: libdl not found.")
>>      10 ENDIF (PATH_OF_LIB_DL)
>> If I execute cmake . in my source directory I get this:
>> cmks-Computer:~/Desktop/cmksql/libloader cmk$ cmake .
>> -- Check for working C compiler: gcc -- works
>> -- Check for working CXX compiler: c++ -- works
>> -- checking for aNiceLib... /usr/lib/libdl.dylib
>> FOUND
>> -- Configuring done
>> -- Generating done
>> -- Build files have been written to: /Users/cmk/Desktop/cmksql/ 
>> libloader
>> But why did cmake found "dadfdfasdf"? It's not there... :/
>>
>
> Change your message command to
>
> MESSAGE("FOUND: [${PATH_OF_LIB_DL}]")
>
> and the problem will become clear.  Since you are not doing an out- 
> of-source build the CMakeCache.txt in your source tree is being  
> used.  It is leftover from some previous run in which your library  
> name was found.  Once FIND_LIBRARY finds a library it saves the  
> result in the variable given so that it does not have to search  
> again.  This is the idea of the cache.
>
> -Brad
>
>



More information about the CMake mailing list