mirror of
https://github.com/curl/curl.git
synced 2026-04-14 22:41:40 +03:00
windows: reduce/stop loading DLLs at runtime
- replace dynamic `InitSecurityInterface()` call with early binding and link `secur32` system DLL. The library and function are available in all supported curl Windows targets, meaning WinXP or newer. Add small hack for mingw32ce to make it build. - detect and use `if_nametoindex()` on Windows when available. Link `iphlpapi` system DLL. Requires targeting Vista or newer. Replacing the dynamic call and the pre-load optimization for lib3026. Suggested-by: Jay Satiro Closes #17413
This commit is contained in:
parent
c129d0b1a8
commit
0d71b18153
16 changed files with 186 additions and 182 deletions
|
|
@ -605,10 +605,12 @@ if(WIN32)
|
|||
set(_win32_winsock "ws2_32")
|
||||
endif()
|
||||
set(_win32_crypt32 "crypt32")
|
||||
set(_win32_secur32 "secur32")
|
||||
|
||||
if(MINGW32CE) # FIXME upstream: must specify the full path to avoid CMake converting "ws2" to "ws2.lib"
|
||||
set(_win32_winsock "${MINGW32CE_LIBRARY_DIR}/lib${_win32_winsock}.a")
|
||||
set(_win32_crypt32 "${MINGW32CE_LIBRARY_DIR}/lib${_win32_crypt32}.a")
|
||||
set(_win32_secur32 "${MINGW32CE_LIBRARY_DIR}/lib${_win32_secur32}.a")
|
||||
endif()
|
||||
elseif(DOS)
|
||||
if(WATT_ROOT)
|
||||
|
|
@ -1651,6 +1653,16 @@ if(WIN32)
|
|||
# Windows XP is required for freeaddrinfo, getaddrinfo
|
||||
message(FATAL_ERROR "Building for Windows XP or newer is required.")
|
||||
endif()
|
||||
|
||||
# Pre-fill detection results based on target OS version
|
||||
if(HAVE_WIN32_WINNT AND HAVE_WIN32_WINNT GREATER_EQUAL 0x0600 AND # Windows Vista or newer
|
||||
(MINGW OR MSVC) AND
|
||||
NOT WINCE AND NOT WINDOWS_STORE)
|
||||
set(HAVE_IF_NAMETOINDEX 1)
|
||||
else()
|
||||
set(HAVE_IF_NAMETOINDEX 0)
|
||||
endif()
|
||||
unset(HAVE_IF_NAMETOINDEX CACHE)
|
||||
endif()
|
||||
|
||||
# Detect headers
|
||||
|
|
@ -1749,6 +1761,9 @@ endif()
|
|||
# Apply to all feature checks
|
||||
if(WIN32)
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES "${_win32_winsock}")
|
||||
if(NOT WINCE AND NOT WINDOWS_STORE)
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES "iphlpapi")
|
||||
endif()
|
||||
elseif(HAVE_LIBSOCKET)
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES "socket")
|
||||
elseif(DOS)
|
||||
|
|
@ -1800,12 +1815,12 @@ check_function_exists("eventfd" HAVE_EVENTFD)
|
|||
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) # iphlpapi.h (Windows Vista+ non-UWP), net/if.h
|
||||
check_function_exists("getrlimit" HAVE_GETRLIMIT)
|
||||
check_function_exists("setlocale" HAVE_SETLOCALE)
|
||||
check_function_exists("setrlimit" HAVE_SETRLIMIT)
|
||||
|
||||
if(NOT WIN32)
|
||||
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)
|
||||
|
|
@ -1984,6 +1999,9 @@ set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "HAVE_CONFIG_H")
|
|||
|
||||
if(WIN32)
|
||||
list(APPEND CURL_LIBS "${_win32_winsock}")
|
||||
if(NOT WINCE AND NOT WINDOWS_STORE)
|
||||
list(APPEND CURL_LIBS "iphlpapi")
|
||||
endif()
|
||||
if(NOT WINCE)
|
||||
list(APPEND CURL_LIBS "bcrypt")
|
||||
endif()
|
||||
|
|
@ -2004,6 +2022,9 @@ if(WIN32)
|
|||
endif()
|
||||
list(APPEND CURL_LIBS "${_win32_crypt32}")
|
||||
endif()
|
||||
if(CURL_WINDOWS_SSPI)
|
||||
list(APPEND CURL_LIBS "${_win32_secur32}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC") # MSVC but exclude clang-cl
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue