[CMake] Why bother with FIND_LIBRARY()
Troels Frimor
troels at in.tum.de
Wed Oct 27 16:09:42 EDT 2004
Hi Eric,
to FIND_LIBRARYs defense, I must admit that I use it quite a lot.
For instance, it does give you the advantage that you can make certain
decisions at configuration time - writing a config.h file or checking
whether a certain library is present and give correct warnings (quite
useful if your product use a lot of third party libraries).
Furthermore, what if I just want to know whether a certain library is
there? Like if it is already in the system, there is no need for me to
compile one with the same functionality...
I know that I did not answer your question completely, but I would just
like to point out that we are some that find it useful. ;-)
regards,
Troels
Eric Bolz wrote:
> 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