From 598a28df9104f11ec148b93579b7c98d8d423488 Mon Sep 17 00:00:00 2001 From: Will Usher Date: Wed, 21 Aug 2024 08:59:03 -0700 Subject: [PATCH] windows --- src/CMakeLists.txt | 10 ++++------ src/main.cpp | 3 ++- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fbe3497..5fc85e3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,10 +7,8 @@ set_target_properties(wgpu_app PROPERTIES CXX_STANDARD 20 CXX_STANDARD_REQUIRED target_link_libraries(wgpu_app PRIVATE glm embedded_files sdl2webgpu tbb) -target_compile_options(wgpu_app PRIVATE -pthread) - if(EMSCRIPTEN) - target_compile_options(wgpu_app PRIVATE --use-port=sdl2) + target_compile_options(wgpu_app PRIVATE --use-port=sdl2 -pthread) target_link_options( wgpu_app @@ -30,8 +28,7 @@ if(EMSCRIPTEN) $<$:-gseparate-dwarf=${CMAKE_CURRENT_BINARY_DIR}/wgpu_app.dwarf> $<$:-g> $<$:-O2> - # Debug build flags - #$<$:-fwasm-exceptions> + # Debug build flags $<$:-fwasm-exceptions> $<$:-g> $<$:-O0> # Exported Emscripten runtime methods @@ -78,8 +75,9 @@ if(EMSCRIPTEN) DEPENDS ${WEB_OUT_DIR}/wgpu_app.js ${WEB_OUT_DIR}/wgpu_app.wasm COMMENT "Copying wasm build to ${WEB_OUT_DIR}") else() + find_package(Threads REQUIRED) if(WIN32) target_compile_definitions(wgpu_app PUBLIC SDL_MAIN_HANDLED) endif() - target_link_libraries(wgpu_app PUBLIC SDL2::SDL2 webgpu) + target_link_libraries(wgpu_app PUBLIC SDL2::SDL2 webgpu Threads::Threads) endif() diff --git a/src/main.cpp b/src/main.cpp index b9cf172..6f14dbe 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include "arcball_camera.h" #include "sdl2webgpu.h" #include @@ -516,7 +515,9 @@ extern "C" EXPORT_FN void dispatch_callback(void (*cb)(int), int arg) extern "C" EXPORT_FN void callback_on_thread(void (*cb)(int)) { +#ifdef EMSCRIPTEN pthread_t main_thread = pthread_self(); +#endif std::cout << "hi on main before thread, x = " << x << "\n"; std::thread test2([=]() {