[CMake] find_library first searches for static libraries

Philip Lowman philip at yhbt.com
Tue Jul 1 22:25:32 EDT 2008

On Tue, Jul 1, 2008 at 2:37 PM, Nicolas Desprès <nicolas.despres at gmail.com>

> Hi list,
> I'm looking for a way to say to find_library (cmake 2.6.0) that I
> prefer static libraries rather than shared libraries. It seems that
> there is no option to do. The only work around I found is the
> following but it is not portable obviously.
> find_library(OPENSSL_LIBRARY ssl)

2.6.0 checks the library names specified to find_library() as filenames
first so you could do something like this to ensure that on a Unix build it
would pick up the static library first:

find_library(OPENSSL_LIBRARY libssl.a)
find_library(OPENSSL_LIBRARY ssl)
find_library(OPENSSL_LIBRARY NAMES libssl.a ssl)

Unfortunately this only works for CMake code that you can control.  If one
had to use a CMake module to add an external dependency your idea would seem
to be the only viable option without modifying the module code itself.

Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20080701/b6893e74/attachment.htm>

More information about the CMake mailing list