Build sherpa-onnx as a single shared library (#1078)
When `-D BUILD_SHARED_LIBS=ON` is passed to `cmake`, it builds a single shared library. Specifically, - For C APIs, it builds `libsherpa-onnx-c-api.so` - For Python APIs, it builds `_sherpa_onnx.cpython-xx-xx.so` - For Kotlin and Java APIs, it builds `libsherpa-onnx-jni.so` There is no `libsherpa-onnx-core.so` any longer. Note it affects only shared libraries.
This commit is contained in:
@@ -67,7 +67,24 @@ function(download_openfst)
|
||||
FetchContent_Populate(openfst)
|
||||
endif()
|
||||
message(STATUS "openfst is downloaded to ${openfst_SOURCE_DIR}")
|
||||
|
||||
if(_build_shared_libs_bak)
|
||||
set(_build_shared_libs_bak ${BUILD_SHARED_LIBS})
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
endif()
|
||||
|
||||
add_subdirectory(${openfst_SOURCE_DIR} ${openfst_BINARY_DIR} EXCLUDE_FROM_ALL)
|
||||
|
||||
if(_build_shared_libs_bak)
|
||||
set_target_properties(fst fstfar
|
||||
PROPERTIES
|
||||
POSITION_INDEPENDENT_CODE ON
|
||||
C_VISIBILITY_PRESET hidden
|
||||
CXX_VISIBILITY_PRESET hidden
|
||||
)
|
||||
set(BUILD_SHARED_LIBS ON)
|
||||
endif()
|
||||
|
||||
set(openfst_SOURCE_DIR ${openfst_SOURCE_DIR} PARENT_SCOPE)
|
||||
|
||||
set_target_properties(fst PROPERTIES OUTPUT_NAME "sherpa-onnx-fst")
|
||||
|
||||
Reference in New Issue
Block a user