#
###########################################################################
include(CheckCSourceCompiles)
+include(CheckCSourceRuns)
+
# The begin of the sources (macros and includes)
set(_source_epilogue "#undef inline")
# only try this on non-apple platforms
# if not cross-compilation...
- include(CheckCSourceRuns)
set(CMAKE_REQUIRED_FLAGS "")
if(HAVE_SYS_POLL_H)
set(CMAKE_REQUIRED_FLAGS "-DHAVE_SYS_POLL_H")
}" HAVE_POLL_FINE)
endif()
endif()
+
+# Detect HAVE_GETADDRINFO_THREADSAFE
+
+if(WIN32)
+ set(HAVE_GETADDRINFO_THREADSAFE ${HAVE_GETADDRINFO})
+elseif(NOT HAVE_GETADDRINFO)
+ set(HAVE_GETADDRINFO_THREADSAFE FALSE)
+elseif(CMAKE_SYSTEM_NAME STREQUAL "AIX" OR
+ CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR
+ CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR
+ CMAKE_SYSTEM_NAME STREQUAL "HP-UX" OR
+ CMAKE_SYSTEM_NAME STREQUAL "MidnightBSD" OR
+ CMAKE_SYSTEM_NAME STREQUAL "NetBSD" OR
+ CMAKE_SYSTEM_NAME STREQUAL "SunOS")
+ set(HAVE_GETADDRINFO_THREADSAFE TRUE)
+elseif(CMAKE_SYSTEM_NAME MATCHES "BSD")
+ set(HAVE_GETADDRINFO_THREADSAFE FALSE)
+endif()
+
+if(NOT DEFINED HAVE_GETADDRINFO_THREADSAFE)
+
+ set(_save_epilogue "${_source_epilogue}")
+ set(_source_epilogue "#undef inline")
+
+ add_header_include(HAVE_SYS_SOCKET_H "sys/socket.h")
+ add_header_include(HAVE_SYS_TIME_H "sys/time.h")
+ add_header_include(HAVE_NETDB_H "netdb.h")
+
+ check_c_source_compiles("${_source_epilogue}
+ int main(void)
+ {
+ #ifdef h_errno
+ return 0;
+ #else
+ force compilation error
+ #endif
+ }" HAVE_H_ERRNO)
+
+ if(NOT HAVE_H_ERRNO)
+ check_c_source_runs("${_source_epilogue}
+ int main(void)
+ {
+ h_errno = 2;
+ return h_errno != 0 ? 1 : 0;
+ }" HAVE_H_ERRNO_ASSIGNABLE)
+
+ if(NOT HAVE_H_ERRNO_ASSIGNABLE)
+ check_c_source_compiles("${_source_epilogue}
+ int main(void)
+ {
+ #if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200809L)
+ return 0;
+ #elif defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 700)
+ return 0;
+ #else
+ force compilation error
+ #endif
+ }" HAVE_H_ERRNO_SBS_ISSUE_7)
+ endif()
+ endif()
+
+ if(HAVE_H_ERRNO OR HAVE_H_ERRNO_ASSIGNABLE OR HAVE_H_ERRNO_SBS_ISSUE_7)
+ set(HAVE_GETADDRINFO_THREADSAFE TRUE)
+ endif()
+
+ set(_source_epilogue "${_save_epilogue}")
+endif()
check_symbol_exists(siginterrupt "${CURL_INCLUDES}" HAVE_SIGINTERRUPT)
check_symbol_exists(getaddrinfo "${CURL_INCLUDES};stdlib.h;string.h" HAVE_GETADDRINFO)
check_symbol_exists(getifaddrs "${CURL_INCLUDES};stdlib.h" HAVE_GETIFADDRS)
-if(WIN32)
- set(HAVE_GETADDRINFO_THREADSAFE ${HAVE_GETADDRINFO})
-endif()
check_symbol_exists(freeaddrinfo "${CURL_INCLUDES}" HAVE_FREEADDRINFO)
check_symbol_exists(pipe "${CURL_INCLUDES}" HAVE_PIPE)
check_symbol_exists(ftruncate "${CURL_INCLUDES}" HAVE_FTRUNCATE)