[CMake] target_link_libraries: prefer static to dynamic

Alexander Neundorf a.neundorf-work at gmx.net
Sun Jan 3 14:26:11 EST 2010


On Monday 28 December 2009, Bill Hoffman wrote:
> Pau Garcia i Quiles wrote:
> > I'm using CMake 2.8.0 on Linux. Yes, Michael is right: I want it to
> > happen automagically. That was the whole point of this thread :-)
>
> OK, well the thread has a very bad subject then....
>
> It should be "force find_library to choose static over shared".  This
> really has nothing to do with target_link_libraries at all.  When given
> a static library target_link_libraries will use it.

it would be really nice if this was possible. I think this must be more or 
less the one remaining missing feature of cmake ;-)

> The next part is how to change find_library to find only static
> libraries.   If you really wanted this now, you could implement it in
> cmake code for your project using find_file and only looking for .a
> libraries if UNIX is on.  For windows it would be much harder to
> implement as there is no way to tell the difference from the shared and
> static as they both end in .lib.

Isn't there some "binutil" which can tell what kind of library some .lib is ? 
Or maybe every dll (and that way the accompanying lib) has some functions 
which only dlls have ?
Or maybe they references some special functions which maybe could be checked 
with something like nm ?

Alex


More information about the CMake mailing list