endif()
endif()
- list(APPEND CMAKE_REQUIRED_DEFINITIONS "-DWIN32_LEAN_AND_MEAN") # Apply to all feature checks
+ # Apply to all feature checks
+ list(APPEND CMAKE_REQUIRED_DEFINITIONS "-DWIN32_LEAN_AND_MEAN")
+ if(MSVC)
+ list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_CRT_NONSTDC_NO_DEPRECATE") # for strdup() detection
+ endif()
set(CURL_TARGET_WINDOWS_VERSION "" CACHE STRING "Minimum target Windows version as hex string")
if(CURL_TARGET_WINDOWS_VERSION)
set(CURL_DISABLE_TELNET ON) # telnet code needs fixing to compile for UWP.
endif()
-option(ENABLE_IPV6 "Enable IPv6 support" ON)
-mark_as_advanced(ENABLE_IPV6)
-if(ENABLE_IPV6 AND NOT WIN32)
- 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)
- if(NOT DOS AND NOT AMIGA)
- message(WARNING "struct sockaddr_in6 not available, disabling IPv6 support")
- endif()
- # Force the feature off as this name is used as guard macro...
- set(ENABLE_IPV6 OFF CACHE BOOL "Enable IPv6 support" FORCE)
- endif()
-
- if(APPLE AND NOT ENABLE_ARES)
- set(_use_core_foundation_and_core_services ON)
-
- find_library(SYSTEMCONFIGURATION_FRAMEWORK NAMES "SystemConfiguration")
- mark_as_advanced(SYSTEMCONFIGURATION_FRAMEWORK)
- if(NOT SYSTEMCONFIGURATION_FRAMEWORK)
- message(FATAL_ERROR "SystemConfiguration framework not found")
- endif()
- list(APPEND CURL_LIBS "-framework SystemConfiguration")
- endif()
-endif()
-if(ENABLE_IPV6)
- set(USE_IPV6 ON)
-endif()
-
find_package(Perl)
if(PERL_EXECUTABLE)
include(CheckTypeSize)
include(CheckCSourceCompiles)
-if(WIN32)
- # Preload settings on Windows
- include("${CMAKE_CURRENT_SOURCE_DIR}/CMake/win32-cache.cmake")
-elseif(APPLE)
- # Fast-track predictable feature detections
- set(HAVE_EVENTFD 0)
- set(HAVE_GETPASS_R 0)
- set(HAVE_SENDMMSG 0)
-elseif(AMIGA)
+option(_CURL_QUICK_DETECT "Fast-track known feature detection results (Windows, some Apple)" ON)
+if(_CURL_QUICK_DETECT)
+ if(WIN32)
+ include("${CMAKE_CURRENT_SOURCE_DIR}/CMake/win32-cache.cmake")
+ elseif(APPLE)
+ set(HAVE_EVENTFD 0)
+ set(HAVE_GETPASS_R 0)
+ set(HAVE_SENDMMSG 0)
+ endif()
+endif()
+
+if(AMIGA)
set(HAVE_GETADDRINFO 0) # Breaks the build when detected and used.
endif()
if(DOS OR AMIGA)
endif()
endif()
+option(ENABLE_IPV6 "Enable IPv6 support" ON)
+mark_as_advanced(ENABLE_IPV6)
+if(ENABLE_IPV6)
+ include(CheckStructHasMember)
+ if(WIN32)
+ check_struct_has_member("struct sockaddr_in6" "sin6_scope_id" "winsock2.h;ws2tcpip.h" HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID)
+ else()
+ 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)
+ if(NOT DOS AND NOT AMIGA)
+ message(WARNING "struct sockaddr_in6 not available, disabling IPv6 support")
+ endif()
+ set(ENABLE_IPV6 OFF CACHE BOOL "Enable IPv6 support" FORCE) # Force the feature off as we use this name as guard macro
+ endif()
+
+ if(APPLE AND NOT ENABLE_ARES)
+ set(_use_core_foundation_and_core_services ON)
+
+ find_library(SYSTEMCONFIGURATION_FRAMEWORK NAMES "SystemConfiguration")
+ mark_as_advanced(SYSTEMCONFIGURATION_FRAMEWORK)
+ if(NOT SYSTEMCONFIGURATION_FRAMEWORK)
+ message(FATAL_ERROR "SystemConfiguration framework not found")
+ endif()
+ list(APPEND CURL_LIBS "-framework SystemConfiguration")
+ endif()
+ endif()
+endif()
+if(ENABLE_IPV6)
+ set(USE_IPV6 ON)
+endif()
+
# Check SSL libraries
option(CURL_ENABLE_SSL "Enable SSL support" ON)
check_symbol_exists("ftruncate" "unistd.h" HAVE_FTRUNCATE)
check_symbol_exists("getpeername" "${CURL_INCLUDES}" HAVE_GETPEERNAME) # winsock2.h unistd.h proto/bsdsocket.h
check_symbol_exists("getsockname" "${CURL_INCLUDES}" HAVE_GETSOCKNAME) # winsock2.h unistd.h proto/bsdsocket.h
-check_function_exists("if_nametoindex" HAVE_IF_NAMETOINDEX) # winsock2.h net/if.h
check_function_exists("getrlimit" HAVE_GETRLIMIT)
check_function_exists("setlocale" HAVE_SETLOCALE)
check_function_exists("setmode" HAVE_SETMODE)
check_function_exists("setrlimit" HAVE_SETRLIMIT)
if(NOT WIN32)
- check_function_exists("realpath" HAVE_REALPATH)
- check_function_exists("sched_yield" HAVE_SCHED_YIELD)
+ check_function_exists("if_nametoindex" HAVE_IF_NAMETOINDEX) # iphlpapi.h (Windows non-UWP), net/if.h
+ check_function_exists("realpath" HAVE_REALPATH)
+ check_function_exists("sched_yield" HAVE_SCHED_YIELD)
check_symbol_exists("strcasecmp" "string.h" HAVE_STRCASECMP)
check_symbol_exists("stricmp" "string.h" HAVE_STRICMP)
check_symbol_exists("strcmpi" "string.h" HAVE_STRCMPI)
check_symbol_exists("arc4random" "${CURL_INCLUDES};stdlib.h" HAVE_ARC4RANDOM)
endif()
-if(NOT MSVC OR (MSVC_VERSION GREATER_EQUAL 1900))
- # Earlier MSVC compilers had faulty snprintf implementations
- check_function_exists("snprintf" HAVE_SNPRINTF)
+if(NOT MSVC)
+ check_function_exists("snprintf" HAVE_SNPRINTF) # to match detection method in ./configure
+elseif(MSVC_VERSION GREATER_EQUAL 1900) # Earlier MSVC compilers had faulty snprintf implementations
+ check_symbol_exists("snprintf" "stdio.h" HAVE_SNPRINTF) # snprintf may be a compatibility macro, not an exported function
endif()
if(APPLE)
check_function_exists("mach_absolute_time" HAVE_MACH_ABSOLUTE_TIME)