[CMake] How to check for a symbol that requires two header files in CMake?

Sergei Nikulov sergey.nikulov at gmail.com
Thu Nov 29 02:25:39 EST 2012


2012/11/29 Martin Sustrik <sustrik at 250bpm.com>

> Hi all,
>
> I am trying to find out whether getifaddrs function is avialable.
>
> To get symbol getifaddrs defined you have to include both sys/types.h and
> ifaddrs.h. Here's the synopsis of the function from the man page:
>
>        #include <sys/types.h>
>        #include <ifaddrs.h>
>
>        int getifaddrs(struct ifaddrs **ifap);
>
> When checking whether the symbol exists, I've tried the following:
>
> set (CMAKE_EXTRA_INCLUDE_FILES sys/types.h)
> check_symbol_exists (getifaddrs ifaddrs.h SP_HAVE_IFADDRS)
> set (CMAKE_EXTRA_INCLUDE_FILES)
>
> However, the generated test program still includes only ifaddrs.h and thus
> fails to detect the symbol.
>
> How can I force it to include sys/types.h as well?
>
> Martin
> --
>
>
Have you tried  as per documentation provide list of files?

check_symbol_exists (getifaddrs "sys/types.h;ifaddrs.h" SP_HAVE_IFADDRS)

and don't forget this only for C.


-- 
Best Regards,
Sergei Nikulov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20121129/1ba5ae7e/attachment-0001.htm>


More information about the CMake mailing list