diff --git a/CMakeLists.txt b/CMakeLists.txt index 199627d0c8..11a84d2934 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,8 +17,7 @@ option(ENABLE_SENTRY "Send crash data via Sentry" OFF) option(ENABLE_MORE_COMPILER_OPTIMIZATION_FLAGS "Enable more optimization flags" ON) option(USE_SYSTEM_LIBS "Use the system libraries if available" OFF) option(OLDER_APPLE_CLANG "Apple Clang <= 13 used" OFF) - -option(OLDER_APPLE_CLANG "Apple Clang <= 13 used" OFF) +option(ENABLE_THREADING "Enable threading support" ON) if (${ENABLE_ARCUS} OR ${ENABLE_PLUGINS}) find_package(protobuf REQUIRED) @@ -157,7 +156,9 @@ set(engine_SRCS # Except main.cpp. ) add_library(_CuraEngine STATIC ${engine_SRCS} ${engine_PB_SRCS}) -#use_threads(_CuraEngine) +if (ENABLE_THREADING) + use_threads(_CuraEngine) +endif () target_include_directories(_CuraEngine PUBLIC @@ -252,7 +253,15 @@ else () endif () endif (NOT WIN32) -#use_threads(CuraEngine) +if (ENABLE_THREADING) + use_threads(CuraEngine) +endif () + +if (CMAKE_CXX_PLATFORM_ID STREQUAL "emscripten") + message(STATUS "Building for Emscripten") + target_link_options(_CuraEngine PUBLIC -Wno-unused-command-line-argument -sINVOKE_RUN=0 -sEXPORT_NAME=CuraEngine -sEXPORTED_RUNTIME_METHODS=[callMain,FS] -sFORCE_FILESYSTEM=1 -sALLOW_MEMORY_GROWTH=1 -sEXPORT_ES6=1 -sMODULARIZE=1 -sSINGLE_FILE=1 -sENVIRONMENT=worker) +endif () + target_link_libraries(CuraEngine PRIVATE _CuraEngine $<$:sentry::sentry> diff --git a/conanfile.py b/conanfile.py index 5bb90c64c8..1f1735fa91 100644 --- a/conanfile.py +++ b/conanfile.py @@ -137,6 +137,7 @@ def generate(self): tc.variables["ENABLE_BENCHMARKS"] = self.options.enable_benchmarks tc.variables["EXTENSIVE_WARNINGS"] = self.options.enable_extensive_warnings tc.variables["OLDER_APPLE_CLANG"] = self.settings.compiler == "apple-clang" and Version(self.settings.compiler.version) < "14" + tc.variables["ENABLE_THREADING"] = not (self.settings.arch == "wasm" and self.settings.os == "Emscripten") if self.options.get_safe("enable_sentry", False): tc.variables["ENABLE_SENTRY"] = True tc.variables["SENTRY_URL"] = self.conf.get("user.curaengine:sentry_url", "", check_type=str) @@ -147,9 +148,6 @@ def generate(self): tc.variables["ENABLE_PLUGINS"] = self.options.enable_plugins tc.generate() - if self.settings.arch == "wasm" and self.settings.os == "Emscripten": - self.buildenv.define("EMCC_CFLAGS", "-s FORCE_FILESYSTEM -s ALLOW_MEMORY_GROWTH=1 -s EXPORT_ES6=1 -s EXPORT_NAME='CuraEngine' -s EXPORTED_RUNTIME_METHODS='[\"callMain\", \"FS\"]' -s INVOKE_RUN=0 -s MODULARIZE=1 -s SINGLE_FILE=1 -s ENVIRONMENT=worker -s USE_ES6_IMPORT_META=0") - for dep in self.dependencies.values(): if len(dep.cpp_info.libdirs) > 0: copy(self, "*.dylib", dep.cpp_info.libdirs[0], self.build_folder)