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:
@@ -26,13 +26,9 @@ function(download_portaudio)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
set(PA_BUILD_SHARED ON CACHE BOOL "" FORCE)
|
||||
set(PA_BUILD_STATIC OFF CACHE BOOL "" FORCE)
|
||||
else()
|
||||
set(PA_BUILD_SHARED OFF CACHE BOOL "" FORCE)
|
||||
set(PA_BUILD_STATIC ON CACHE BOOL "" FORCE)
|
||||
endif()
|
||||
# Always use static build
|
||||
set(PA_BUILD_SHARED OFF CACHE BOOL "" FORCE)
|
||||
set(PA_BUILD_STATIC ON CACHE BOOL "" FORCE)
|
||||
|
||||
FetchContent_Declare(portaudio
|
||||
URL
|
||||
@@ -55,28 +51,17 @@ function(download_portaudio)
|
||||
|
||||
add_subdirectory(${portaudio_SOURCE_DIR} ${portaudio_BINARY_DIR} EXCLUDE_FROM_ALL)
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
set_target_properties(portaudio PROPERTIES OUTPUT_NAME "sherpa-onnx-portaudio")
|
||||
if(NOT WIN32)
|
||||
target_compile_options(portaudio PRIVATE "-Wno-deprecated-declarations")
|
||||
endif()
|
||||
|
||||
if(SHERPA_ONNX_ENABLE_PYTHON AND WIN32)
|
||||
install(TARGETS portaudio DESTINATION ..)
|
||||
else()
|
||||
install(TARGETS portaudio DESTINATION lib)
|
||||
endif()
|
||||
else()
|
||||
set_target_properties(portaudio_static PROPERTIES OUTPUT_NAME "sherpa-onnx-portaudio_static")
|
||||
if(NOT WIN32)
|
||||
target_compile_options(portaudio_static PRIVATE "-Wno-deprecated-declarations")
|
||||
endif()
|
||||
if(SHERPA_ONNX_ENABLE_PYTHON AND WIN32)
|
||||
install(TARGETS portaudio_static DESTINATION ..)
|
||||
else()
|
||||
install(TARGETS portaudio_static DESTINATION lib)
|
||||
endif()
|
||||
set_target_properties(portaudio_static PROPERTIES OUTPUT_NAME "sherpa-onnx-portaudio_static")
|
||||
if(NOT WIN32)
|
||||
target_compile_options(portaudio_static PRIVATE "-Wno-deprecated-declarations")
|
||||
endif()
|
||||
|
||||
if(NOT BUILD_SHARED_LIBS AND SHERPA_ONNX_ENABLE_BINARY)
|
||||
install(TARGETS
|
||||
portaudio_static
|
||||
DESTINATION lib)
|
||||
endif()
|
||||
|
||||
endfunction()
|
||||
|
||||
download_portaudio()
|
||||
|
||||
Reference in New Issue
Block a user