diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d5e06ea8f..3897dcc074 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/docs/INSTALL-CMAKE.md b/docs/INSTALL-CMAKE.md index b6d51da508..eed6218350 100644 --- a/docs/INSTALL-CMAKE.md +++ b/docs/INSTALL-CMAKE.md @@ -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`