Test using sherpa-onnx as a cmake subproject (#1961)

This commit is contained in:
Fangjun Kuang
2025-03-06 12:12:56 +08:00
committed by GitHub
parent 7740dbfb96
commit 1e2328242d
4 changed files with 95 additions and 2 deletions

View File

@@ -0,0 +1,17 @@
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
project(use-of-sherpa-onnx-as-a-sub-project)
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/sherpa-onnx/setup.py")
message(FATAL_ERROR "Please download the source code of sherpa-onnx and put it inside this directory")
endif()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
include_directories(./sherpa-onnx)
add_subdirectory(./sherpa-onnx)
add_executable(main main.cc)
target_link_libraries(main sherpa-onnx-core)

View File

@@ -0,0 +1,10 @@
#include "sherpa-onnx/csrc/offline-recognizer.h"
#include "sherpa-onnx/csrc/parse-options.h"
int main(int32_t argc, char *argv[]) {
sherpa_onnx::ParseOptions po("help info");
sherpa_onnx::OfflineRecognizerConfig config;
config.Register(&po);
po.PrintUsage();
return 0;
}