[CMake] target_link_libraries: prefer static to dynamic

Michael Wild themiwi at gmail.com
Sun Dec 27 04:59:42 EST 2009


On 26. Dec, 2009, at 17:53 , Pau Garcia i Quiles wrote:

> Hello,
> 
> I think this has already been discussed and the answer is negative but
> still: when I do target_link_libraries to an external library (for
> instance, my application needs to link to sqlite), is it possible to
> tell CMake to link to the static version of sqlite instead of the
> dynamic version?
> 
> For instance, in Debian the libsqlite3-dev package contains both the
> static and the dynamic versions of the library and they have the very
> same name:
> 
> /usr/lib/libsqlite3.a
> /usr/lib/libsqlite3.so
> 
> ( http://packages.debian.org/sid/i386/libsqlite3-dev/filelist )
> 
> Is this feature going to be implemented any time soon? I have not
> looked at the sources for target_link_libraries but at first sight it
> doesn't look difficult to add  something like
> "static;optimized;libsqlite3.a;dynamic;optimized;libsqlite3.so".
> There's the problem of find_library on Windows confusing the .lib as
> the import for a .dll with a static .lib library but IIRC it's
> possible to detect that.

Perhaps a variable CMAKE_FIND_STATIC with the possible values "FIRST" "LAST", "ONLY" and "NEVER, similar to CMAKE_FIND_FRAMEWORK, would fit the bill?


Michael



More information about the CMake mailing list