summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt17
1 files changed, 17 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7917be50..8567e374 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -89,6 +89,7 @@ option(enable_single_obj_compilation "Compile all libgc source files into single
option(disable_single_obj_compilation "Compile each libgc source file independently" OFF)
option(enable_handle_fork "Attempt to ensure a usable collector after fork()" ON)
option(disable_handle_fork "Prohibit installation of pthread_atfork() handlers" OFF)
+option(enable_emscripten_asyncify "Use Emscripten asyncify feature" OFF)
option(install_headers "Install header and pkg-config metadata files" ON)
option(with_libatomic_ops "Use an external libatomic_ops" OFF)
option(without_libatomic_ops "Use atomic_ops.h in libatomic_ops/src" OFF)
@@ -546,6 +547,22 @@ if (HAVE_DLADDR)
add_definitions("-DHAVE_DLADDR")
endif()
+# Check for emscripten; use asyncify feature if requested.
+check_c_source_compiles("
+#ifndef __EMSCRIPTEN__\n
+# error This is not Emscripten\n
+#endif\n
+int main(void) { return 0; }"
+ EMSCRIPTEN)
+if (EMSCRIPTEN AND enable_emscripten_asyncify)
+ # Use this option if your program is targeting -sASYNCIFY. The latter is
+ # required to scan the stack, ASYNCIFY_STACK_SIZE is probably needed for
+ # gctest only.
+ add_definitions("-DEMSCRIPTEN_ASYNCIFY")
+ set(CMAKE_EXE_LINKER_FLAGS
+ "${CMAKE_EXE_LINKER_FLAGS} -sASYNCIFY -sASYNCIFY_STACK_SIZE=128000")
+endif()
+
add_library(gc ${SRC})
target_link_libraries(gc
PRIVATE ${ATOMIC_OPS_LIBS_CMAKE} ${THREADDLLIBS_LIST})