Skip to content

Commit

Permalink
windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Twinklebear committed Aug 21, 2024
1 parent d79ca3b commit 598a28d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
10 changes: 4 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,8 +28,7 @@ if(EMSCRIPTEN)
$<$<CONFIG:RELWITHDEBINFO>:-gseparate-dwarf=${CMAKE_CURRENT_BINARY_DIR}/wgpu_app.dwarf>
$<$<CONFIG:RELWITHDEBINFO>:-g>
$<$<CONFIG:RELWITHDEBINFO>:-O2>
# Debug build flags
#$<$<CONFIG:DEBUG>:-fwasm-exceptions>
# Debug build flags $<$<CONFIG:DEBUG>:-fwasm-exceptions>
$<$<CONFIG:DEBUG>:-g>
$<$<CONFIG:DEBUG>:-O0>
# Exported Emscripten runtime methods
Expand Down Expand Up @@ -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()
3 changes: 2 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <stdexcept>
#include <thread>
#include <SDL.h>
#include <pthread.h>
#include "arcball_camera.h"
#include "sdl2webgpu.h"
#include <glm/ext.hpp>
Expand Down Expand Up @@ -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([=]() {
Expand Down

0 comments on commit 598a28d

Please sign in to comment.