diff --git a/CMakeLists.txt b/CMakeLists.txt index c7f31e52f..62637e96f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,15 @@ if (MSVC OR APPLE) endif() endif() +#emscripten pthread support +if(EMSCRIPTEN) + set(EMSCRIPTEN_PTHREADS_COMPILER_FLAGS "-pthread -s USE_PTHREADS=1") + set(EMSCRIPTEN_PTHREADS_LINKER_FLAGS "${EMSCRIPTEN_PTHREADS_COMPILER_FLAGS} -s PROXY_TO_PTHREAD") + string(APPEND CMAKE_C_FLAGS " ${EMSCRIPTEN_PTHREADS_COMPILER_FLAGS}") + string(APPEND CMAKE_CXX_FLAGS " ${EMSCRIPTEN_PTHREADS_COMPILER_FLAGS}") + string(APPEND CMAKE_EXE_LINKER_FLAGS " ${EMSCRIPTEN_PTHREADS_LINKER_FLAGS}") +endif() + # Deterministic math # https://box2d.org/posts/2024/08/determinism/ if (MINGW OR APPLE OR UNIX)