Committed by
GitHub
Support linking onnxruntime statically for macOS (#403)
正在显示
9 个修改的文件
包含
239 行增加
和
10 行删除
| @@ -39,11 +39,13 @@ concurrency: | @@ -39,11 +39,13 @@ concurrency: | ||
| 39 | jobs: | 39 | jobs: |
| 40 | macos: | 40 | macos: |
| 41 | runs-on: ${{ matrix.os }} | 41 | runs-on: ${{ matrix.os }} |
| 42 | + name: ${{ matrix.build_type }} ${{ matrix.lib_type }} | ||
| 42 | strategy: | 43 | strategy: |
| 43 | fail-fast: false | 44 | fail-fast: false |
| 44 | matrix: | 45 | matrix: |
| 45 | os: [macos-latest] | 46 | os: [macos-latest] |
| 46 | build_type: [Release, Debug] | 47 | build_type: [Release, Debug] |
| 48 | + lib_type: [static, shared] | ||
| 47 | 49 | ||
| 48 | steps: | 50 | steps: |
| 49 | - uses: actions/checkout@v4 | 51 | - uses: actions/checkout@v4 |
| @@ -53,7 +55,7 @@ jobs: | @@ -53,7 +55,7 @@ jobs: | ||
| 53 | - name: ccache | 55 | - name: ccache |
| 54 | uses: hendrikmuhs/ccache-action@v1.2 | 56 | uses: hendrikmuhs/ccache-action@v1.2 |
| 55 | with: | 57 | with: |
| 56 | - key: ${{ matrix.os }}-${{ matrix.build_type }} | 58 | + key: ${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.lib_type }} |
| 57 | 59 | ||
| 58 | - name: Configure CMake | 60 | - name: Configure CMake |
| 59 | shell: bash | 61 | shell: bash |
| @@ -64,7 +66,14 @@ jobs: | @@ -64,7 +66,14 @@ jobs: | ||
| 64 | 66 | ||
| 65 | mkdir build | 67 | mkdir build |
| 66 | cd build | 68 | cd build |
| 67 | - cmake -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_OSX_ARCHITECTURES='arm64;x86_64' -DCMAKE_INSTALL_PREFIX=./install .. | 69 | + lib_type=${{ matrix.lib_type }} |
| 70 | + if [[ $lib_type == "static" ]]; then | ||
| 71 | + BUILD_SHARED_LIBS=OFF | ||
| 72 | + else | ||
| 73 | + BUILD_SHARED_LIBS=ON | ||
| 74 | + fi | ||
| 75 | + | ||
| 76 | + cmake -D BUILD_SHARED_LIBS=$BUILD_SHARED_LIBS -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_OSX_ARCHITECTURES='arm64;x86_64' -DCMAKE_INSTALL_PREFIX=./install .. | ||
| 68 | 77 | ||
| 69 | - name: Build sherpa-onnx for macos | 78 | - name: Build sherpa-onnx for macos |
| 70 | shell: bash | 79 | shell: bash |
| @@ -149,7 +158,7 @@ jobs: | @@ -149,7 +158,7 @@ jobs: | ||
| 149 | run: | | 158 | run: | |
| 150 | SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) | 159 | SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) |
| 151 | 160 | ||
| 152 | - dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-osx-universal2 | 161 | + dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-osx-universal2-${{ matrix.lib_type }} |
| 153 | mkdir $dst | 162 | mkdir $dst |
| 154 | 163 | ||
| 155 | cp -a build/install/bin $dst/ | 164 | cp -a build/install/bin $dst/ |
| @@ -167,4 +176,4 @@ jobs: | @@ -167,4 +176,4 @@ jobs: | ||
| 167 | with: | 176 | with: |
| 168 | file_glob: true | 177 | file_glob: true |
| 169 | overwrite: true | 178 | overwrite: true |
| 170 | - file: sherpa-onnx-*osx-universal2.tar.bz2 | 179 | + file: sherpa-onnx-*osx-universal2*.tar.bz2 |
cmake/onnxruntime-osx-arm64-static.cmake
0 → 100644
| 1 | +# Copyright (c) 2022-2023 Xiaomi Corporation | ||
| 2 | +message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}") | ||
| 3 | +message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}") | ||
| 4 | +message(STATUS "CMAKE_OSX_ARCHITECTURES: ${CMAKE_OSX_ARCHITECTURES}") | ||
| 5 | +message(STATUS "CMAKE_APPLE_SILICON_PROCESSOR : ${CMAKE_APPLE_SILICON_PROCESSOR}") | ||
| 6 | + | ||
| 7 | +if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin) | ||
| 8 | + message(FATAL_ERROR "This file is for macOS only. Given: ${CMAKE_SYSTEM_NAME}") | ||
| 9 | +endif() | ||
| 10 | + | ||
| 11 | +if(BUILD_SHARED_LIBS) | ||
| 12 | + message(FATAL_ERROR "This file is for building static libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}") | ||
| 13 | +endif() | ||
| 14 | + | ||
| 15 | +set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.16.0/onnxruntime-osx-arm64-static_lib-1.16.0.zip") | ||
| 16 | +set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-osx-arm64-static_lib-1.16.0.zip") | ||
| 17 | +set(onnxruntime_HASH "SHA256=5f99c9a51d91e751ac20fcbb73dfa31a379438381c5357fd3f37bda816934e3e") | ||
| 18 | + | ||
| 19 | +# If you don't have access to the Internet, | ||
| 20 | +# please download onnxruntime to one of the following locations. | ||
| 21 | +# You can add more if you want. | ||
| 22 | +set(possible_file_locations | ||
| 23 | + $ENV{HOME}/Downloads/onnxruntime-osx-arm64-static_lib-1.16.0.zip | ||
| 24 | + ${PROJECT_SOURCE_DIR}/onnxruntime-osx-arm64-static_lib-1.16.0.zip | ||
| 25 | + ${PROJECT_BINARY_DIR}/onnxruntime-osx-arm64-static_lib-1.16.0.zip | ||
| 26 | + /tmp/onnxruntime-osx-arm64-static_lib-1.16.0.zip | ||
| 27 | +) | ||
| 28 | + | ||
| 29 | +foreach(f IN LISTS possible_file_locations) | ||
| 30 | + if(EXISTS ${f}) | ||
| 31 | + set(onnxruntime_URL "${f}") | ||
| 32 | + file(TO_CMAKE_PATH "${onnxruntime_URL}" onnxruntime_URL) | ||
| 33 | + message(STATUS "Found local downloaded onnxruntime: ${onnxruntime_URL}") | ||
| 34 | + set(onnxruntime_URL2) | ||
| 35 | + break() | ||
| 36 | + endif() | ||
| 37 | +endforeach() | ||
| 38 | + | ||
| 39 | +FetchContent_Declare(onnxruntime | ||
| 40 | + URL | ||
| 41 | + ${onnxruntime_URL} | ||
| 42 | + ${onnxruntime_URL2} | ||
| 43 | + URL_HASH ${onnxruntime_HASH} | ||
| 44 | +) | ||
| 45 | + | ||
| 46 | +FetchContent_GetProperties(onnxruntime) | ||
| 47 | +if(NOT onnxruntime_POPULATED) | ||
| 48 | + message(STATUS "Downloading onnxruntime from ${onnxruntime_URL}") | ||
| 49 | + FetchContent_Populate(onnxruntime) | ||
| 50 | +endif() | ||
| 51 | +message(STATUS "onnxruntime is downloaded to ${onnxruntime_SOURCE_DIR}") | ||
| 52 | + | ||
| 53 | +# for static libraries, we use onnxruntime_lib_files directly below | ||
| 54 | +include_directories(${onnxruntime_SOURCE_DIR}/include) | ||
| 55 | + | ||
| 56 | +file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/lib*.a") | ||
| 57 | + | ||
| 58 | +set(onnxruntime_lib_files ${onnxruntime_lib_files} PARENT_SCOPE) | ||
| 59 | + | ||
| 60 | +message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}") | ||
| 61 | +install(FILES ${onnxruntime_lib_files} DESTINATION lib) |
| @@ -8,6 +8,10 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin) | @@ -8,6 +8,10 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin) | ||
| 8 | message(FATAL_ERROR "This file is for macOS only. Given: ${CMAKE_SYSTEM_NAME}") | 8 | message(FATAL_ERROR "This file is for macOS only. Given: ${CMAKE_SYSTEM_NAME}") |
| 9 | endif() | 9 | endif() |
| 10 | 10 | ||
| 11 | +if(NOT BUILD_SHARED_LIBS) | ||
| 12 | + message(FATAL_ERROR "This file is for building shared libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}") | ||
| 13 | +endif() | ||
| 14 | + | ||
| 11 | set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.16.0/onnxruntime-osx-arm64-1.16.0.tgz") | 15 | set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.16.0/onnxruntime-osx-arm64-1.16.0.tgz") |
| 12 | set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/onnxruntime-osx-arm64-1.16.0.tgz") | 16 | set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/onnxruntime-osx-arm64-1.16.0.tgz") |
| 13 | set(onnxruntime_HASH "SHA256=fec3b70ca4f642a5c6d5c3a6f3a4eddd4c1b9281893fe2c7ae03a3086e20c316") | 17 | set(onnxruntime_HASH "SHA256=fec3b70ca4f642a5c6d5c3a6f3a4eddd4c1b9281893fe2c7ae03a3086e20c316") |
cmake/onnxruntime-osx-universal-static.cmake
0 → 100644
| 1 | +# Possible values for CMAKE_SYSTEM_NAME: Linux, Windows, Darwin | ||
| 2 | + | ||
| 3 | +message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}") | ||
| 4 | +message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}") | ||
| 5 | +message(STATUS "CMAKE_OSX_ARCHITECTURES: ${CMAKE_OSX_ARCHITECTURES}") | ||
| 6 | +message(STATUS "CMAKE_APPLE_SILICON_PROCESSOR : ${CMAKE_APPLE_SILICON_PROCESSOR}") | ||
| 7 | + | ||
| 8 | +if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin) | ||
| 9 | + message(FATAL_ERROR "This file is for macOS only. Given: ${CMAKE_SYSTEM_NAME}") | ||
| 10 | +endif() | ||
| 11 | + | ||
| 12 | +if(BUILD_SHARED_LIBS) | ||
| 13 | + message(FATAL_ERROR "This file is for building static libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}") | ||
| 14 | +endif() | ||
| 15 | + | ||
| 16 | +set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.16.0/onnxruntime-osx-universal2-static_lib-1.16.0.zip") | ||
| 17 | +set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-osx-universal2-static_lib-1.16.0.zip") | ||
| 18 | +set(onnxruntime_HASH "SHA256=6df205fb519d311ff57131d35ed43374f4fe483eb665baa38bfbc00034595b35") | ||
| 19 | + | ||
| 20 | +# If you don't have access to the Internet, | ||
| 21 | +# please download onnxruntime to one of the following locations. | ||
| 22 | +# You can add more if you want. | ||
| 23 | +set(possible_file_locations | ||
| 24 | + $ENV{HOME}/Downloads/onnxruntime-osx-universal2-static_lib-1.16.0.zip | ||
| 25 | + ${PROJECT_SOURCE_DIR}/onnxruntime-osx-universal2-static_lib-1.16.0.zip | ||
| 26 | + ${PROJECT_BINARY_DIR}/onnxruntime-osx-universal2-static_lib-1.16.0.zip | ||
| 27 | + /tmp/onnxruntime-osx-universal2-static_lib-1.16.0.zip | ||
| 28 | +) | ||
| 29 | + | ||
| 30 | +foreach(f IN LISTS possible_file_locations) | ||
| 31 | + if(EXISTS ${f}) | ||
| 32 | + set(onnxruntime_URL "${f}") | ||
| 33 | + file(TO_CMAKE_PATH "${onnxruntime_URL}" onnxruntime_URL) | ||
| 34 | + message(STATUS "Found local downloaded onnxruntime: ${onnxruntime_URL}") | ||
| 35 | + set(onnxruntime_URL2) | ||
| 36 | + break() | ||
| 37 | + endif() | ||
| 38 | +endforeach() | ||
| 39 | + | ||
| 40 | +FetchContent_Declare(onnxruntime | ||
| 41 | + URL | ||
| 42 | + ${onnxruntime_URL} | ||
| 43 | + ${onnxruntime_URL2} | ||
| 44 | + URL_HASH ${onnxruntime_HASH} | ||
| 45 | +) | ||
| 46 | + | ||
| 47 | +FetchContent_GetProperties(onnxruntime) | ||
| 48 | +if(NOT onnxruntime_POPULATED) | ||
| 49 | + message(STATUS "Downloading onnxruntime from ${onnxruntime_URL}") | ||
| 50 | + FetchContent_Populate(onnxruntime) | ||
| 51 | +endif() | ||
| 52 | +message(STATUS "onnxruntime is downloaded to ${onnxruntime_SOURCE_DIR}") | ||
| 53 | + | ||
| 54 | +# for static libraries, we use onnxruntime_lib_files directly below | ||
| 55 | +include_directories(${onnxruntime_SOURCE_DIR}/include) | ||
| 56 | + | ||
| 57 | +file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/lib*.a") | ||
| 58 | + | ||
| 59 | +set(onnxruntime_lib_files ${onnxruntime_lib_files} PARENT_SCOPE) | ||
| 60 | + | ||
| 61 | +message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}") | ||
| 62 | +install(FILES ${onnxruntime_lib_files} DESTINATION lib) |
| @@ -9,6 +9,10 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin) | @@ -9,6 +9,10 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin) | ||
| 9 | message(FATAL_ERROR "This file is for macOS only. Given: ${CMAKE_SYSTEM_NAME}") | 9 | message(FATAL_ERROR "This file is for macOS only. Given: ${CMAKE_SYSTEM_NAME}") |
| 10 | endif() | 10 | endif() |
| 11 | 11 | ||
| 12 | +if(NOT BUILD_SHARED_LIBS) | ||
| 13 | + message(FATAL_ERROR "This file is for building shared libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}") | ||
| 14 | +endif() | ||
| 15 | + | ||
| 12 | set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.16.0/onnxruntime-osx-universal2-1.16.0.tgz") | 16 | set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.16.0/onnxruntime-osx-universal2-1.16.0.tgz") |
| 13 | set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/onnxruntime-osx-universal2-1.16.0.tgz") | 17 | set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/onnxruntime-osx-universal2-1.16.0.tgz") |
| 14 | set(onnxruntime_HASH "SHA256=e5b69ece634cf1cd5cf4b45ab478417199a5e8ab5775f6f12560e09dc5ef7749") | 18 | set(onnxruntime_HASH "SHA256=e5b69ece634cf1cd5cf4b45ab478417199a5e8ab5775f6f12560e09dc5ef7749") |
cmake/onnxruntime-osx-x86_64-static.cmake
0 → 100644
| 1 | +# Copyright (c) 2022-2023 Xiaomi Corporation | ||
| 2 | +message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}") | ||
| 3 | +message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}") | ||
| 4 | +message(STATUS "CMAKE_OSX_ARCHITECTURES: ${CMAKE_OSX_ARCHITECTURES}") | ||
| 5 | +message(STATUS "CMAKE_APPLE_SILICON_PROCESSOR : ${CMAKE_APPLE_SILICON_PROCESSOR}") | ||
| 6 | + | ||
| 7 | +if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin) | ||
| 8 | + message(FATAL_ERROR "This file is for macOS only. Given: ${CMAKE_SYSTEM_NAME}") | ||
| 9 | +endif() | ||
| 10 | + | ||
| 11 | +if(BUILD_SHARED_LIBS) | ||
| 12 | + message(FATAL_ERROR "This file is for building static libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}") | ||
| 13 | +endif() | ||
| 14 | + | ||
| 15 | +set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.16.0/onnxruntime-osx-x86_64-static_lib-1.16.0.zip") | ||
| 16 | +set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-osx-x86_64-static_lib-1.16.0.zip") | ||
| 17 | +set(onnxruntime_HASH "SHA256=1686a1b6778483371d29106d8c7300a8960e3db084ab84ac4f870b7685cf5259") | ||
| 18 | + | ||
| 19 | +# If you don't have access to the Internet, | ||
| 20 | +# please download onnxruntime to one of the following locations. | ||
| 21 | +# You can add more if you want. | ||
| 22 | +set(possible_file_locations | ||
| 23 | + $ENV{HOME}/Downloads/onnxruntime-osx-x86_64-static_lib-1.16.0.zip | ||
| 24 | + ${PROJECT_SOURCE_DIR}/onnxruntime-osx-x86_64-static_lib-1.16.0.zip | ||
| 25 | + ${PROJECT_BINARY_DIR}/onnxruntime-osx-x86_64-static_lib-1.16.0.zip | ||
| 26 | + /tmp/onnxruntime-osx-x86_64-static_lib-1.16.0.zip | ||
| 27 | +) | ||
| 28 | + | ||
| 29 | +foreach(f IN LISTS possible_file_locations) | ||
| 30 | + if(EXISTS ${f}) | ||
| 31 | + set(onnxruntime_URL "${f}") | ||
| 32 | + file(TO_CMAKE_PATH "${onnxruntime_URL}" onnxruntime_URL) | ||
| 33 | + message(STATUS "Found local downloaded onnxruntime: ${onnxruntime_URL}") | ||
| 34 | + set(onnxruntime_URL2) | ||
| 35 | + break() | ||
| 36 | + endif() | ||
| 37 | +endforeach() | ||
| 38 | + | ||
| 39 | +FetchContent_Declare(onnxruntime | ||
| 40 | + URL | ||
| 41 | + ${onnxruntime_URL} | ||
| 42 | + ${onnxruntime_URL2} | ||
| 43 | + URL_HASH ${onnxruntime_HASH} | ||
| 44 | +) | ||
| 45 | + | ||
| 46 | +FetchContent_GetProperties(onnxruntime) | ||
| 47 | +if(NOT onnxruntime_POPULATED) | ||
| 48 | + message(STATUS "Downloading onnxruntime from ${onnxruntime_URL}") | ||
| 49 | + FetchContent_Populate(onnxruntime) | ||
| 50 | +endif() | ||
| 51 | +message(STATUS "onnxruntime is downloaded to ${onnxruntime_SOURCE_DIR}") | ||
| 52 | + | ||
| 53 | +# for static libraries, we use onnxruntime_lib_files directly below | ||
| 54 | +include_directories(${onnxruntime_SOURCE_DIR}/include) | ||
| 55 | + | ||
| 56 | +file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/lib*.a") | ||
| 57 | + | ||
| 58 | +set(onnxruntime_lib_files ${onnxruntime_lib_files} PARENT_SCOPE) | ||
| 59 | + | ||
| 60 | +message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}") | ||
| 61 | +install(FILES ${onnxruntime_lib_files} DESTINATION lib) |
| @@ -8,6 +8,10 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin) | @@ -8,6 +8,10 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin) | ||
| 8 | message(FATAL_ERROR "This file is for macOS only. Given: ${CMAKE_SYSTEM_NAME}") | 8 | message(FATAL_ERROR "This file is for macOS only. Given: ${CMAKE_SYSTEM_NAME}") |
| 9 | endif() | 9 | endif() |
| 10 | 10 | ||
| 11 | +if(NOT BUILD_SHARED_LIBS) | ||
| 12 | + message(FATAL_ERROR "This file is for building shared libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}") | ||
| 13 | +endif() | ||
| 14 | + | ||
| 11 | set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.16.0/onnxruntime-osx-x86_64-1.16.0.tgz") | 15 | set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.16.0/onnxruntime-osx-x86_64-1.16.0.tgz") |
| 12 | set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/onnxruntime-osx-x86_64-1.16.0.tgz") | 16 | set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/onnxruntime-osx-x86_64-1.16.0.tgz") |
| 13 | set(onnxruntime_HASH "SHA256=3d639a269af4e97a455f23cff363a709ef3a5f3e086162e65e3395c339122285") | 17 | set(onnxruntime_HASH "SHA256=3d639a269af4e97a455f23cff363a709ef3a5f3e086162e65e3395c339122285") |
| @@ -27,17 +27,37 @@ function(download_onnxruntime) | @@ -27,17 +27,37 @@ function(download_onnxruntime) | ||
| 27 | endif() | 27 | endif() |
| 28 | elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin) | 28 | elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin) |
| 29 | if (arm64 IN_LIST CMAKE_OSX_ARCHITECTURES AND x86_64 IN_LIST CMAKE_OSX_ARCHITECTURES) | 29 | if (arm64 IN_LIST CMAKE_OSX_ARCHITECTURES AND x86_64 IN_LIST CMAKE_OSX_ARCHITECTURES) |
| 30 | - include(onnxruntime-osx-universal) | 30 | + if(BUILD_SHARED_LIBS) |
| 31 | + include(onnxruntime-osx-universal) | ||
| 32 | + else() | ||
| 33 | + include(onnxruntime-osx-universal-static) | ||
| 34 | + endif() | ||
| 31 | elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 AND CMAKE_OSX_ARCHITECTURES STREQUAL "arm64") | 35 | elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 AND CMAKE_OSX_ARCHITECTURES STREQUAL "arm64") |
| 32 | # cross compiling | 36 | # cross compiling |
| 33 | - include(onnxruntime-osx-arm64) | 37 | + if(BUILD_SHARED_LIBS) |
| 38 | + include(onnxruntime-osx-arm64) | ||
| 39 | + else() | ||
| 40 | + include(onnxruntime-osx-arm64-static) | ||
| 41 | + endif() | ||
| 34 | elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL arm64 AND CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64") | 42 | elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL arm64 AND CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64") |
| 35 | # cross compiling | 43 | # cross compiling |
| 36 | - include(onnxruntime-osx-x86_64) | 44 | + if(BUILD_SHARED_LIBS) |
| 45 | + include(onnxruntime-osx-x86_64) | ||
| 46 | + else() | ||
| 47 | + include(onnxruntime-osx-x86_64-static) | ||
| 48 | + endif() | ||
| 37 | elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL arm64) | 49 | elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL arm64) |
| 38 | - include(onnxruntime-osx-arm64) | 50 | + if(BUILD_SHARED_LIBS) |
| 51 | + include(onnxruntime-osx-arm64) | ||
| 52 | + else() | ||
| 53 | + include(onnxruntime-osx-arm64-static) | ||
| 54 | + endif() | ||
| 39 | elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64) | 55 | elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64) |
| 40 | - include(onnxruntime-osx-x86_64) | 56 | + if(BUILD_SHARED_LIBS) |
| 57 | + include(onnxruntime-osx-x86_64) | ||
| 58 | + else() | ||
| 59 | + include(onnxruntime-osx-x86_64-static) | ||
| 60 | + endif() | ||
| 41 | else() | 61 | else() |
| 42 | message(FATAL_ERROR "Unsupport processor {CMAKE_SYSTEM_PROCESSOR} for Darwin") | 62 | message(FATAL_ERROR "Unsupport processor {CMAKE_SYSTEM_PROCESSOR} for Darwin") |
| 43 | endif() | 63 | endif() |
| @@ -113,12 +113,16 @@ target_link_libraries(sherpa-onnx-core kaldi-native-fbank-core) | @@ -113,12 +113,16 @@ target_link_libraries(sherpa-onnx-core kaldi-native-fbank-core) | ||
| 113 | 113 | ||
| 114 | target_link_libraries(sherpa-onnx-core kaldi-decoder-core) | 114 | target_link_libraries(sherpa-onnx-core kaldi-decoder-core) |
| 115 | 115 | ||
| 116 | -if(BUILD_SHARED_LIBS OR APPLE) | 116 | +if(BUILD_SHARED_LIBS) |
| 117 | target_link_libraries(sherpa-onnx-core onnxruntime) | 117 | target_link_libraries(sherpa-onnx-core onnxruntime) |
| 118 | else() | 118 | else() |
| 119 | target_link_libraries(sherpa-onnx-core ${onnxruntime_lib_files}) | 119 | target_link_libraries(sherpa-onnx-core ${onnxruntime_lib_files}) |
| 120 | endif() | 120 | endif() |
| 121 | 121 | ||
| 122 | +if(NOT BUILD_SHARED_LIBS AND APPLE) | ||
| 123 | + target_link_libraries(sherpa-onnx-core "-framework Foundation") | ||
| 124 | +endif() | ||
| 125 | + | ||
| 122 | if(SHERPA_ONNX_ENABLE_GPU) | 126 | if(SHERPA_ONNX_ENABLE_GPU) |
| 123 | target_link_libraries(sherpa-onnx-core | 127 | target_link_libraries(sherpa-onnx-core |
| 124 | onnxruntime_providers_cuda | 128 | onnxruntime_providers_cuda |
-
请 注册 或 登录 后发表评论