diff --git a/CMakeLists.txt b/CMakeLists.txt index c0b02333e..27b0afa7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,7 @@ file(TOUCH "${PROJECTM_DUMMY_SOURCE_FILE}") if(CMAKE_SYSTEM_NAME STREQUAL Emscripten) set(ENABLE_EMSCRIPTEN ON CACHE BOOL "Build for web with emscripten. Will also build the SDL2-based entrypoint." FORCE) + option(USE_PTHREADS "Enable multithreading support" OFF) else() set(ENABLE_EMSCRIPTEN OFF CACHE BOOL "Build for web with emscripten. Requires emscripten toolset for building." FORCE) endif() @@ -122,6 +123,11 @@ if(ENABLE_EMSCRIPTEN) "SHELL:-s NO_DISABLE_EXCEPTION_CATCHING" ) + if(USE_PTHREADS) + add_compile_options("SHELL:-s USE_PTHREADS=1") + add_link_options("SHELL:-s USE_PTHREADS=1") + endif() + set(USE_GLES ON) else() if(ENABLE_SDL_UI) @@ -242,6 +248,9 @@ if(ENABLE_SDL_UI) endif() message(STATUS " OpenGL ES: ${ENABLE_GLES}") message(STATUS " Emscripten: ${ENABLE_EMSCRIPTEN}") +if(CMAKE_SYSTEM_NAME STREQUAL Emscripten) + message(STATUS " - PThreads: ${USE_PTHREADS}") +endif() message(STATUS " Use system GLM: ${ENABLE_SYSTEM_GLM}") message(STATUS " Link UI with shared lib: ${ENABLE_SHARED_LINKING}") message(STATUS "")