[CMake] Linking Behavior of Static Libraries on Windows

Filipe Sousa natros at gmail.com
Wed Mar 21 18:18:14 EST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

bpwlist at cox.net wrote:
> Hi All,
> 
> I have a static library that I'm trying to compile and link under windows.  It depends on other static libraries.  It appears that the default behavior of cmake is to defer the linking of the dependencies until they are needed by a dll or executable.  There is no way under cmake that I have found to link the depedencies to the static library at time of creation.    Is this really the behavior that is desired?

I think this is the standard behavior.

> It appears that CMake ignores LINK_DIRECTORIES and TARGET_LINK_LIBRARIES when link the static library.  When the library is needed by a dll or executable the TARGET_LINK_LIBRARIES will be carried over but the user must specify the LINK_DIRECTORIES again.  The library that am I creating is suppose to be facade to the underlying dependencies so having to do this kind of defeats the purpose.  I have been able to do what I want with VS7 directly but haven't found a way to do this with cmake.

LINK_DIRECTORIES is deprecated

> Any ideas?

I don't see why this is problem. If you have libA, libB and libC (B
depends on A and C depends on B) and you link the executable against C
(TARGET_LINK_LIBRARIES(exe C) cmake knows that needs B and A and does
that for you.

> Thanks for the help,
> 
> Bryan Walsh


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFGAb01bQdNYqwwwCwRAoWVAJ9RYeUS255myAcSnDtosmZowy5EMwCgnZNN
zY+nh4NILIAzTDCQTaH5ZbE=
=KR9M
-----END PGP SIGNATURE-----


More information about the CMake mailing list