[CMake] Why bother with FIND_LIBRARY()

Eric Bolz ebolz at mitre.org
Wed Oct 27 14:49:16 EDT 2004


I've been using FIND_LIBRARY do locate all of the libraries my project 
needs.  I've noticed, however the libraries I find are not necessarily 
the ones that get linked. 
For example, say I do the following:
FIND_LIBRARY(LIB_1    NAMES  m         PATHS /usr/lib)
FIND_LIBRARY(LIB_2    NAMES  socket  PATHS  /usr/local/lib)
TARGET_LINK_LIBRARIES( my_executable   ${LIB_1}  ${LIB_2})
In my Makefile, I get something like this:
gcc   -L/usr/lib  -L/usr/local/lib -lm  -lsocket

The problem is that even though I did all the work of locating the 
socket library in /usr/local/lib, I can't be sure that the linker won't 
pick up a different one from /usr/lib
cmake could do the following:
gcc  -l/usr/lib/libm.a  -l/usr/local/lib/libsocket.a
Why does cmake separate the library name from the path?
This make me wonder about the value of FIND_LIBRARY().  Why bother with 
FIND_LIBRARY if cmake is going to ignore what I found?  Is there some 
benefit to FIND_LIBRARY() I'm not aware of?

Eric
 
















More information about the CMake mailing list