mirror of
https://github.com/curl/curl.git
synced 2026-04-11 12:01:42 +08:00
cmake: do not force Windows target versions
The goal of this patch is to avoid CMake forcing specific Windows versions and rely on toolchain defaults or manual selection instead. This gives back control to the user. This also brings CMake closer to how autotools and `Makefile.m32` behaves in this regard. - CMake had a setting `ENABLE_INET_PTON` defaulting to `ON`, which did nothing else than fixing the Windows build target to Vista. This also happened when the toolchain did not have Vista support (e.g. original MinGW), breaking such builds. In other environments it did not make a user-facing difference, because libcurl has its own pton() implementation, so it works well with or without Vista's inet_pton(). This patch drops this setting. inet_pton() is now used whenever building for Vista or newer, either when requested manually or by default with modern toolchains (e.g. mingw-w64). Older envs will fall back to curl's pton(). Ref: https://github.com/curl/curl/pull/9027#issuecomment-1164157604 Ref: https://github.com/curl/curl/pull/8997#issuecomment-1164344155 - When the user did no select a Windows target version manually, stop explicitly targeting Windows XP, and instead use the toolchain default. This may pose an issue with old toolchains defaulting to pre-XP targets. In such case you must manually target Windows XP via: `-DCURL_TARGET_WINDOWS_VERSION=0x0501` or `-DCMAKE_C_FLAGS=-D_WIN32_WINNT=0x0501` Reviewed-by: Jay Satiro Reviewed-by: Marcel Raad Closes #9046
This commit is contained in:
parent
76172511e7
commit
8ba22ffb20
@ -78,20 +78,11 @@ option(BUILD_SHARED_LIBS "Build shared libraries" ON)
|
||||
option(ENABLE_ARES "Set to ON to enable c-ares support" OFF)
|
||||
if(WIN32)
|
||||
option(CURL_STATIC_CRT "Set to ON to build libcurl with static CRT on Windows (/MT)." OFF)
|
||||
option(ENABLE_INET_PTON "Set to OFF to prevent usage of inet_pton when building against modern SDKs while still requiring compatibility with older Windows versions, such as Windows XP, Windows Server 2003 etc." ON)
|
||||
option(ENABLE_UNICODE "Set to ON to use the Unicode version of the Windows API functions" OFF)
|
||||
set(CURL_TARGET_WINDOWS_VERSION "" CACHE STRING "Minimum target Windows version as hex string")
|
||||
if(CURL_TARGET_WINDOWS_VERSION)
|
||||
add_definitions(-D_WIN32_WINNT=${CURL_TARGET_WINDOWS_VERSION})
|
||||
set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_WIN32_WINNT=${CURL_TARGET_WINDOWS_VERSION}")
|
||||
elseif(ENABLE_INET_PTON)
|
||||
# _WIN32_WINNT_VISTA (0x0600)
|
||||
add_definitions(-D_WIN32_WINNT=0x0600)
|
||||
set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_WIN32_WINNT=0x0600")
|
||||
else()
|
||||
# _WIN32_WINNT_WINXP (0x0501)
|
||||
add_definitions(-D_WIN32_WINNT=0x0501)
|
||||
set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_WIN32_WINNT=0x0501")
|
||||
endif()
|
||||
if(ENABLE_UNICODE)
|
||||
add_definitions(-DUNICODE -D_UNICODE)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user