cmake: warn for invalid CURL_TARGET_WINDOWS_VERSION values

Also:
- INSTALL-CMAKE.md: add an example for `CURL_TARGET_WINDOWS_VERSION`.

Reported-by: nono303 on github
Ref: #20575
Closes #20582
This commit is contained in:
Viktor Szakats 2026-02-12 22:25:52 +01:00
parent fb5541c28b
commit 20ae14a322
No known key found for this signature in database
2 changed files with 7 additions and 3 deletions

View file

@ -201,8 +201,12 @@ if(WIN32)
set(CURL_TARGET_WINDOWS_VERSION "" CACHE STRING "Minimum target Windows version as hex string")
if(CURL_TARGET_WINDOWS_VERSION)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "_WIN32_WINNT=${CURL_TARGET_WINDOWS_VERSION}")
list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_WIN32_WINNT=${CURL_TARGET_WINDOWS_VERSION}") # Apply to all feature checks
if(CURL_TARGET_WINDOWS_VERSION MATCHES "^0x[0-9a-fA-F]+$")
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "_WIN32_WINNT=${CURL_TARGET_WINDOWS_VERSION}")
list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_WIN32_WINNT=${CURL_TARGET_WINDOWS_VERSION}") # Apply to all feature checks
else()
message(WARNING "CURL_TARGET_WINDOWS_VERSION value '${CURL_TARGET_WINDOWS_VERSION}' is not a valid hex string.")
endif()
endif()
# Detect actual value of _WIN32_WINNT and store as HAVE_WIN32_WINNT

View file

@ -249,7 +249,7 @@ target_link_libraries(my_target PRIVATE CURL::libcurl)
- `CURL_LTO`: Enable compiler Link Time Optimizations. Default: `OFF`
- `CURL_PATCHSTAMP`: Set security patch string for `curl -V`/`curl --version` output.
- `CURL_STATIC_CRT`: Build libcurl with static CRT with MSVC (`/MT`) (requires UCRT, static libcurl or no curl executable). Default: `OFF`
- `CURL_TARGET_WINDOWS_VERSION`: Minimum target Windows version as hex string.
- `CURL_TARGET_WINDOWS_VERSION`: Minimum target Windows version as hex string, e.g. `0x0a00` for Windows 10.
- `CURL_WERROR`: Turn compiler warnings into errors. Default: `OFF`
- `ENABLE_CURL_MANUAL`: Build the man page for curl and enable its `-M`/`--manual` option. Default: `ON`
- `ENABLE_DEBUG`: Enable curl debug features (for developing curl itself). Default: `OFF`