mirror of
https://github.com/browsermt/bergamot-translator.git
synced 2024-09-17 16:47:18 +03:00
Improved cmake to use wasm compilation flags across project
This commit is contained in:
parent
ff95e37f89
commit
28dcf55b41
6
3rd_party/CMakeLists.txt
vendored
6
3rd_party/CMakeLists.txt
vendored
@ -1,4 +1,10 @@
|
||||
add_subdirectory(marian-dev)
|
||||
|
||||
if(COMPILE_WASM)
|
||||
# This is a bad way of adding compilation flags. Will be improved soon.
|
||||
add_compile_options(${WASM_COMPILE_FLAGS})
|
||||
endif(COMPILE_WASM)
|
||||
|
||||
add_subdirectory(ssplit-cpp)
|
||||
|
||||
# Add include directories for 3rd party targets to be able to use it anywhere in the
|
||||
|
@ -33,9 +33,9 @@ if(NOT COMPILE_WASM)
|
||||
endif()
|
||||
|
||||
if(COMPILE_WASM)
|
||||
add_compile_options(-pthread -O3 -g2 -fPIC -mssse3 -msimd128)
|
||||
add_compile_options("SHELL:-s WASM=1" "SHELL:-s ASSERTIONS=1" "SHELL:-s DISABLE_EXCEPTION_CATCHING=0" "SHELL:-s LLD_REPORT_UNDEFINED" "SHELL:-s FORCE_FILESYSTEM=1" "SHELL:-s ALLOW_MEMORY_GROWTH=1")
|
||||
add_compile_options(-Wno-error=pthreads-mem-growth)
|
||||
list(APPEND WASM_COMPILE_FLAGS -pthread -O3 -g2 -fPIC -mssse3 -msimd128)
|
||||
list(APPEND WASM_COMPILE_FLAGS "SHELL:-s WASM=1" "SHELL:-s ASSERTIONS=1" "SHELL:-s DISABLE_EXCEPTION_CATCHING=0" "SHELL:-s LLD_REPORT_UNDEFINED" "SHELL:-s FORCE_FILESYSTEM=1" "SHELL:-s ALLOW_MEMORY_GROWTH=1")
|
||||
list(APPEND WASM_COMPILE_FLAGS -Wno-error=pthreads-mem-growth)
|
||||
endif(COMPILE_WASM)
|
||||
|
||||
add_subdirectory(3rd_party)
|
||||
|
@ -21,6 +21,7 @@ if(COMPILE_WASM)
|
||||
target_compile_definitions(bergamot-translator PUBLIC USE_SSE2 WASM)
|
||||
# Enable code that is required for generating JS bindings
|
||||
target_compile_definitions(bergamot-translator PRIVATE WASM_BINDINGS)
|
||||
target_compile_options(bergamot-translator PRIVATE ${WASM_COMPILE_FLAGS})
|
||||
endif(COMPILE_WASM)
|
||||
|
||||
if (COMPILE_THREAD_VARIANT)
|
||||
|
@ -12,6 +12,7 @@ target_include_directories(bergamot-translator-worker
|
||||
)
|
||||
# This compile definition is required for generating binding code properly
|
||||
target_compile_definitions(bergamot-translator-worker PRIVATE WASM_BINDINGS)
|
||||
target_compile_options(bergamot-translator-worker PRIVATE ${WASM_COMPILE_FLAGS})
|
||||
|
||||
set(LINKER_FLAGS "--bind -s ASSERTIONS=1 -s DISABLE_EXCEPTION_CATCHING=0 -s FORCE_FILESYSTEM=1 -s ALLOW_MEMORY_GROWTH=1")
|
||||
if (NOT PACKAGE_DIR STREQUAL "")
|
||||
@ -22,6 +23,5 @@ set_target_properties(bergamot-translator-worker PROPERTIES
|
||||
SUFFIX ".js"
|
||||
LINK_FLAGS ${LINKER_FLAGS}
|
||||
)
|
||||
#target_link_options(bergamot-translator-worker --preload-file ${PACKAGE_DIR}@/)
|
||||
|
||||
target_link_libraries(bergamot-translator-worker bergamot-translator)
|
||||
|
Loading…
Reference in New Issue
Block a user