[CMake] Recursive dependencies and static libraries

Jed Brown jed at 59A2.org
Fri Nov 7 03:32:08 EST 2008


On Thu 2008-11-06 21:03, Jed Brown wrote:
> On Thu 2008-11-06 13:18, Bill Hoffman wrote:
> > Jed Brown wrote:
> >
> >> The FindPkgConfig.cmake module looks broken too, it assumes that
> >>
> >>   -L/A -la -L/B -lb
> >>
> >> is equivalent to
> >>
> >>   -L/A -L/B -la -lb
> >>
> > I don't see where the above would fail.

This can also fail, but I should have written

  -L/B -L/A -la -lb

since the existing modules are doing two things wrong.  When the
compiler parses the link line, it builds a stack of libraries to search.
This stack must be searched incrementally.

In the original example (-L/A -la -L/B -lb) the linker will look for
liba.{so,a} in /A, then in system directories.  It will look for
libb.{so,a} in /B, then in /A, then in system directories.

The existing CMake modules are passing the complete list of directories
as HINTS when looking for every library.  This is wrong because the
linker only searches those directories appearing *before* the lib.

The existing CMake modules are passing the libraries to find_library()
in the order they appear on the command line.  This is wrong because
find_library() searches HINTS in forward order while the linker searches
the stack starting from the top (i.e. reverse order as they appear on
the command line).


Jed
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20081107/87dfa906/attachment.pgp>


More information about the CMake mailing list