2022-10-22 12:07:59 +02:00
|
|
|
set(TARGET libwhisper)
|
|
|
|
|
|
|
|
add_executable(${TARGET}
|
|
|
|
emscripten.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(${TARGET} PRIVATE
|
|
|
|
whisper
|
|
|
|
)
|
|
|
|
|
|
|
|
unset(EXTRA_FLAGS)
|
2022-11-21 21:20:42 +01:00
|
|
|
|
2022-10-22 12:07:59 +02:00
|
|
|
if (WHISPER_WASM_SINGLE_FILE)
|
|
|
|
set(EXTRA_FLAGS "-s SINGLE_FILE=1")
|
|
|
|
message(STATUS "Embedding WASM inside whisper.js")
|
|
|
|
|
|
|
|
add_custom_command(
|
2022-11-21 21:20:42 +01:00
|
|
|
TARGET ${TARGET} POST_BUILD
|
2022-10-22 12:07:59 +02:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy
|
|
|
|
${CMAKE_BINARY_DIR}/bin/libwhisper.js
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/whisper.js
|
|
|
|
)
|
2022-12-12 19:17:27 +01:00
|
|
|
|
|
|
|
add_custom_command(
|
|
|
|
TARGET ${TARGET} POST_BUILD
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy
|
|
|
|
${CMAKE_BINARY_DIR}/bin/libwhisper.worker.js
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/libwhisper.worker.js
|
|
|
|
)
|
2022-10-22 12:07:59 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
set_target_properties(${TARGET} PROPERTIES LINK_FLAGS " \
|
|
|
|
--bind \
|
2022-12-12 19:17:27 +01:00
|
|
|
-s MODULARIZE=1 \
|
|
|
|
-s EXPORT_NAME=\"'whisper_factory'\" \
|
|
|
|
-s FORCE_FILESYSTEM=1 \
|
2022-10-22 12:07:59 +02:00
|
|
|
-s USE_PTHREADS=1 \
|
2022-10-22 15:57:54 +02:00
|
|
|
-s PTHREAD_POOL_SIZE=8 \
|
2022-12-12 19:17:27 +01:00
|
|
|
-s ALLOW_MEMORY_GROWTH=1 \
|
2022-10-22 12:07:59 +02:00
|
|
|
${EXTRA_FLAGS} \
|
|
|
|
")
|