cmake: fix pthread linking on Windows

This commit is contained in:
David Hrdlička 2021-09-15 12:49:52 +02:00
parent 206c34ed27
commit 719d155393
6 changed files with 28 additions and 3 deletions

View file

@ -57,6 +57,7 @@ jobs:
${{ matrix.environment.prefix }}-zlib ${{ matrix.environment.prefix }}-zlib
${{ matrix.environment.prefix }}-libpng ${{ matrix.environment.prefix }}-libpng
${{ matrix.environment.prefix }}-libvncserver ${{ matrix.environment.prefix }}-libvncserver
${{ matrix.environment.prefix }}-winpthreads
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: make - name: make
run: make -fwin/makefile.mingw -j DEV_BUILD=${{ matrix.dev-build }} NEW_DYNAREC=${{ matrix.new-dynarec }} X64=${{ matrix.environment.x64 }} CLANG=${{ matrix.clang }} VNC=n run: make -fwin/makefile.mingw -j DEV_BUILD=${{ matrix.dev-build }} NEW_DYNAREC=${{ matrix.new-dynarec }} X64=${{ matrix.environment.x64 }} CLANG=${{ matrix.clang }} VNC=n

View file

@ -62,13 +62,16 @@ jobs:
msystem: ${{ matrix.environment.msystem }} msystem: ${{ matrix.environment.msystem }}
install: >- install: >-
${{ matrix.environment.prefix }}-ninja ${{ matrix.environment.prefix }}-ninja
${{ matrix.environment.prefix }}-toolchain ${{ matrix.environment.prefix }}-gcc
${{ matrix.environment.prefix }}-clang
${{ matrix.environment.prefix }}-pkg-config
${{ matrix.environment.prefix }}-openal ${{ matrix.environment.prefix }}-openal
${{ matrix.environment.prefix }}-freetype ${{ matrix.environment.prefix }}-freetype
${{ matrix.environment.prefix }}-SDL2 ${{ matrix.environment.prefix }}-SDL2
${{ matrix.environment.prefix }}-zlib ${{ matrix.environment.prefix }}-zlib
${{ matrix.environment.prefix }}-libpng ${{ matrix.environment.prefix }}-libpng
${{ matrix.environment.prefix }}-libvncserver ${{ matrix.environment.prefix }}-libvncserver
${{ matrix.environment.prefix }}-winpthreads
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Configure CMake - name: Configure CMake
run: >- run: >-

View file

@ -88,6 +88,10 @@ CMAKE_DEPENDENT_OPTION(VNC "VNC renderer" ON "DEV_BRANCH" OFF)
CMAKE_DEPENDENT_OPTION(XL24 "ATI VGA Wonder XL24 (ATI-28800-6)" ON "DEV_BRANCH" OFF) CMAKE_DEPENDENT_OPTION(XL24 "ATI VGA Wonder XL24 (ATI-28800-6)" ON "DEV_BRANCH" OFF)
CMAKE_DEPENDENT_OPTION(VECT486VL "HP Vectra 486VL" ON "DEV_BRANCH" OFF) CMAKE_DEPENDENT_OPTION(VECT486VL "HP Vectra 486VL" ON "DEV_BRANCH" OFF)
if(WIN32)
option(PTHREAD "Use POSIX threads (pthreads) instead of Win32 threads" ON)
endif()
# HACK: Avoid a MSVC2019 compiler bug on ARM64 Debug builds # HACK: Avoid a MSVC2019 compiler bug on ARM64 Debug builds
if(MSVC_TOOLSET_VERSION GREATER_EQUAL 142 AND ARCH STREQUAL "arm64") if(MSVC_TOOLSET_VERSION GREATER_EQUAL 142 AND ARCH STREQUAL "arm64")
# Define a cache option in case somebody wants to disable this workaround # Define a cache option in case somebody wants to disable this workaround

View file

@ -16,7 +16,7 @@
# WIN32 marks us as a GUI app on Windows # WIN32 marks us as a GUI app on Windows
add_executable(86Box WIN32 86box.c config.c random.c timer.c io.c acpi.c apm.c add_executable(86Box WIN32 86box.c config.c random.c timer.c io.c acpi.c apm.c
dma.c ddma.c nmi.c pic.c pit.c port_92.c ppi.c pci.c mca.c usb.c dma.c ddma.c nmi.c pic.c pit.c port_92.c ppi.c pci.c mca.c usb.c
device.c nvr.c nvr_at.c nvr_ps2.c thread.c) device.c nvr.c nvr_at.c nvr_ps2.c)
if(NEW_DYNAREC) if(NEW_DYNAREC)
add_compile_definitions(USE_NEW_DYNAREC) add_compile_definitions(USE_NEW_DYNAREC)
@ -44,6 +44,18 @@ if(VNC)
target_link_libraries(86Box vnc vncserver ws2_32) target_link_libraries(86Box vnc vncserver ws2_32)
endif() endif()
if(NOT WIN32 OR PTHREAD)
target_sources(86Box PRIVATE thread.c)
if(WIN32 AND VCPKG_TOOLCHAIN)
find_package(pthreads REQUIRED)
target_link_libraries(86Box pthreads)
else()
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
target_link_libraries(86Box Threads::Threads)
endif()
endif()
target_link_libraries(86Box cpu chipset mch dev mem fdd game cdrom zip mo hdd target_link_libraries(86Box cpu chipset mch dev mem fdd game cdrom zip mo hdd
net print scsi sio snd vid voodoo plat ui) net print scsi sio snd vid voodoo plat ui)

View file

@ -58,5 +58,9 @@ if(OPENGL)
target_sources(ui PRIVATE glad.c win_opengl.c win_opengl_glslp.c) target_sources(ui PRIVATE glad.c win_opengl.c win_opengl_glslp.c)
endif() endif()
if(NOT PTHREAD)
target_sources(plat PRIVATE win_thread.c)
endif()
target_link_libraries(86Box advapi32 comctl32 comdlg32 gdi32 shell32 iphlpapi target_link_libraries(86Box advapi32 comctl32 comdlg32 gdi32 shell32 iphlpapi
dxguid imm32 hid setupapi uxtheme version winmm psapi) dxguid imm32 hid setupapi uxtheme version winmm psapi)

View file

@ -8,6 +8,7 @@
"freetype", "freetype",
"libpng", "libpng",
"openal-soft", "openal-soft",
"sdl2" "sdl2",
"pthreads"
] ]
} }