diff --git a/3rdparty/simlib/include/mata/simlib/util/shared_list.hh b/3rdparty/simlib/include/mata/simlib/util/shared_list.hh index 420f28a5..9cb78b7d 100644 --- a/3rdparty/simlib/include/mata/simlib/util/shared_list.hh +++ b/3rdparty/simlib/include/mata/simlib/util/shared_list.hh @@ -108,7 +108,7 @@ public: } if (elem) - --elem->counter_; + --elem->refcount_; } template diff --git a/CMakeLists.txt b/CMakeLists.txt index 97063f71..991c1ef5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,11 @@ set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) option(MATA_WERROR "Warnings should be handled as errors" OFF) option(MATA_ENABLE_COVERAGE "Build with coverage compiler flags" OFF) +# For the case of WASM build we need to add -pthread option +if (EMSCRIPTEN) + add_compile_options(-pthread) +endif() + # Only do these if this is the main project, and not if it is included through add_subdirectory if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) # Store compile commands into 'build/compile_commands.json', which are needed, beside others, for linters. diff --git a/README-WASM.md b/README-WASM.md new file mode 100644 index 00000000..c6affeb0 --- /dev/null +++ b/README-WASM.md @@ -0,0 +1,9 @@ +## Building Mata to WASM + +In order to build Mata library to WASM, you need to have `emscripten` set up, along with all of its dependencies. +You can use the system packages or consult [emsdk](https://github.com/emscripten-core/emsdk). +For building Mata to WASM then use the following steps: + +1. create folder `build-wasm` for the WASM build of libmata.a +2. in `build-wasm` run `emcmake cmake -DBUILD_TYPE=Release -DMATA_BUILD_EXAMPLES:BOOL=OFF -DBUILD_TESTING:BOOL=OFF ..` +3. build the library using `emmake make` (the WASM static library `src/libmata.a` should be created after that) \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7cad7754..698a7239 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -34,6 +34,11 @@ set_target_properties(libmata PROPERTIES target_include_directories(libmata PUBLIC "${PROJECT_SOURCE_DIR}/include/") +# For the case of WASM build we need to link with pthread +if (EMSCRIPTEN) + target_link_libraries(libmata PRIVATE pthread) +endif() + target_link_libraries(libmata PUBLIC cudd simlib) target_link_libraries(libmata PRIVATE re2)