[CMake] Check_library_exists don't found a function in a static library

victor sv victorsv at gmail.com
Fri Mar 13 05:18:06 EDT 2015


Hello again,

the problem was that the static version of the METIS library must be linked
with the MATH library (libm). After adding:

SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}
/path/to/math/library )

it seems that all works fine.

Best regards,
Víctor.



2015-03-10 11:02 GMT+01:00 victor sv <victorsv at gmail.com>:

> Hello all,
>
> I'm a newbie using CMake and I'm trying to migrate the compilation of a
> fortran project to CMake.
>
> I'm trying to detect the METIS library with find_library(). Inside my
> FindMETIS.cmake I want to check the existence of some functions to set the
> library version with:
>
> CHECK_LIBRARY_EXISTS(metis METIS_SetDefaultOptions /path/to/metis
> VARIABLE_NAME)
>
>
> If /path/to/metis contains the METIS shared library (libmetis.so) it works
> as expected, but if /path/to/metis only contains the static version of the
> library (libmetis.a) CHECK_LIBRARY_EXISTS cannot found this function...
>
> I check that the library contains this function with the following result:
>
> $ nm libmetis.a  | grep -i setdefaultoptions
>> 0000000000000210 T metis_setdefaultoptions
>> 0000000000000220 T metis_setdefaultoptions_
>> 0000000000000230 T metis_setdefaultoptions__
>>                              U METIS_SetDefaultOptions
>> 0000000000000200 T METIS_SETDEFAULTOPTIONS
>>                              U METIS_SetDefaultOptions
>> 0000000000000030 T METIS_SetDefaultOptions
>>
>
> I don't know if this the expected behaviour of this macro, but anyway I
> need to do this check in both, shared and static library. How can I do this?
>
> Any help would be appreciated.
>
> Thanks,
> Víctor.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150313/39dc82ec/attachment.html>


More information about the CMake mailing list