[CMake] find_library questions

Alexander Neundorf a.neundorf-work at gmx.net
Wed Aug 4 15:53:04 EDT 2010


On Wednesday 04 August 2010, Dennis Schridde wrote:
> On Wednesday 04 August 2010 10:03:55 Denis Scherbakov wrote:
> > >> 1) Is it
>
> possible to
>
> > retrieve the path where find_library found the library?
>
> E.g. so I can setup
>
> > ..._LIBRARY_DIR correctly.
> >
> > Yes, see
>
> GET_FILENAME_COMPONENT.
>
> > 2) Is it possible to disable the "lib" prefix
>
> that find_library always seems to prepend when searching? I have a library
>
> that is called "thelibrary.so" instead of "libthelibrary.so".
>
> > Yes,
>
> specify name that you want to find. Like "NAMES libMyLib MyLib"
> Ah, so NAMES
> <name> specifies the literal name, while giving just <name> as a parameter
> to find_library will prepend "lib" and append ".so"?

No, Denis was only almost right.

If one of the names has a suffix, this one is treated as a full filename and 
nothing will be prepended/appended.
So
find_library(THELIB NAMES thelibrary.so)
or 
find_library(THELIB NAMES thelibrary.${CMAKE_SHARED_LIBRARY_SUFFIX})
should do what you want.

Alex


More information about the CMake mailing list