[CMake] fun with Boost - swap absolute library path for -L and -l?

Adam J Richardson fatman at crackmonkey.us
Thu Nov 11 07:33:02 EST 2010


On Thu, 11 Nov 2010 07:07:48 -0500
cmake-request at cmake.org wrote:

> Any help is greatly appreciated!

I'd help if I could. Unfortunately I'm still stuck on this. Usually I
can work around a problem given enough time, but this is a real
stumper. Actually I do have a suggestion (see below) but it's kind of
ugly.

> Adam J Richardson <fatman at ...> writes:
> > (That is, if I manually separate
> > "C:\Compilers\Libs\libboost_thread-mgw44-mt-1_44.a" into
> > "-LC:\Compilers\Libs -lboost_thread-mgw44-mt-1_44".)
> > 
> > Is there a way to have CMake do this by itself and not use absolute
> > paths? I've tried setting CMP0003 to OLD but it doesn't seem to do
> > that.  
>
> I've run into the same problem recently.
>
> It seems to be because the underlying find_library() call returns full
> paths instead of just library names.  Linking against libraries as
> inputs (specifying as full paths) instead of libraries (specifying
> name with -l) seems to lead to inconsistent results on different
> platforms.

Is this actually a CMake bug? Just after posting it occurred to me that
this might be a MinGW bug. Shouldn't g++ find the library whether you
give it "C:\Compilers\Libs\libboost_thread-mgw44-mt-1_44.a" or
"-LC:\Compilers\Libs -lboost_thread-mgw44-mt-1_44"?

> The FindBoost script does set a Boost_LIBRARY_DIRS variable, so you
> can use link_directories() to basically add the -L option.  But I'm at
> a loss as to how to properly set the -l options.

I suppose you could manually

set_target_properties(targ PROPERTIES LINK_FLAGS "${LINK_FLAGS}
-lboost_thread")

but that seems a little hackish. No, I'll poke some more at g++ and see
what I can come up with.

Regards,
Adam J Richardson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20101111/527a1756/attachment.pgp>


More information about the CMake mailing list