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:
@@ -1,9 +1,9 @@
|
||||
function(download_espeak_ng_for_piper)
|
||||
include(FetchContent)
|
||||
|
||||
set(espeak_ng_URL "https://github.com/csukuangfj/espeak-ng/archive/69bf6927964fb042aeb827cfdf6082a30f5802eb.zip")
|
||||
set(espeak_ng_URL2 "https://hub.nuaa.cf/csukuangfj/espeak-ng/archive/69bf6927964fb042aeb827cfdf6082a30f5802eb.zip")
|
||||
set(espeak_ng_HASH "SHA256=745e35b21ece6804b4a1839722f9e625ac909380c8f85873ad71bf145877075a")
|
||||
set(espeak_ng_URL "https://github.com/csukuangfj/espeak-ng/archive/f6fed6c58b5e0998b8e68c6610125e2d07d595a7.zip")
|
||||
set(espeak_ng_URL2 "https://hub.nuaa.cf/csukuangfj/espeak-ng/archive/f6fed6c58b5e0998b8e68c6610125e2d07d595a7.zip")
|
||||
set(espeak_ng_HASH "SHA256=70cbf4050e7a014aae19140b05e57249da4720f56128459fbe3a93beaf971ae6")
|
||||
|
||||
set(BUILD_ESPEAK_NG_TESTS OFF CACHE BOOL "" FORCE)
|
||||
set(USE_ASYNC OFF CACHE BOOL "" FORCE)
|
||||
@@ -21,11 +21,11 @@ function(download_espeak_ng_for_piper)
|
||||
# If you don't have access to the Internet,
|
||||
# please pre-download kaldi-decoder
|
||||
set(possible_file_locations
|
||||
$ENV{HOME}/Downloads/espeak-ng-69bf6927964fb042aeb827cfdf6082a30f5802eb.zip
|
||||
${CMAKE_SOURCE_DIR}/espeak-ng-69bf6927964fb042aeb827cfdf6082a30f5802eb.zip
|
||||
${CMAKE_BINARY_DIR}/espeak-ng-69bf6927964fb042aeb827cfdf6082a30f5802eb.zip
|
||||
/tmp/espeak-ng-69bf6927964fb042aeb827cfdf6082a30f5802eb.zip
|
||||
/star-fj/fangjun/download/github/espeak-ng-69bf6927964fb042aeb827cfdf6082a30f5802eb.zip
|
||||
$ENV{HOME}/Downloads/espeak-ng-f6fed6c58b5e0998b8e68c6610125e2d07d595a7.zip
|
||||
${CMAKE_SOURCE_DIR}/espeak-ng-f6fed6c58b5e0998b8e68c6610125e2d07d595a7.zip
|
||||
${CMAKE_BINARY_DIR}/espeak-ng-f6fed6c58b5e0998b8e68c6610125e2d07d595a7.zip
|
||||
/tmp/espeak-ng-f6fed6c58b5e0998b8e68c6610125e2d07d595a7.zip
|
||||
/star-fj/fangjun/download/github/espeak-ng-f6fed6c58b5e0998b8e68c6610125e2d07d595a7.zip
|
||||
)
|
||||
|
||||
foreach(f IN LISTS possible_file_locations)
|
||||
@@ -53,7 +53,23 @@ function(download_espeak_ng_for_piper)
|
||||
message(STATUS "espeak-ng is downloaded to ${espeak_ng_SOURCE_DIR}")
|
||||
message(STATUS "espeak-ng binary dir is ${espeak_ng_BINARY_DIR}")
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
set(_build_shared_libs_bak ${BUILD_SHARED_LIBS})
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
endif()
|
||||
|
||||
add_subdirectory(${espeak_ng_SOURCE_DIR} ${espeak_ng_BINARY_DIR})
|
||||
|
||||
if(_build_shared_libs_bak)
|
||||
set_target_properties(espeak-ng
|
||||
PROPERTIES
|
||||
POSITION_INDEPENDENT_CODE ON
|
||||
C_VISIBILITY_PRESET hidden
|
||||
CXX_VISIBILITY_PRESET hidden
|
||||
)
|
||||
set(BUILD_SHARED_LIBS ON)
|
||||
endif()
|
||||
|
||||
set(espeak_ng_SOURCE_DIR ${espeak_ng_SOURCE_DIR} PARENT_SCOPE)
|
||||
|
||||
if(WIN32 AND MSVC)
|
||||
@@ -107,28 +123,12 @@ function(download_espeak_ng_for_piper)
|
||||
${espeak_ng_SOURCE_DIR}/src/ucd-tools/src/include
|
||||
)
|
||||
|
||||
if(SHERPA_ONNX_ENABLE_PYTHON AND WIN32)
|
||||
install(TARGETS
|
||||
espeak-ng
|
||||
ucd
|
||||
DESTINATION ..)
|
||||
else()
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
install(TARGETS
|
||||
espeak-ng
|
||||
ucd
|
||||
DESTINATION lib)
|
||||
endif()
|
||||
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
install(TARGETS ucd DESTINATION lib)
|
||||
endif()
|
||||
|
||||
if(WIN32 AND BUILD_SHARED_LIBS)
|
||||
install(TARGETS
|
||||
espeak-ng
|
||||
ucd
|
||||
DESTINATION bin)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
download_espeak_ng_for_piper()
|
||||
|
||||
Reference in New Issue
Block a user