[CMake] Static linking and find_library

Brad King brad.king at kitware.com
Mon May 11 13:39:25 EDT 2009


Bill Hoffman wrote:
> Marcel Loose wrote:
>> 2) How can I persuade find_library() to only search for static
>> libraries?
>>
> You can't.

Yes, you can:

   find_library(MATH_LIB NAMES libm.a)

If you specify a valid library name then CMake will look for it directly
instead of prepending 'lib' and appending library extensions.

The reason there is no generic "find a static library" option is because
it is almost impossible to implement on windows where one cannot distinguish
import libraries and static libraries by their name.

-Brad


More information about the CMake mailing list