Always use check_symbol_exists instead of check_function_exists.

pull/66/merge
Stephen Sorley 8 years ago committed by Gregor Jasny
parent e7fdf4829e
commit 9fe30b55bc
  1. 97
      CMakeLists.txt

@ -192,7 +192,7 @@ ENDIF ()
# When checking for symbols, we need to make sure we set the proper
# headers, libraries, and definitions for the detection to work properly
# CMAKE_REQUIRED_DEFINITIONS, CMAKE_REQUIRED_LIBRARIES, and
# CMAKE_REQUIRED_DEFINITIONS, CMAKE_REQUIRED_LIBRARIES, and
# CMAKE_EXTRA_INCLUDE_FILES. When we're done with the detection, we'll
# unset them.
@ -210,13 +210,18 @@ CARES_EXTRAINCLUDE_IFSET (HAVE_SYS_TYPES_H sys/types.h)
CARES_EXTRAINCLUDE_IFSET (HAVE_ARPA_INET_H arpa/inet.h)
CARES_EXTRAINCLUDE_IFSET (HAVE_ARPA_NAMESER_H arpa/nameser.h)
CARES_EXTRAINCLUDE_IFSET (HAVE_NETDB_H netdb.h)
CARES_EXTRAINCLUDE_IFSET (HAVE_NET_IF_H net/if.h)
CARES_EXTRAINCLUDE_IFSET (HAVE_NETINET_IN_H netinet/in.h)
CARES_EXTRAINCLUDE_IFSET (HAVE_NETINET_TCP_H netinet/tcp.h)
CARES_EXTRAINCLUDE_IFSET (HAVE_SIGNAL_H signal.h)
CARES_EXTRAINCLUDE_IFSET (HAVE_STDLIB_H stdlib.h)
CARES_EXTRAINCLUDE_IFSET (HAVE_STRING_H string.h)
CARES_EXTRAINCLUDE_IFSET (HAVE_STRINGS_H strings.h)
CARES_EXTRAINCLUDE_IFSET (HAVE_SYS_IOCTL_H sys/ioctl.h)
CARES_EXTRAINCLUDE_IFSET (HAVE_SYS_SELECT_H sys/select.h)
CARES_EXTRAINCLUDE_IFSET (HAVE_SYS_SOCKET_H sys/socket.h)
CARES_EXTRAINCLUDE_IFSET (HAVE_SYS_TIME_H sys/time.h)
CARES_EXTRAINCLUDE_IFSET (HAVE_SYS_UIO_H sys/uio.h)
CARES_EXTRAINCLUDE_IFSET (HAVE_TIME_H time.h)
CARES_EXTRAINCLUDE_IFSET (HAVE_FCNTL_H fcntl.h)
CARES_EXTRAINCLUDE_IFSET (HAVE_UNISTD_H unistd.h)
@ -283,59 +288,45 @@ CHECK_STRUCT_HAS_MEMBER("struct sockaddr_in6" sin6_scope_id "${CMAKE_EXTRA_INCLU
CHECK_C_SOURCE_COMPILES ("int main() { int n=1234LL; return 0; }" HAVE_LL)
# NOTE: CHECK_FUNCTION_EXISTS appears to be broken on 32bit Windows with VS2005
# at least. It does not appear to honor CMAKE_REQUIRED_LIBRARIES for some
# reason so does not find functions that are not in the standard C library.
# For this reason, we are going to at least just make sure it is in the
# headers by using CHECK_SYMBOL_EXISTS. But we wrap it in a Macro to allow
# it to work on other systems
MACRO (CARES_FUNCTION_EXISTS func var)
IF (WIN32 AND MSVC)
CHECK_SYMBOL_EXISTS("${func}" "${CMAKE_EXTRA_INCLUDE_FILES}" "${var}")
ELSE ()
CHECK_FUNCTION_EXISTS("${func}" "${var}")
ENDIF ()
ENDMACRO ()
CARES_FUNCTION_EXISTS (bitncmp HAVE_BITNCMP)
CARES_FUNCTION_EXISTS (closesocket HAVE_CLOSESOCKET)
CARES_FUNCTION_EXISTS (CloseSocket HAVE_CLOSESOCKET_CAMEL)
CARES_FUNCTION_EXISTS (connect HAVE_CONNECT)
CARES_FUNCTION_EXISTS (fcntl HAVE_FCNTL)
CARES_FUNCTION_EXISTS (freeaddrinfo HAVE_FREEADDRINFO)
CARES_FUNCTION_EXISTS (getaddrinfo HAVE_GETADDRINFO)
CARES_FUNCTION_EXISTS (getenv HAVE_GETENV)
CARES_FUNCTION_EXISTS (gethostbyaddr HAVE_GETHOSTBYADDR)
CARES_FUNCTION_EXISTS (gethostbyname HAVE_GETHOSTBYNAME)
CARES_FUNCTION_EXISTS (gethostname HAVE_GETHOSTNAME)
CARES_FUNCTION_EXISTS (getnameinfo HAVE_GETNAMEINFO)
CARES_FUNCTION_EXISTS (getservbyport_r HAVE_GETSERVBYPORT_R)
CARES_FUNCTION_EXISTS (gettimeofday HAVE_GETTIMEOFDAY)
CARES_FUNCTION_EXISTS (if_indextoname HAVE_IF_INDEXTONAME)
CARES_FUNCTION_EXISTS (inet_net_pton HAVE_INET_NET_PTON)
CHECK_SYMBOL_EXISTS (bitncmp "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_BITNCMP)
CHECK_SYMBOL_EXISTS (closesocket "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_CLOSESOCKET)
CHECK_SYMBOL_EXISTS (CloseSocket "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_CLOSESOCKET_CAMEL)
CHECK_SYMBOL_EXISTS (connect "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_CONNECT)
CHECK_SYMBOL_EXISTS (fcntl "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_FCNTL)
CHECK_SYMBOL_EXISTS (freeaddrinfo "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_FREEADDRINFO)
CHECK_SYMBOL_EXISTS (getaddrinfo "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_GETADDRINFO)
CHECK_SYMBOL_EXISTS (getenv "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_GETENV)
CHECK_SYMBOL_EXISTS (gethostbyaddr "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_GETHOSTBYADDR)
CHECK_SYMBOL_EXISTS (gethostbyname "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_GETHOSTBYNAME)
CHECK_SYMBOL_EXISTS (gethostname "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_GETHOSTNAME)
CHECK_SYMBOL_EXISTS (getnameinfo "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_GETNAMEINFO)
CHECK_SYMBOL_EXISTS (getservbyport_r "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_GETSERVBYPORT_R)
CHECK_SYMBOL_EXISTS (gettimeofday "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_GETTIMEOFDAY)
CHECK_SYMBOL_EXISTS (if_indextoname "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_IF_INDEXTONAME)
CHECK_SYMBOL_EXISTS (inet_net_pton "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_INET_NET_PTON)
IF (NOT WIN32)
# Disabled on windows. CARES_FUNCTION_EXISTS will say they exist, but
# it doesn't appear as though proper headers really exist for these functions
# as there are prototype warnings during the build.
CARES_FUNCTION_EXISTS (inet_ntop HAVE_INET_NTOP)
CARES_FUNCTION_EXISTS (inet_pton HAVE_INET_PTON)
# Disabled on Windows, because these functions are only really supported on Windows
# Vista or newer (_WIN32_WINNT >= 0x0600). Older versions of Windows may provide
# them as experimental non-working features, so we have to disable them manually.
CHECK_SYMBOL_EXISTS (inet_ntop "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_INET_NTOP)
CHECK_SYMBOL_EXISTS (inet_pton "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_INET_PTON)
ENDIF ()
CARES_FUNCTION_EXISTS (ioctl HAVE_IOCTL)
CARES_FUNCTION_EXISTS (ioctlsocket HAVE_IOCTLSOCKET)
CARES_FUNCTION_EXISTS (IoctlSocket HAVE_IOCTLSOCKET_CAMEL)
CARES_FUNCTION_EXISTS (recv HAVE_RECV)
CARES_FUNCTION_EXISTS (recvfrom HAVE_RECVFROM)
CARES_FUNCTION_EXISTS (send HAVE_SEND)
CARES_FUNCTION_EXISTS (setsockopt HAVE_SETSOCKOPT)
CARES_FUNCTION_EXISTS (socket HAVE_SOCKET)
CARES_FUNCTION_EXISTS (strcasecmp HAVE_STRCASECMP)
CARES_FUNCTION_EXISTS (strcmpi HAVE_STRCMPI)
CARES_FUNCTION_EXISTS (strdup HAVE_STRDUP)
CARES_FUNCTION_EXISTS (stricmp HAVE_STRICMP)
CARES_FUNCTION_EXISTS (strncasecmp HAVE_STRNCASECMP)
CARES_FUNCTION_EXISTS (strncmpi HAVE_STRNCMPI)
CARES_FUNCTION_EXISTS (strnicmp HAVE_STRNICMP)
CARES_FUNCTION_EXISTS (writev HAVE_WRITEV)
CHECK_SYMBOL_EXISTS (ioctl "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_IOCTL)
CHECK_SYMBOL_EXISTS (ioctlsocket "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_IOCTLSOCKET)
CHECK_SYMBOL_EXISTS (IoctlSocket "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_IOCTLSOCKET_CAMEL)
CHECK_SYMBOL_EXISTS (recv "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_RECV)
CHECK_SYMBOL_EXISTS (recvfrom "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_RECVFROM)
CHECK_SYMBOL_EXISTS (send "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_SEND)
CHECK_SYMBOL_EXISTS (setsockopt "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_SETSOCKOPT)
CHECK_SYMBOL_EXISTS (socket "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_SOCKET)
CHECK_SYMBOL_EXISTS (strcasecmp "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_STRCASECMP)
CHECK_SYMBOL_EXISTS (strcmpi "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_STRCMPI)
CHECK_SYMBOL_EXISTS (strdup "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_STRDUP)
CHECK_SYMBOL_EXISTS (stricmp "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_STRICMP)
CHECK_SYMBOL_EXISTS (strncasecmp "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_STRNCASECMP)
CHECK_SYMBOL_EXISTS (strncmpi "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_STRNCMPI)
CHECK_SYMBOL_EXISTS (strnicmp "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_STRNICMP)
CHECK_SYMBOL_EXISTS (writev "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_WRITEV)
# Unset temporary data
SET (CMAKE_EXTRA_INCLUDE_FILES)
@ -496,7 +487,7 @@ CONFIGURE_FILE (ares_config.h.cmake ${PROJECT_BINARY_DIR}/ares_config.h)
# ...
#
# into this:
#
#
# SET (CSOURCES
# ares__close_sockets.c
# ares__get_hostent.c

Loading…
Cancel
Save