diff --git a/CMakeLists.txt b/CMakeLists.txt index 645ea60d..2c349167 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,8 +53,12 @@ endif() if(EMSCRIPTEN) option(MUJOCO_BUILD_TESTS_WASM "Build tests for WASM bindings" ON) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20 -O3 -pthread -fexceptions") + option(MUJOCO_WASM_THREADS "Build with multi-threading support" ON) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20 -O3 -fexceptions") + if(MUJOCO_WASM_THREADS) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") + endif() endif() if(APPLE AND (MUJOCO_BUILD_EXAMPLES OR MUJOCO_BUILD_SIMULATE)) diff --git a/wasm/CMakeLists.txt b/wasm/CMakeLists.txt index 08004839..80ed4feb 100644 --- a/wasm/CMakeLists.txt +++ b/wasm/CMakeLists.txt @@ -31,8 +31,6 @@ if(NOT MUJOCO_WASM_FILES) message(FATAL_ERROR "No source files found in codegen/generated/") endif() -option(MUJOCO_WASM_THREADS "Build with multi-threading support" ON) - # Set Emscripten linker flags set(EMCC_LINKER_FLAGS "--bind"