From aec7c5a87c8482b6ddffa352d7d220698652262e Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Mon, 13 Oct 2014 11:19:36 +0200 Subject: cmake: enable IPv6 by default if available ENABLE_IPV6 depends on HAVE_GETADDRINFO or you will get a Curl_getaddrinfo_ex error. Enable IPv6 by default, disabling it if struct sockaddr_in6 is not found in netinet/in.h. Note that HAVE_GETADDRINFO_THREADSAFE is still not set as it needs more platform checks even though POSIX requires a thread-safe getaddrinfo. Verified on Arch Linux x86_64 with glibc 2.20-2 and Linux 3.16-rc7. Signed-off-by: Peter Wu --- CMakeLists.txt | 16 +++++++++++++++- docs/INSTALL.cmake | 1 - 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 13bd39e7b..7ac69fcbc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -171,8 +171,21 @@ option(CURL_DISABLE_VERBOSE_STRINGS "to disable verbose strings" OFF) mark_as_advanced(CURL_DISABLE_VERBOSE_STRINGS) option(DISABLED_THREADSAFE "Set to explicitly specify we don't want to use thread-safe functions" OFF) mark_as_advanced(DISABLED_THREADSAFE) -option(ENABLE_IPV6 "Define if you want to enable IPv6 support" OFF) +option(ENABLE_IPV6 "Define if you want to enable IPv6 support" ON) mark_as_advanced(ENABLE_IPV6) +if(ENABLE_IPV6) + include(CheckStructHasMember) + check_struct_has_member("struct sockaddr_in6" sin6_addr "netinet/in.h" + HAVE_SOCKADDR_IN6_SIN6_ADDR) + check_struct_has_member("struct sockaddr_in6" sin6_scope_id "netinet/in.h" + HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID) + if(NOT HAVE_SOCKADDR_IN6_SIN6_ADDR) + message(WARNING "struct sockaddr_in6 not available, disabling IPv6 support") + # Force the feature off as this name is used as guard macro... + set(ENABLE_IPV6 OFF + CACHE BOOL "Define if you want to enable IPv6 support" FORCE) + endif() +endif() option(ENABLE_MANUAL "to provide the built-in manual" ON) unset(USE_MANUAL CACHE) # TODO: cache NROFF/NROFF_MANOPT/USE_MANUAL vars? @@ -731,6 +744,7 @@ check_symbol_exists(strerror_r "${CURL_INCLUDES}" HAVE_STRERROR_R) check_symbol_exists(siginterrupt "${CURL_INCLUDES}" HAVE_SIGINTERRUPT) check_symbol_exists(perror "${CURL_INCLUDES}" HAVE_PERROR) check_symbol_exists(fork "${CURL_INCLUDES}" HAVE_FORK) +check_symbol_exists(getaddrinfo "${CURL_INCLUDES}" HAVE_GETADDRINFO) check_symbol_exists(freeaddrinfo "${CURL_INCLUDES}" HAVE_FREEADDRINFO) check_symbol_exists(freeifaddrs "${CURL_INCLUDES}" HAVE_FREEIFADDRS) check_symbol_exists(pipe "${CURL_INCLUDES}" HAVE_PIPE) diff --git a/docs/INSTALL.cmake b/docs/INSTALL.cmake index dd8c93674..b2924e642 100644 --- a/docs/INSTALL.cmake +++ b/docs/INSTALL.cmake @@ -31,7 +31,6 @@ Current flaws in the curl CMake build - Doesn't allow build curl and libcurl debug enabled - Doesn't allow a custom CA bundle path - Doesn't allow you to disable specific protocols from the build - - Doesn't properly enable IPv6 support by default - Doesn't find or use krb4 or GSS - Rebuilds test files too eagerly, but still can't run the tests -- cgit v1.2.3