[CMake] Static linking and find_library

Marcel Loose loose at astron.nl
Tue May 12 03:09:14 EDT 2009


Thanks Brad,

Didn't realize that.
Does that also mean that I could change the default search order by
using:

  find_library(MATH_LIB NAMES libm.a libm.so)


Best regards,
Marcel Loose.

On Mon, 2009-05-11 at 13:39 -0400, Brad King wrote:
> 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