From 8e28d1a40e2171003760634912d445e0a54c2860 Mon Sep 17 00:00:00 2001 From: andrassmuk <64307696+andrassmuk@users.noreply.github.com> Date: Thu, 19 Mar 2026 15:06:33 +0100 Subject: [PATCH] fix: use native winpthreads for MinGW/MSYS2 builds on Windows The pthreads4w dependency uses MSVC-specific architecture detection (_M_X64, _M_IX86 macros) which fails under MinGW/MSYS2/ProxSpace with "unknown not supported in version.rc". MinGW-w64 ships with winpthreads, so only MSVC builds need pthreads4w. Fixes #378 --- software/src/CMakeLists.txt | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/software/src/CMakeLists.txt b/software/src/CMakeLists.txt index d137251..293162e 100644 --- a/software/src/CMakeLists.txt +++ b/software/src/CMakeLists.txt @@ -97,14 +97,21 @@ elseif (CMAKE_SYSTEM_NAME MATCHES "Windows") endif() endif() - FetchContent_Declare( - pthreads4w - GIT_REPOSITORY "https://github.com/GerHobbelt/pthread-win32" - OVERRIDE_FIND_PACKAGE - EXCLUDE_FROM_ALL - ) - find_package(pthreads4w CONFIG REQUIRED) - set(LIBTHREAD pthreads4w::pthreadVC3) + if(MSVC) + # MSVC has no native POSIX threads; use pthreads4w + FetchContent_Declare( + pthreads4w + GIT_REPOSITORY "https://github.com/GerHobbelt/pthread-win32" + OVERRIDE_FIND_PACKAGE + EXCLUDE_FROM_ALL + ) + find_package(pthreads4w CONFIG REQUIRED) + set(LIBTHREAD pthreads4w::pthreadVC3) + else() + # MinGW/MSYS2 ships with winpthreads; use native threads + find_package(Threads REQUIRED) + set(LIBTHREAD Threads::Threads) + endif() set(LIBMATH "") # No separate math library needed on Windows else()