Merge pull request #379 from andrassmuk/fix/issue-378-mingw-pthread

fix: use native winpthreads for MinGW/MSYS2 Windows builds
This commit is contained in:
GameTec-live
2026-04-25 08:02:57 +02:00
committed by GitHub
+15 -8
View File
@@ -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()