[CMake] FIND_LIBRARY - always true - very strange...
Brad King
brad.king at kitware.com
Wed May 11 14:03:38 EDT 2005
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