Skip to content

Commit

Permalink
build,cmake: fix compilation on old MinGW
Browse files Browse the repository at this point in the history
_WIN32_WINNT specifies the minimum version of the operating system
supported by the code, so change it to the minimum version supported by
libuv.
If _WIN32_WINNT=0x0600, PSAPI_VERSION=1 is set and it is necessary to link
psapi, so it adds psapi unconditionally to the linked library.

Fixes: libuv#2742
Refs: https://docs.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?view=vs-2019
PR-URL: libuv#2748
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
  • Loading branch information
erw7 committed Apr 27, 2020
1 parent 002fe6e commit 6b3df05
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,9 @@ set(uv_sources
src/version.c)

if(WIN32)
if (CMAKE_SYSTEM_VERSION VERSION_GREATER 10) # Windows 10
set(windows-version 0x0A00)
elseif (CMAKE_SYSTEM_VERSION VERSION_GREATER 6.3) # Windows 8.1
set(windows-version 0x0603)
elseif (CMAKE_SYSTEM_VERSION VERSION_GREATER 6.2) # Windows 8
set(windows-version 0x0602)
elseif (CMAKE_SYSTEM_VERSION VERSION_GREATER 6.1) # Windows 7
set(windows-version 0x0601)
elseif (CMAKE_SYSTEM_VERSION VERSION_GREATER 6.0) # Windows Vista
set(windows-version 0x0600)
else()
message(FATAL_ERROR "Windows Vista is the minimum version supported")
endif()
list(APPEND uv_defines WIN32_LEAN_AND_MEAN _WIN32_WINNT=${windows-version})
list(APPEND uv_defines WIN32_LEAN_AND_MEAN _WIN32_WINNT=0x0600)
list(APPEND uv_libraries
$<$<STREQUAL:${windows-version},0x0600>:psapi>
psapi
iphlpapi
userenv
ws2_32)
Expand Down

0 comments on commit 6b3df05

Please sign in to comment.