Skip to content

Commit 2eb0a41

Browse files
committed
Add pthreads option for emscripten
1 parent b658ccc commit 2eb0a41

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

CMakeLists.txt

+9
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ file(TOUCH "${PROJECTM_DUMMY_SOURCE_FILE}")
6060

6161
if(CMAKE_SYSTEM_NAME STREQUAL Emscripten)
6262
set(ENABLE_EMSCRIPTEN ON CACHE BOOL "Build for web with emscripten. Will also build the SDL2-based entrypoint." FORCE)
63+
option(USE_PTHREADS "Enable multithreading support" OFF)
6364
else()
6465
set(ENABLE_EMSCRIPTEN OFF CACHE BOOL "Build for web with emscripten. Requires emscripten toolset for building." FORCE)
6566
endif()
@@ -122,6 +123,11 @@ if(ENABLE_EMSCRIPTEN)
122123
"SHELL:-s NO_DISABLE_EXCEPTION_CATCHING"
123124
)
124125

126+
if(USE_PTHREADS)
127+
add_compile_options("SHELL:-s USE_PTHREADS=1")
128+
add_link_options("SHELL:-s USE_PTHREADS=1")
129+
endif()
130+
125131
set(USE_GLES ON)
126132
else()
127133
if(ENABLE_SDL_UI)
@@ -242,6 +248,9 @@ if(ENABLE_SDL_UI)
242248
endif()
243249
message(STATUS " OpenGL ES: ${ENABLE_GLES}")
244250
message(STATUS " Emscripten: ${ENABLE_EMSCRIPTEN}")
251+
if(CMAKE_SYSTEM_NAME STREQUAL Emscripten)
252+
message(STATUS " - PThreads: ${USE_PTHREADS}")
253+
endif()
245254
message(STATUS " Use system GLM: ${ENABLE_SYSTEM_GLM}")
246255
message(STATUS " Link UI with shared lib: ${ENABLE_SHARED_LINKING}")
247256
message(STATUS "")

0 commit comments

Comments
 (0)