@@ -54,7 +54,12 @@ include(CMakeDependentOption)
5454
5555set (_ORTX_STANDALONE_PROJECT OFF )
5656if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR )
57- set (_ORTX_STANDALONE_PROJECT ON )
57+ set (_ORTX_STANDALONE_PROJECT ON )
58+ endif ()
59+
60+ set (_ORTX_SHARED_BUILD_SUPPORTED ON )
61+ if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten" )
62+ set (_ORTX_SHARED_BUILD_SUPPORTED OFF )
5863endif ()
5964
6065option (CC_OPTIMIZE "Allow compiler optimizations, Set to OFF to disable" ON )
@@ -78,11 +83,11 @@ option(OCOS_ENABLE_VISION "Enable the operators in `operators/vision`" ON)
7883option (OCOS_ENABLE_AUDIO "Enable the operators for audio processing" ON )
7984option (OCOS_ENABLE_AZURE "Enable the operators for azure execution provider" OFF )
8085
81- option (OCOS_ENABLE_STATIC_LIB "Enable generating static library" OFF )
86+ option (OCOS_ENABLE_STATIC_LIB "Enable generating static library" OFF ) # only for WebAssembly
8287option (OCOS_ENABLE_SELECTED_OPLIST "Enable including the selected_ops tool file" OFF )
8388option (OCOS_ENABLE_C_API "Enable building the C API" OFF )
8489
85- option (OCOS_BUILD_SHARED_LIB "Enable building the dynamic library" ON )
90+ option (OCOS_BUILD_SHARED_LIB "Enable building the dynamic library" ${_ORTX_SHARED_BUILD_SUPPORTED} )
8691option (OCOS_BUILD_PYTHON "Enable building the Python package" OFF )
8792option (OCOS_BUILD_JAVA "Enable building the Java package" OFF )
8893option (OCOS_BUILD_ANDROID "Enable building the Android package" OFF )
@@ -773,30 +778,7 @@ if(OCOS_ENABLE_C_API)
773778endif ()
774779
775780if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten" )
776- if (OCOS_ENABLE_STATIC_LIB)
777- message (FATAL_ERROR "Emscripten build does not support building a static library." )
778- endif ()
779- # Emscripten does not support building a shared library with custom ops.
780- # and backward compatible with the previous version, we silently turn off the shared library build.
781- set (OCOS_BUILD_SHARED_LIB OFF CACHE INTERNAL "" FORCE)
782- add_executable (ortcustomops ${_TARGET_LIB_SRC} )
783- set_target_properties (ortcustomops PROPERTIES LINK_FLAGS " \
784- -s WASM=1 \
785- -s NO_EXIT_RUNTIME=0 \
786- -s ALLOW_MEMORY_GROWTH=1 \
787- -s SAFE_HEAP=0 \
788- -s MODULARIZE=1 \
789- -s SAFE_HEAP_LOG=0 \
790- -s STACK_OVERFLOW_CHECK=0 \
791- -s EXPORT_ALL=0 \
792- -s VERBOSE=0 \
793- --no-entry" )
794-
795- if (CMAKE_BUILD_TYPE STREQUAL "Debug" )
796- set_property (TARGET ortcustomops APPEND_STRING PROPERTY LINK_FLAGS " -s ASSERTIONS=1 -s DEMANGLE_SUPPORT=1" )
797- else ()
798- set_property (TARGET ortcustomops APPEND_STRING PROPERTY LINK_FLAGS " -s ASSERTIONS=0 -s DEMANGLE_SUPPORT=0" )
799- endif ()
781+ include (ext_wasm)
800782else ()
801783 add_library (ortcustomops STATIC ${_TARGET_LIB_SRC} )
802784 if (HAS_SDL)
0 commit comments