[CMake] What is the prescribed way to link in dependencies for a static library

Alexander Neundorf a.neundorf-work at gmx.net
Tue Sep 17 14:30:52 EDT 2013


On Tuesday 17 September 2013, James Bigler wrote:
> On Tue, Sep 17, 2013 at 11:05 AM, Dan Kegel <dank at kegel.com> wrote:
> > On Tue, Sep 17, 2013 at 9:41 AM, James Bigler <jamesbigler at gmail.com>
> > 
> > wrote:
> > > I have a static library I found using find_library.  Typically with
> > 
> > shared
> > 
> > > libraries I just link against the library and the dependencies come
> > > along for the ride.
> > > 
> > > What is the prescribed way of doing this for static libraries?
> > 
> > How static are you trying to be?
> > 
> > For comparison, it's worth noting that pkg-config doesn't support
> > mixed static+dynamic linking,
> > https://bugs.freedesktop.org/show_bug.cgi?id=9917
> > probably because it's hard to know which dependencies one wants to
> > be static, and which dynamic.
> > 
> > (Me, I think I just manually find and add the dependencies as if my
> > app depended on them.)
> > - Dan
> 
> I'm not trying to be particularly static.  I just need my symbols to be
> resolved at the point where the shared library is linked.  I think I'm just
> going to add the missing libraries to my library variable.

Yes.
Similar to what FindPNG.cmake does, it searches libpng, then searches libz, 
and adds them both to the result variable.

Alex


More information about the CMake mailing list