File tree 4 files changed +96
-2
lines changed
scripts/as-cmake-sub-project
4 files changed +96
-2
lines changed Original file line number Diff line number Diff line change
1
+ cmake_minimum_required (VERSION 3.13 FATAL_ERROR)
2
+
3
+ project (use-of-sherpa-onnx-as-a-sub-project)
4
+
5
+ if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR} /sherpa-onnx/setup.py" )
6
+ message (FATAL_ERROR "Please download the source code of sherpa-onnx and put it inside this directory" )
7
+ endif ()
8
+
9
+ set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /lib" )
10
+ set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /lib" )
11
+ set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /bin" )
12
+
13
+ include_directories (./sherpa-onnx)
14
+ add_subdirectory (./sherpa-onnx)
15
+
16
+ add_executable (main main.cc)
17
+ target_link_libraries (main sherpa-onnx-core)
Original file line number Diff line number Diff line change
1
+ #include " sherpa-onnx/csrc/offline-recognizer.h"
2
+ #include " sherpa-onnx/csrc/parse-options.h"
3
+
4
+ int main (int32_t argc, char *argv[]) {
5
+ sherpa_onnx::ParseOptions po (" help info" );
6
+ sherpa_onnx::OfflineRecognizerConfig config;
7
+ config.Register (&po);
8
+ po.PrintUsage ();
9
+ return 0 ;
10
+ }
Original file line number Diff line number Diff line change
1
+ name : linux
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - master
7
+ - as-cmake-sub-project
8
+ pull_request :
9
+ branches :
10
+ - master
11
+
12
+ workflow_dispatch :
13
+
14
+ concurrency :
15
+ group : as-cmake-sub-project-${{ github.ref }}
16
+ cancel-in-progress : true
17
+
18
+ jobs :
19
+ as_cmake_sub_project :
20
+ name : ${{ matrix.os }} shared ${{ matrix.shared_lib }}
21
+ runs-on : ${{ matrix.os }}
22
+ strategy :
23
+ fail-fast : false
24
+ matrix :
25
+ os : [ubuntu-latest]
26
+ shared_lib : [ON, OFF]
27
+
28
+ steps :
29
+ - uses : actions/checkout@v4
30
+ with :
31
+ fetch-depth : 0
32
+
33
+ - name : ccache
34
+ uses : hendrikmuhs/ccache-action@v1.2
35
+ with :
36
+ key : ${{ matrix.os }}-${{ matrix.shared_lib }}-cmake-sub-project
37
+
38
+ - name : Display PWD
39
+ shell : bash
40
+ run : |
41
+ echo "pwd: $PWD"
42
+ ls -lh
43
+ du -h -d1 .
44
+
45
+ - name : Build
46
+ shell : bash
47
+ run : |
48
+ mv .github/scripts/as-cmake-sub-project ..
49
+ cd ../as-cmake-sub-project
50
+ ln -s $PWD/../sherpa-onnx .
51
+ mkdir build
52
+ cd build
53
+ cmake -DBUILD_SHARED_LIBS=${{ matrix.shared_lib }} ..
54
+ make -j2 main
55
+
56
+ - name : Test
57
+ shell : bash
58
+ run : |
59
+ cd ../as-cmake-sub-project
60
+
61
+ cd build
62
+ ls -lh lib
63
+ echo "----"
64
+ ls -lh bin
65
+
66
+ readelf -d ./bin/main
67
+ ./bin/main
Original file line number Diff line number Diff line change @@ -322,8 +322,8 @@ if(WIN32 AND MSVC)
322
322
add_compile_options ("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>" )
323
323
endif ()
324
324
325
- list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR } /cmake/Modules)
326
- list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR } /cmake)
325
+ list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR } /cmake/Modules)
326
+ list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR } /cmake)
327
327
328
328
if (SHERPA_ONNX_ENABLE_WASM)
329
329
# Enable it for debugging in case there is something wrong.
You can’t perform that action at this time.
0 commit comments