[CMake] target_link_libraries: prefer static to dynamic

Bill Hoffman bill.hoffman at kitware.com
Mon Dec 28 10:07:17 EST 2009


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.

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.


-Bill



More information about the CMake mailing list