[CMake] target_link_libraries between dll and static libs

Andreas Fredriksson deplinenoise at gmail.com
Mon Jun 9 15:51:42 EDT 2008


On Mon, Jun 9, 2008 at 8:48 PM, Alexander Neundorf
<a.neundorf-work at gmx.net> wrote:
> Which behaviour do you expect here ?
> Not everything from slib will be included in dlib1.

Hi Alexander,
assuming you mean dlib2 (dlib1 lists slib in its
target_link_libraries, so it should get a copy of slib included). Let
me clarify:

Say I have one DLL (foo) which when built links together a static
library (bar) and some object files to form the DLL. Its interface is
DLL exported to some import library. To use the DLL, one must link
with that import library.

Now I introduce another DLL (baz) which uses the DLL foo, and
therefore lists it in its target_link_libraries() list.

In the default CMake behavior (2.6.0) the baz DLL is linked statically
to the static library bar as well. This can be harmless but in
practice it always costs something if nothing else than plain linking
time if the static library is several MB large.

I would expected that listing a DLL target in a target_link_libraries
would link with the import library of that DLL only, and nothing else,
since nothing else is needed to use that DLL.

Does this make sense? In essence I was surprised that the
INTERFACE-list wasn't set up to be only the import library.

Thanks,
Andreas


More information about the CMake mailing list