From 195f25cfbd4a13d16bd14c657c993a979215402a Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 2 Apr 2015 09:11:21 +0200 Subject: cmake: Detect network function correctly on Windows Signed-off-by: Andreas Schneider --- ConfigureChecks.cmake | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'ConfigureChecks.cmake') diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index c4bf6c28..e3a39dd9 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -103,11 +103,6 @@ check_function_exists(isblank HAVE_ISBLANK) check_function_exists(strncpy HAVE_STRNCPY) check_function_exists(vsnprintf HAVE_VSNPRINTF) check_function_exists(snprintf HAVE_SNPRINTF) -check_function_exists(poll HAVE_POLL) -check_function_exists(select HAVE_SELECT) -check_function_exists(getaddrinfo HAVE_GETADDRINFO) -check_symbol_exists(ntohll arpa/inet.h HAVE_NTOHLL) -check_symbol_exists(htonll arpa/inet.h HAVE_HTONLL) if (WIN32) check_function_exists(_strtoui64 HAVE__STRTOUI64) @@ -118,17 +113,28 @@ if (WIN32) check_function_exists(_snprintf_s HAVE__SNPRINTF_S) if (HAVE_WSPIAPI_H OR HAVE_WS2TCPIP_H) - set(HAVE_GETADDRINFO TRUE) - set(HAVE_GETHOSTBYNAME TRUE) - if (MSVC) - set(HAVE_NTOHLL TRUE) - set(HAVE_HTONLL TRUE) - endif (MSVC) + check_symbol_exists(ntohll winsock2.h HAVE_NTOHLL) + check_symbol_exists(htonll winsock2.h HAVE_HTONLL) + + set(CMAKE_REQUIRED_LIBRARIES ws2_32) + check_symbol_exists(select "winsock2.h;ws2tcpip.h" HAVE_SELECT) + check_symbol_exists(poll "winsock2.h;ws2tcpip.h" HAVE_SELECT) + # The getaddrinfo function is defined to the WspiapiGetAddrInfo inline function + check_symbol_exists(getaddrinfo "winsock2.h;ws2tcpip.h" HAVE_GETADDRINFO) + set(CMAKE_REQUIRED_LIBRARIES) endif (HAVE_WSPIAPI_H OR HAVE_WS2TCPIP_H) set(HAVE_SELECT TRUE) +else (WIN32) + check_function_exists(poll HAVE_POLL) + check_function_exists(select HAVE_SELECT) + check_function_exists(getaddrinfo HAVE_GETADDRINFO) + + check_symbol_exists(ntohll arpa/inet.h HAVE_NTOHLL) + check_symbol_exists(htonll arpa/inet.h HAVE_HTONLL) endif (WIN32) + if (UNIX) if (NOT LINUX) # libsocket (Solaris) -- cgit v1.2.3