[CMake] Howto let FIND_LIBRARY prefer static over shared libraries

Brad King brad.king at kitware.com
Fri Dec 10 08:55:56 EST 2010


On 12/10/2010 06:36 AM, Marcel Loose wrote:
> Is there a way to let FIND_LIBRARY prefer static over shared
> libraries?
> I know of one, but that's a bit hack-ish: 
> 
>   SET(CMAKE_FIND_LIBRARY_SUFFIXES .a)
> 
> Are there other options? 
> Ideally, I would like to be able to specify this per library search,
> i.e. as an option to FIND_LIBRARY.

Just ask for the archive name first:

  find_library(MYLIB NAMES libmylib.a mylib)

-Brad


More information about the CMake mailing list