mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-26 23:01:04 +08:00
Problem: value for _WIN32_WINNT not always known in CMakeLists.txt
Solution: calculate from CMAKE_SYSTEM_VERSION Problem: CMAKE_SYSTEM_VERSION might be newer than Windows SDK Version Solution: limit _WIN32_WINNT value to Visual Studio default Windows SDK version
This commit is contained in:
parent
d7e1cf3eb0
commit
bfb092c3ec
@ -264,9 +264,51 @@ if(NOT CYGWIN)
|
|||||||
check_include_files(windows.h ZMQ_HAVE_WINDOWS)
|
check_include_files(windows.h ZMQ_HAVE_WINDOWS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
# from https://stackoverflow.com/a/40217291/2019765
|
||||||
|
macro(get_WIN32_WINNT version)
|
||||||
|
if (CMAKE_SYSTEM_VERSION)
|
||||||
|
set(ver ${CMAKE_SYSTEM_VERSION})
|
||||||
|
string(REGEX MATCH "^([0-9]+).([0-9])" ver ${ver})
|
||||||
|
string(REGEX MATCH "^([0-9]+)" verMajor ${ver})
|
||||||
|
# Check for Windows 10, b/c we'll need to convert to hex 'A'.
|
||||||
|
if ("${verMajor}" MATCHES "10")
|
||||||
|
set(verMajor "A")
|
||||||
|
string(REGEX REPLACE "^([0-9]+)" ${verMajor} ver ${ver})
|
||||||
|
endif ("${verMajor}" MATCHES "10")
|
||||||
|
# Remove all remaining '.' characters.
|
||||||
|
string(REPLACE "." "" ver ${ver})
|
||||||
|
# Prepend each digit with a zero.
|
||||||
|
string(REGEX REPLACE "([0-9A-Z])" "0\\1" ver ${ver})
|
||||||
|
set(${version} "0x${ver}")
|
||||||
|
endif(CMAKE_SYSTEM_VERSION)
|
||||||
|
endmacro(get_WIN32_WINNT)
|
||||||
|
|
||||||
|
get_WIN32_WINNT(ZMQ_WIN32_WINNT_DEFAULT)
|
||||||
|
message(STATUS "Detected _WIN32_WINNT from CMAKE_SYSTEM_VERSION: ${ZMQ_WIN32_WINNT_DEFAULT}")
|
||||||
|
|
||||||
|
# TODO limit _WIN32_WINNT to the actual Windows SDK version, which might be different from the default version installed with Visual Studio
|
||||||
|
if(MSVC_VERSION STREQUAL "1500" AND CMAKE_SYSTEM_VERSION VERSION_GREATER "6.0")
|
||||||
|
set(ZMQ_WIN32_WINNT_LIMIT "0x0600")
|
||||||
|
elseif(MSVC_VERSION STREQUAL "1600" AND CMAKE_SYSTEM_VERSION VERSION_GREATER "6.1")
|
||||||
|
set(ZMQ_WIN32_WINNT_LIMIT "0x0601")
|
||||||
|
elseif(MSVC_VERSION STREQUAL "1700" AND CMAKE_SYSTEM_VERSION VERSION_GREATER "6.1")
|
||||||
|
set(ZMQ_WIN32_WINNT_LIMIT "0x0601")
|
||||||
|
elseif(MSVC_VERSION STREQUAL "1800" AND CMAKE_SYSTEM_VERSION VERSION_GREATER "6.2")
|
||||||
|
set(ZMQ_WIN32_WINNT_LIMIT "0x0602")
|
||||||
|
endif()
|
||||||
|
if(ZMQ_WIN32_WINNT_LIMIT)
|
||||||
|
message(STATUS "Mismatch of Visual Studio Version (${MSVC_VERSION}) and CMAKE_SYSTEM_VERSION (${CMAKE_SYSTEM_VERSION}), limiting _WIN32_WINNT to ${ZMQ_WIN32_WINNT_LIMIT}, you may override this by setting ZMQ_WIN32_WINNT")
|
||||||
|
set(ZMQ_WIN32_WINNT_DEFAULT "${ZMQ_WIN32_WINNT_LIMIT}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(ZMQ_WIN32_WINNT "${ZMQ_WIN32_WINNT_DEFAULT}" CACHE STRING "Value to set _WIN32_WINNT to for building [default=autodetect from build environment]")
|
||||||
|
|
||||||
|
add_definitions(-D_WIN32_WINNT=${ZMQ_WIN32_WINNT})
|
||||||
|
endif(WIN32)
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND CMAKE_SYSTEM_VERSION STREQUAL "10.0")
|
if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND CMAKE_SYSTEM_VERSION STREQUAL "10.0")
|
||||||
set(ZMQ_HAVE_WINDOWS_UWP ON)
|
set(ZMQ_HAVE_WINDOWS_UWP ON)
|
||||||
add_definitions(-D_WIN32_WINNT=_WIN32_WINNT_WIN10)
|
|
||||||
endif()
|
endif()
|
||||||
if(NOT MSVC)
|
if(NOT MSVC)
|
||||||
check_include_files(ifaddrs.h ZMQ_HAVE_IFADDRS)
|
check_include_files(ifaddrs.h ZMQ_HAVE_IFADDRS)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user