From 7e6b21a856b6858cccc2c2f43047b62e92ee8733 Mon Sep 17 00:00:00 2001 From: Adam Aposhian Date: Mon, 26 Feb 2024 08:21:32 -0700 Subject: [PATCH] fix mingw build Signed-off-by: Adam Aposhian --- CMakeLists.txt | 9 +++++++++ src/CMakeLists.txt | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1148e8ed..0e49a967 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,15 @@ SET(PAHO_ENABLE_CPACK TRUE CACHE BOOL "Enable CPack") SET(PAHO_HIGH_PERFORMANCE FALSE CACHE BOOL "Disable tracing and heap tracking") SET(PAHO_USE_SELECT FALSE CACHE BOOL "Revert to select system call instead of poll") +IF (MINGW) + ADD_DEFINITIONS(-D_WINDOWS) + # Require at least Windows Vista (0x0600) for poll support + ## https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?view=msvc-170#remarks + IF (NOT PAHO_SELECT_USE_SELECT) + ADD_DEFINITIONS(-DWINVER=0x0600 -D_WIN32_WINNT=0x0600) + ENDIF() +ENDIF() + IF (PAHO_HIGH_PERFORMANCE) ADD_DEFINITIONS(-DHIGH_PERFORMANCE=1) ENDIF() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0f795b9a..1e8eca86 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -58,7 +58,8 @@ IF (NOT PAHO_HIGH_PERFORMANCE) ENDIF() IF (WIN32) - SET(LIBS_SYSTEM ws2_32 crypt32 RpcRT4) + # use all lowercase names for mingw compatibility + SET(LIBS_SYSTEM ws2_32 crypt32 rpcrt4) ELSEIF (UNIX) IF(CMAKE_SYSTEM_NAME MATCHES "Linux") SET(LIBS_SYSTEM c dl pthread rt)