diff --git a/circuits/cpp/cmake/threading.cmake b/circuits/cpp/cmake/threading.cmake index 1f32c83745d..ff60f240a16 100644 --- a/circuits/cpp/cmake/threading.cmake +++ b/circuits/cpp/cmake/threading.cmake @@ -1,10 +1,26 @@ if(MULTITHREADING) - find_package(OpenMP REQUIRED) message(STATUS "Multithreading is enabled.") - link_libraries(OpenMP::OpenMP_CXX) + add_compile_options(-pthread) + add_link_options(-pthread) + if(WASM) + add_compile_options(--target=wasm32-wasi-threads) + add_link_options(--target=wasm32-wasi-threads) + endif() + #add_compile_options(-fsanitize=thread) + #add_link_options(-fsanitize=thread) else() message(STATUS "Multithreading is disabled.") - add_definitions(-DNO_MULTITHREADING -DBOOST_SP_NO_ATOMIC_ACCESS) + add_definitions(-DNO_MULTITHREADING) + set(OMP_MULTITHREADING OFF) +endif() + +if(OMP_MULTITHREADING) + find_package(OpenMP REQUIRED) + message(STATUS "OMP multithreading is enabled.") + link_libraries(OpenMP::OpenMP_CXX) +else() + message(STATUS "OMP multithreading is disabled.") + add_definitions(-DNO_OMP_MULTITHREADING) endif() if(DISABLE_TBB)