Fangjun Kuang
Committed by GitHub

Refactor onnxruntime.cmake (#220)

@@ -55,6 +55,10 @@ function(download_kaldi_native_fbank) @@ -55,6 +55,10 @@ function(download_kaldi_native_fbank)
55 else() 55 else()
56 install(TARGETS kaldi-native-fbank-core DESTINATION lib) 56 install(TARGETS kaldi-native-fbank-core DESTINATION lib)
57 endif() 57 endif()
  58 +
  59 + if(WIN32 AND BUILD_SHARED_LIBS)
  60 + install(TARGETS kaldi-native-fbank-core DESTINATION bin)
  61 + endif()
58 endfunction() 62 endfunction()
59 63
60 download_kaldi_native_fbank() 64 download_kaldi_native_fbank()
  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(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL arm64)
  12 + message(FATAL_ERROR "This file is for arm64 only. Given: ${CMAKE_SYSTEM_PROCESSOR}")
  13 +endif()
  14 +
  15 +set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.15.1/onnxruntime-osx-arm64-1.15.1.tgz")
  16 +set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/onnxruntime-osx-arm64-1.15.1.tgz")
  17 +set(onnxruntime_HASH "SHA256=df97832fc7907c6677a6da437f92339d84a462becb74b1d65217fcb859ee9460")
  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-1.15.1.tgz
  24 + ${PROJECT_SOURCE_DIR}/onnxruntime-osx-arm64-1.15.1.tgz
  25 + ${PROJECT_BINARY_DIR}/onnxruntime-osx-arm64-1.15.1.tgz
  26 + /tmp/onnxruntime-osx-arm64-1.15.1.tgz
  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 +find_library(location_onnxruntime onnxruntime
  54 + PATHS
  55 + "${onnxruntime_SOURCE_DIR}/lib"
  56 + NO_CMAKE_SYSTEM_PATH
  57 +)
  58 +
  59 +message(STATUS "location_onnxruntime: ${location_onnxruntime}")
  60 +
  61 +add_library(onnxruntime SHARED IMPORTED)
  62 +
  63 +set_target_properties(onnxruntime PROPERTIES
  64 + IMPORTED_LOCATION ${location_onnxruntime}
  65 + INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_SOURCE_DIR}/include"
  66 +)
  67 +
  68 +file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/libonnxruntime*dylib")
  69 +message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")
  70 +install(FILES ${onnxruntime_lib_files} DESTINATION lib)
  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 +set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.15.1/onnxruntime-osx-universal2-1.15.1.tgz")
  13 +set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/onnxruntime-osx-universal2-1.15.1.tgz")
  14 +set(onnxruntime_HASH "SHA256=ecb7651c216fe6ffaf4c578e135d98341bc5bc944c5dc6b725ef85b0d7747be0")
  15 +
  16 +# If you don't have access to the Internet,
  17 +# please download onnxruntime to one of the following locations.
  18 +# You can add more if you want.
  19 +set(possible_file_locations
  20 + $ENV{HOME}/Downloads/onnxruntime-osx-universal2-1.15.1.tgz
  21 + ${PROJECT_SOURCE_DIR}/onnxruntime-osx-universal2-1.15.1.tgz
  22 + ${PROJECT_BINARY_DIR}/onnxruntime-osx-universal2-1.15.1.tgz
  23 + /tmp/onnxruntime-osx-universal2-1.15.1.tgz
  24 +)
  25 +
  26 +foreach(f IN LISTS possible_file_locations)
  27 + if(EXISTS ${f})
  28 + set(onnxruntime_URL "${f}")
  29 + file(TO_CMAKE_PATH "${onnxruntime_URL}" onnxruntime_URL)
  30 + message(STATUS "Found local downloaded onnxruntime: ${onnxruntime_URL}")
  31 + set(onnxruntime_URL2)
  32 + break()
  33 + endif()
  34 +endforeach()
  35 +
  36 +FetchContent_Declare(onnxruntime
  37 + URL
  38 + ${onnxruntime_URL}
  39 + ${onnxruntime_URL2}
  40 + URL_HASH ${onnxruntime_HASH}
  41 +)
  42 +
  43 +FetchContent_GetProperties(onnxruntime)
  44 +if(NOT onnxruntime_POPULATED)
  45 + message(STATUS "Downloading onnxruntime from ${onnxruntime_URL}")
  46 + FetchContent_Populate(onnxruntime)
  47 +endif()
  48 +message(STATUS "onnxruntime is downloaded to ${onnxruntime_SOURCE_DIR}")
  49 +
  50 +find_library(location_onnxruntime onnxruntime
  51 + PATHS
  52 + "${onnxruntime_SOURCE_DIR}/lib"
  53 + NO_CMAKE_SYSTEM_PATH
  54 +)
  55 +
  56 +message(STATUS "location_onnxruntime: ${location_onnxruntime}")
  57 +
  58 +add_library(onnxruntime SHARED IMPORTED)
  59 +
  60 +set_target_properties(onnxruntime PROPERTIES
  61 + IMPORTED_LOCATION ${location_onnxruntime}
  62 + INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_SOURCE_DIR}/include"
  63 +)
  64 +
  65 +file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/libonnxruntime*dylib")
  66 +message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")
  67 +install(FILES ${onnxruntime_lib_files} DESTINATION lib)
  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(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64)
  12 + message(FATAL_ERROR "This file is for x86_64 only. Given: ${CMAKE_SYSTEM_PROCESSOR}")
  13 +endif()
  14 +
  15 +set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.15.1/onnxruntime-osx-x86_64-1.15.1.tgz")
  16 +set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/onnxruntime-osx-x86_64-1.15.1.tgz")
  17 +set(onnxruntime_HASH "SHA256=4b66ebbca24b8b96f6b74655fee3610a7e529b4e01f6790632f24ee82b778e5a")
  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-1.15.1.tgz
  24 + ${PROJECT_SOURCE_DIR}/onnxruntime-osx-x86_64-1.15.1.tgz
  25 + ${PROJECT_BINARY_DIR}/onnxruntime-osx-x86_64-1.15.1.tgz
  26 + /tmp/onnxruntime-osx-x86_64-1.15.1.tgz
  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 +find_library(location_onnxruntime onnxruntime
  54 + PATHS
  55 + "${onnxruntime_SOURCE_DIR}/lib"
  56 + NO_CMAKE_SYSTEM_PATH
  57 +)
  58 +
  59 +message(STATUS "location_onnxruntime: ${location_onnxruntime}")
  60 +
  61 +add_library(onnxruntime SHARED IMPORTED)
  62 +
  63 +set_target_properties(onnxruntime PROPERTIES
  64 + IMPORTED_LOCATION ${location_onnxruntime}
  65 + INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_SOURCE_DIR}/include"
  66 +)
  67 +
  68 +file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/libonnxruntime*dylib")
  69 +message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")
  70 +install(FILES ${onnxruntime_lib_files} DESTINATION lib)
  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 +
  5 +if(NOT CMAKE_SYSTEM_NAME STREQUAL Linux)
  6 + message(FATAL_ERROR "This file is for Linux only. Given: ${CMAKE_SYSTEM_NAME}")
  7 +endif()
  8 +
  9 +if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64)
  10 + message(FATAL_ERROR "This file is for aarch64 only. Given: ${CMAKE_SYSTEM_PROCESSOR}")
  11 +endif()
  12 +
  13 +set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.15.1/onnxruntime-linux-aarch64-1.15.1.tgz")
  14 +set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/onnxruntime-linux-aarch64-1.15.1.tgz")
  15 +set(onnxruntime_HASH "SHA256=85272e75d8dd841138de4b774a9672ea93c1be108d96038c6c34a62d7f976aee")
  16 +
  17 +# If you don't have access to the Internet,
  18 +# please download onnxruntime to one of the following locations.
  19 +# You can add more if you want.
  20 +set(possible_file_locations
  21 + $ENV{HOME}/Downloads/onnxruntime-linux-aarch64-1.15.1.tgz
  22 + ${PROJECT_SOURCE_DIR}/onnxruntime-linux-aarch64-1.15.1.tgz
  23 + ${PROJECT_BINARY_DIR}/onnxruntime-linux-aarch64-1.15.1.tgz
  24 + /tmp/onnxruntime-linux-aarch64-1.15.1.tgz
  25 + /star-fj/fangjun/download/github/onnxruntime-linux-aarch64-1.15.1.tgz
  26 +)
  27 +
  28 +foreach(f IN LISTS possible_file_locations)
  29 + if(EXISTS ${f})
  30 + set(onnxruntime_URL "${f}")
  31 + file(TO_CMAKE_PATH "${onnxruntime_URL}" onnxruntime_URL)
  32 + message(STATUS "Found local downloaded onnxruntime: ${onnxruntime_URL}")
  33 + set(onnxruntime_URL2)
  34 + break()
  35 + endif()
  36 +endforeach()
  37 +
  38 +FetchContent_Declare(onnxruntime
  39 + URL
  40 + ${onnxruntime_URL}
  41 + ${onnxruntime_URL2}
  42 + URL_HASH ${onnxruntime_HASH}
  43 +)
  44 +
  45 +FetchContent_GetProperties(onnxruntime)
  46 +if(NOT onnxruntime_POPULATED)
  47 + message(STATUS "Downloading onnxruntime from ${onnxruntime_URL}")
  48 + FetchContent_Populate(onnxruntime)
  49 +endif()
  50 +message(STATUS "onnxruntime is downloaded to ${onnxruntime_SOURCE_DIR}")
  51 +
  52 +find_library(location_onnxruntime onnxruntime
  53 + PATHS
  54 + "${onnxruntime_SOURCE_DIR}/lib"
  55 + NO_CMAKE_SYSTEM_PATH
  56 +)
  57 +
  58 +message(STATUS "location_onnxruntime: ${location_onnxruntime}")
  59 +
  60 +add_library(onnxruntime SHARED IMPORTED)
  61 +
  62 +set_target_properties(onnxruntime PROPERTIES
  63 + IMPORTED_LOCATION ${location_onnxruntime}
  64 + INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_SOURCE_DIR}/include"
  65 +)
  66 +
  67 +file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/libonnxruntime*")
  68 +message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")
  69 +install(FILES ${onnxruntime_lib_files} DESTINATION lib)
  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 +
  5 +if(NOT CMAKE_SYSTEM_NAME STREQUAL Linux)
  6 + message(FATAL_ERROR "This file is for Linux only. Given: ${CMAKE_SYSTEM_NAME}")
  7 +endif()
  8 +
  9 +if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL arm)
  10 + message(FATAL_ERROR "This file is for arm only. Given: ${CMAKE_SYSTEM_PROCESSOR}")
  11 +endif()
  12 +
  13 +set(onnxruntime_URL "https://huggingface.co/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-linux-arm-1.15.1.zip")
  14 +set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/onnxruntime-linux-arm-1.15.1.zip")
  15 +set(onnxruntime_HASH "SHA256=867b96210a347e4b1bb949e7c9a3f222371ea0c00c9deaaba9fdd66c689f7fb7")
  16 +
  17 +# If you don't have access to the Internet,
  18 +# please download onnxruntime to one of the following locations.
  19 +# You can add more if you want.
  20 +set(possible_file_locations
  21 + $ENV{HOME}/Downloads/onnxruntime-linux-arm-1.15.1.zip
  22 + ${PROJECT_SOURCE_DIR}/onnxruntime-linux-arm-1.15.1.zip
  23 + ${PROJECT_BINARY_DIR}/onnxruntime-linux-arm-1.15.1.zip
  24 + /tmp/onnxruntime-linux-arm-1.15.1.zip
  25 + /star-fj/fangjun/download/github/onnxruntime-linux-arm-1.15.1.zip
  26 +)
  27 +
  28 +foreach(f IN LISTS possible_file_locations)
  29 + if(EXISTS ${f})
  30 + set(onnxruntime_URL "${f}")
  31 + file(TO_CMAKE_PATH "${onnxruntime_URL}" onnxruntime_URL)
  32 + message(STATUS "Found local downloaded onnxruntime: ${onnxruntime_URL}")
  33 + set(onnxruntime_URL2)
  34 + break()
  35 + endif()
  36 +endforeach()
  37 +
  38 +FetchContent_Declare(onnxruntime
  39 + URL
  40 + ${onnxruntime_URL}
  41 + ${onnxruntime_URL2}
  42 + URL_HASH ${onnxruntime_HASH}
  43 +)
  44 +
  45 +FetchContent_GetProperties(onnxruntime)
  46 +if(NOT onnxruntime_POPULATED)
  47 + message(STATUS "Downloading onnxruntime from ${onnxruntime_URL}")
  48 + FetchContent_Populate(onnxruntime)
  49 +endif()
  50 +message(STATUS "onnxruntime is downloaded to ${onnxruntime_SOURCE_DIR}")
  51 +
  52 +find_library(location_onnxruntime onnxruntime
  53 + PATHS
  54 + "${onnxruntime_SOURCE_DIR}/lib"
  55 + NO_CMAKE_SYSTEM_PATH
  56 +)
  57 +
  58 +message(STATUS "location_onnxruntime: ${location_onnxruntime}")
  59 +
  60 +add_library(onnxruntime SHARED IMPORTED)
  61 +
  62 +set_target_properties(onnxruntime PROPERTIES
  63 + IMPORTED_LOCATION ${location_onnxruntime}
  64 + INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_SOURCE_DIR}/include"
  65 +)
  66 +
  67 +file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/libonnxruntime*")
  68 +message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")
  69 +install(FILES ${onnxruntime_lib_files} DESTINATION lib)
  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 +
  5 +if(NOT CMAKE_SYSTEM_NAME STREQUAL Linux)
  6 + message(FATAL_ERROR "This file is for Linux only. Given: ${CMAKE_SYSTEM_NAME}")
  7 +endif()
  8 +
  9 +if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64)
  10 + message(FATAL_ERROR "This file is for x86_64 only. Given: ${CMAKE_SYSTEM_PROCESSOR}")
  11 +endif()
  12 +
  13 +if(NOT BUILD_SHARED_LIBS)
  14 + message(FATAL_ERROR "This file is for building shared libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}")
  15 +endif()
  16 +
  17 +if(NOT SHERPA_ONNX_ENABLE_GPU)
  18 + message(FATAL_ERROR "This file is for NVIDIA GPU only. Given SHERPA_ONNX_ENABLE_GPU: ${SHERPA_ONNX_ENABLE_GPU}")
  19 +endif()
  20 +
  21 +set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.15.1/onnxruntime-linux-x64-gpu-1.15.1.tgz")
  22 +set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/onnxruntime-linux-x64-gpu-1.15.1.tgz")
  23 +set(onnxruntime_HASH "SHA256=eab891393025edd5818d1aa26a42860e5739fcc49e3ca3f876110ec8736fe7f1")
  24 +
  25 +# If you don't have access to the Internet,
  26 +# please download onnxruntime to one of the following locations.
  27 +# You can add more if you want.
  28 +set(possible_file_locations
  29 + $ENV{HOME}/Downloads/onnxruntime-linux-x64-gpu-1.15.1.tgz
  30 + ${PROJECT_SOURCE_DIR}/onnxruntime-linux-x64-gpu-1.15.1.tgz
  31 + ${PROJECT_BINARY_DIR}/onnxruntime-linux-x64-gpu-1.15.1.tgz
  32 + /tmp/onnxruntime-linux-x64-gpu-1.15.1.tgz
  33 + /star-fj/fangjun/download/github/onnxruntime-linux-x64-gpu-1.15.1.tgz
  34 +)
  35 +
  36 +foreach(f IN LISTS possible_file_locations)
  37 + if(EXISTS ${f})
  38 + set(onnxruntime_URL "${f}")
  39 + file(TO_CMAKE_PATH "${onnxruntime_URL}" onnxruntime_URL)
  40 + message(STATUS "Found local downloaded onnxruntime: ${onnxruntime_URL}")
  41 + set(onnxruntime_URL2)
  42 + break()
  43 + endif()
  44 +endforeach()
  45 +
  46 +FetchContent_Declare(onnxruntime
  47 + URL
  48 + ${onnxruntime_URL}
  49 + ${onnxruntime_URL2}
  50 + URL_HASH ${onnxruntime_HASH}
  51 +)
  52 +
  53 +FetchContent_GetProperties(onnxruntime)
  54 +if(NOT onnxruntime_POPULATED)
  55 + message(STATUS "Downloading onnxruntime from ${onnxruntime_URL}")
  56 + FetchContent_Populate(onnxruntime)
  57 +endif()
  58 +message(STATUS "onnxruntime is downloaded to ${onnxruntime_SOURCE_DIR}")
  59 +
  60 +find_library(location_onnxruntime onnxruntime
  61 + PATHS
  62 + "${onnxruntime_SOURCE_DIR}/lib"
  63 + NO_CMAKE_SYSTEM_PATH
  64 +)
  65 +
  66 +message(STATUS "location_onnxruntime: ${location_onnxruntime}")
  67 +
  68 +add_library(onnxruntime SHARED IMPORTED)
  69 +
  70 +set_target_properties(onnxruntime PROPERTIES
  71 + IMPORTED_LOCATION ${location_onnxruntime}
  72 + INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_SOURCE_DIR}/include"
  73 +)
  74 +
  75 +find_library(location_onnxruntime_cuda_lib onnxruntime_providers_cuda
  76 + PATHS
  77 + "${onnxruntime_SOURCE_DIR}/lib"
  78 + NO_CMAKE_SYSTEM_PATH
  79 +)
  80 +
  81 +add_library(onnxruntime_providers_cuda SHARED IMPORTED)
  82 +set_target_properties(onnxruntime_providers_cuda PROPERTIES
  83 + IMPORTED_LOCATION ${location_onnxruntime_cuda_lib}
  84 +)
  85 +
  86 +file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/libonnxruntime*")
  87 +message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")
  88 +install(FILES ${onnxruntime_lib_files} DESTINATION lib)
  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 +
  5 +if(NOT CMAKE_SYSTEM_NAME STREQUAL Linux)
  6 + message(FATAL_ERROR "This file is for Linux only. Given: ${CMAKE_SYSTEM_NAME}")
  7 +endif()
  8 +
  9 +if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64)
  10 + message(FATAL_ERROR "This file is for x86_64 only. Given: ${CMAKE_SYSTEM_PROCESSOR}")
  11 +endif()
  12 +
  13 +set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.15.1/onnxruntime-linux-x64-1.15.1.tgz")
  14 +set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/onnxruntime-linux-x64-1.15.1.tgz")
  15 +set(onnxruntime_HASH "SHA256=5492f9065f87538a286fb04c8542e9ff7950abb2ea6f8c24993a940006787d87")
  16 +
  17 +# If you don't have access to the Internet,
  18 +# please download onnxruntime to one of the following locations.
  19 +# You can add more if you want.
  20 +set(possible_file_locations
  21 + $ENV{HOME}/Downloads/onnxruntime-linux-x64-1.15.1.tgz
  22 + ${PROJECT_SOURCE_DIR}/onnxruntime-linux-x64-1.15.1.tgz
  23 + ${PROJECT_BINARY_DIR}/onnxruntime-linux-x64-1.15.1.tgz
  24 + /tmp/onnxruntime-linux-x64-1.15.1.tgz
  25 + /star-fj/fangjun/download/github/onnxruntime-linux-x64-1.15.1.tgz
  26 +)
  27 +
  28 +foreach(f IN LISTS possible_file_locations)
  29 + if(EXISTS ${f})
  30 + set(onnxruntime_URL "${f}")
  31 + file(TO_CMAKE_PATH "${onnxruntime_URL}" onnxruntime_URL)
  32 + message(STATUS "Found local downloaded onnxruntime: ${onnxruntime_URL}")
  33 + set(onnxruntime_URL2)
  34 + break()
  35 + endif()
  36 +endforeach()
  37 +
  38 +FetchContent_Declare(onnxruntime
  39 + URL
  40 + ${onnxruntime_URL}
  41 + ${onnxruntime_URL2}
  42 + URL_HASH ${onnxruntime_HASH}
  43 +)
  44 +
  45 +FetchContent_GetProperties(onnxruntime)
  46 +if(NOT onnxruntime_POPULATED)
  47 + message(STATUS "Downloading onnxruntime from ${onnxruntime_URL}")
  48 + FetchContent_Populate(onnxruntime)
  49 +endif()
  50 +message(STATUS "onnxruntime is downloaded to ${onnxruntime_SOURCE_DIR}")
  51 +
  52 +find_library(location_onnxruntime onnxruntime
  53 + PATHS
  54 + "${onnxruntime_SOURCE_DIR}/lib"
  55 + NO_CMAKE_SYSTEM_PATH
  56 +)
  57 +
  58 +message(STATUS "location_onnxruntime: ${location_onnxruntime}")
  59 +
  60 +add_library(onnxruntime SHARED IMPORTED)
  61 +
  62 +set_target_properties(onnxruntime PROPERTIES
  63 + IMPORTED_LOCATION ${location_onnxruntime}
  64 + INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_SOURCE_DIR}/include"
  65 +)
  66 +
  67 +file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/libonnxruntime*")
  68 +message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")
  69 +install(FILES ${onnxruntime_lib_files} DESTINATION lib)
  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_VS_PLATFORM_NAME: ${CMAKE_VS_PLATFORM_NAME}")
  5 +
  6 +if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
  7 + message(FATAL_ERROR "This file is for Windows only. Given: ${CMAKE_SYSTEM_NAME}")
  8 +endif()
  9 +
  10 +if(NOT (CMAKE_VS_PLATFORM_NAME STREQUAL X64 OR CMAKE_VS_PLATFORM_NAME STREQUAL x64))
  11 + message(FATAL_ERROR "This file is for Windows x64 only. Given: ${CMAKE_VS_PLATFORM_NAME}")
  12 +endif()
  13 +
  14 +if(NOT BUILD_SHARED_LIBS)
  15 + message(FATAL_ERROR "This file is for building shared libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}")
  16 +endif()
  17 +
  18 +if(NOT SHERPA_ONNX_ENABLE_GPU)
  19 + message(FATAL_ERROR "This file is for NVIDIA GPU only. Given SHERPA_ONNX_ENABLE_GPU: ${SHERPA_ONNX_ENABLE_GPU}")
  20 +endif()
  21 +
  22 +set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.15.1/onnxruntime-win-x64-gpu-1.15.1.zip")
  23 +set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/onnxruntime-win-x64-gpu-1.15.1.zip")
  24 +set(onnxruntime_HASH "SHA256=dcc3a385b415dd2e4a813018b71da5085d9b97774552edf17947826a255a3732")
  25 +
  26 +# If you don't have access to the Internet,
  27 +# please download onnxruntime to one of the following locations.
  28 +# You can add more if you want.
  29 +set(possible_file_locations
  30 + $ENV{HOME}/Downloads/onnxruntime-win-x64-gpu-1.15.1.zip
  31 + ${PROJECT_SOURCE_DIR}/onnxruntime-win-x64-gpu-1.15.1.zip
  32 + ${PROJECT_BINARY_DIR}/onnxruntime-win-x64-gpu-1.15.1.zip
  33 + /tmp/onnxruntime-win-x64-gpu-1.15.1.zip
  34 +)
  35 +
  36 +foreach(f IN LISTS possible_file_locations)
  37 + if(EXISTS ${f})
  38 + set(onnxruntime_URL "${f}")
  39 + file(TO_CMAKE_PATH "${onnxruntime_URL}" onnxruntime_URL)
  40 + message(STATUS "Found local downloaded onnxruntime: ${onnxruntime_URL}")
  41 + set(onnxruntime_URL2)
  42 + break()
  43 + endif()
  44 +endforeach()
  45 +
  46 +FetchContent_Declare(onnxruntime
  47 + URL
  48 + ${onnxruntime_URL}
  49 + ${onnxruntime_URL2}
  50 + URL_HASH ${onnxruntime_HASH}
  51 +)
  52 +
  53 +FetchContent_GetProperties(onnxruntime)
  54 +if(NOT onnxruntime_POPULATED)
  55 + message(STATUS "Downloading onnxruntime from ${onnxruntime_URL}")
  56 + FetchContent_Populate(onnxruntime)
  57 +endif()
  58 +message(STATUS "onnxruntime is downloaded to ${onnxruntime_SOURCE_DIR}")
  59 +
  60 +find_library(location_onnxruntime onnxruntime
  61 + PATHS
  62 + "${onnxruntime_SOURCE_DIR}/lib"
  63 + NO_CMAKE_SYSTEM_PATH
  64 +)
  65 +
  66 +message(STATUS "location_onnxruntime: ${location_onnxruntime}")
  67 +
  68 +add_library(onnxruntime SHARED IMPORTED)
  69 +
  70 +set_target_properties(onnxruntime PROPERTIES
  71 + IMPORTED_LOCATION ${location_onnxruntime}
  72 + INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_SOURCE_DIR}/include"
  73 +)
  74 +
  75 +set_property(TARGET onnxruntime
  76 + PROPERTY
  77 + IMPORTED_IMPLIB "${onnxruntime_SOURCE_DIR}/lib/onnxruntime.lib"
  78 +)
  79 +
  80 +file(COPY ${onnxruntime_SOURCE_DIR}/lib/onnxruntime.dll
  81 + DESTINATION
  82 + ${CMAKE_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}
  83 +)
  84 +
  85 +add_library(onnxruntime_providers_cuda SHARED IMPORTED)
  86 +set_target_properties(onnxruntime_providers_cuda PROPERTIES
  87 + IMPORTED_LOCATION ${location_onnxruntime}
  88 + INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_SOURCE_DIR}/include"
  89 +)
  90 +
  91 +set_property(TARGET onnxruntime_providers_cuda
  92 + PROPERTY
  93 + IMPORTED_IMPLIB "${onnxruntime_SOURCE_DIR}/lib/onnxruntime_providers_cuda.lib"
  94 +)
  95 +
  96 +file(COPY ${onnxruntime_SOURCE_DIR}/lib/onnxruntime_providers_cuda.dll
  97 + DESTINATION
  98 + ${CMAKE_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}
  99 +)
  100 +
  101 +file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/*.dll")
  102 +
  103 +message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")
  104 +
  105 +if(SHERPA_ONNX_ENABLE_PYTHON)
  106 + install(FILES ${onnxruntime_lib_files} DESTINATION ..)
  107 +else()
  108 + install(FILES ${onnxruntime_lib_files} DESTINATION lib)
  109 +endif()
  110 +
  111 +install(FILES ${onnxruntime_lib_files} DESTINATION bin)
  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_VS_PLATFORM_NAME: ${CMAKE_VS_PLATFORM_NAME}")
  5 +
  6 +if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
  7 + message(FATAL_ERROR "This file is for Windows only. Given: ${CMAKE_SYSTEM_NAME}")
  8 +endif()
  9 +
  10 +if(NOT (CMAKE_VS_PLATFORM_NAME STREQUAL X64 OR CMAKE_VS_PLATFORM_NAME STREQUAL x64))
  11 + message(FATAL_ERROR "This file is for Windows x64 only. Given: ${CMAKE_VS_PLATFORM_NAME}")
  12 +endif()
  13 +
  14 +if(BUILD_SHARED_LIBS)
  15 + message(FATAL_ERROR "This file is for building static libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}")
  16 +endif()
  17 +
  18 +set(onnxruntime_URL "https://huggingface.co/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-win-x64-static-1.15.1.tar.bz2")
  19 +set(onnxruntime_URL2 "")
  20 +set(onnxruntime_HASH "SHA256=c809a8510a89b8b37ae7d563c39229db22bac8fbefcbfe5c81a60b367d065b1b")
  21 +
  22 +# If you don't have access to the Internet,
  23 +# please download onnxruntime to one of the following locations.
  24 +# You can add more if you want.
  25 +set(possible_file_locations
  26 + $ENV{HOME}/Downloads/onnxruntime-win-x64-static-1.15.1.tar.bz2
  27 + ${PROJECT_SOURCE_DIR}/onnxruntime-win-x64-static-1.15.1.tar.bz2
  28 + ${PROJECT_BINARY_DIR}/onnxruntime-win-x64-static-1.15.1.tar.bz2
  29 + /tmp/onnxruntime-win-x64-static-1.15.1.tar.bz2
  30 +)
  31 +
  32 +foreach(f IN LISTS possible_file_locations)
  33 + if(EXISTS ${f})
  34 + set(onnxruntime_URL "${f}")
  35 + file(TO_CMAKE_PATH "${onnxruntime_URL}" onnxruntime_URL)
  36 + message(STATUS "Found local downloaded onnxruntime: ${onnxruntime_URL}")
  37 + set(onnxruntime_URL2)
  38 + break()
  39 + endif()
  40 +endforeach()
  41 +
  42 +FetchContent_Declare(onnxruntime
  43 + URL
  44 + ${onnxruntime_URL}
  45 + ${onnxruntime_URL2}
  46 + URL_HASH ${onnxruntime_HASH}
  47 +)
  48 +
  49 +FetchContent_GetProperties(onnxruntime)
  50 +if(NOT onnxruntime_POPULATED)
  51 + message(STATUS "Downloading onnxruntime from ${onnxruntime_URL}")
  52 + FetchContent_Populate(onnxruntime)
  53 +endif()
  54 +message(STATUS "onnxruntime is downloaded to ${onnxruntime_SOURCE_DIR}")
  55 +
  56 +# for static libraries, we use onnxruntime_lib_files directly below
  57 +include_directories(${onnxruntime_SOURCE_DIR}/include)
  58 +
  59 +file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/*.lib")
  60 +set(onnxruntime_lib_files ${onnxruntime_lib_files} PARENT_SCOPE)
  61 +
  62 +message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")
  63 +if(SHERPA_ONNX_ENABLE_PYTHON)
  64 + install(FILES ${onnxruntime_lib_files} DESTINATION ..)
  65 +else()
  66 + install(FILES ${onnxruntime_lib_files} DESTINATION lib)
  67 +endif()
  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_VS_PLATFORM_NAME: ${CMAKE_VS_PLATFORM_NAME}")
  5 +
  6 +if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
  7 + message(FATAL_ERROR "This file is for Windows only. Given: ${CMAKE_SYSTEM_NAME}")
  8 +endif()
  9 +
  10 +if(NOT (CMAKE_VS_PLATFORM_NAME STREQUAL X64 OR CMAKE_VS_PLATFORM_NAME STREQUAL x64))
  11 + message(FATAL_ERROR "This file is for Windows x64 only. Given: ${CMAKE_VS_PLATFORM_NAME}")
  12 +endif()
  13 +
  14 +if(NOT BUILD_SHARED_LIBS)
  15 + message(FATAL_ERROR "This file is for building shared libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}")
  16 +endif()
  17 +
  18 +set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.15.1/onnxruntime-win-x64-1.15.1.zip")
  19 +set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/onnxruntime-win-x64-1.15.1.zip")
  20 +set(onnxruntime_HASH "SHA256=261308ee5526dfd3f405ce8863e43d624a2e0bcd16b2d33cdea8c120ab3534d3")
  21 +
  22 +# If you don't have access to the Internet,
  23 +# please download onnxruntime to one of the following locations.
  24 +# You can add more if you want.
  25 +set(possible_file_locations
  26 + $ENV{HOME}/Downloads/onnxruntime-win-x64-1.15.1.zip
  27 + ${PROJECT_SOURCE_DIR}/onnxruntime-win-x64-1.15.1.zip
  28 + ${PROJECT_BINARY_DIR}/onnxruntime-win-x64-1.15.1.zip
  29 + /tmp/onnxruntime-win-x64-1.15.1.zip
  30 +)
  31 +
  32 +foreach(f IN LISTS possible_file_locations)
  33 + if(EXISTS ${f})
  34 + set(onnxruntime_URL "${f}")
  35 + file(TO_CMAKE_PATH "${onnxruntime_URL}" onnxruntime_URL)
  36 + message(STATUS "Found local downloaded onnxruntime: ${onnxruntime_URL}")
  37 + set(onnxruntime_URL2)
  38 + break()
  39 + endif()
  40 +endforeach()
  41 +
  42 +FetchContent_Declare(onnxruntime
  43 + URL
  44 + ${onnxruntime_URL}
  45 + ${onnxruntime_URL2}
  46 + URL_HASH ${onnxruntime_HASH}
  47 +)
  48 +
  49 +FetchContent_GetProperties(onnxruntime)
  50 +if(NOT onnxruntime_POPULATED)
  51 + message(STATUS "Downloading onnxruntime from ${onnxruntime_URL}")
  52 + FetchContent_Populate(onnxruntime)
  53 +endif()
  54 +message(STATUS "onnxruntime is downloaded to ${onnxruntime_SOURCE_DIR}")
  55 +
  56 +find_library(location_onnxruntime onnxruntime
  57 + PATHS
  58 + "${onnxruntime_SOURCE_DIR}/lib"
  59 + NO_CMAKE_SYSTEM_PATH
  60 +)
  61 +
  62 +message(STATUS "location_onnxruntime: ${location_onnxruntime}")
  63 +
  64 +add_library(onnxruntime SHARED IMPORTED)
  65 +
  66 +set_target_properties(onnxruntime PROPERTIES
  67 + IMPORTED_LOCATION ${location_onnxruntime}
  68 + INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_SOURCE_DIR}/include"
  69 +)
  70 +
  71 +set_property(TARGET onnxruntime
  72 + PROPERTY
  73 + IMPORTED_IMPLIB "${onnxruntime_SOURCE_DIR}/lib/onnxruntime.lib"
  74 +)
  75 +
  76 +file(COPY ${onnxruntime_SOURCE_DIR}/lib/onnxruntime.dll
  77 + DESTINATION
  78 + ${CMAKE_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}
  79 +)
  80 +
  81 +file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/*.dll")
  82 +
  83 +message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")
  84 +
  85 +if(SHERPA_ONNX_ENABLE_PYTHON)
  86 + install(FILES ${onnxruntime_lib_files} DESTINATION ..)
  87 +else()
  88 + install(FILES ${onnxruntime_lib_files} DESTINATION lib)
  89 +endif()
  90 +
  91 +install(FILES ${onnxruntime_lib_files} DESTINATION bin)
  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_VS_PLATFORM_NAME: ${CMAKE_VS_PLATFORM_NAME}")
  5 +
  6 +if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
  7 + message(FATAL_ERROR "This file is for Windows only. Given: ${CMAKE_SYSTEM_NAME}")
  8 +endif()
  9 +
  10 +if(NOT (CMAKE_VS_PLATFORM_NAME STREQUAL Win32 OR CMAKE_VS_PLATFORM_NAME STREQUAL win32))
  11 + message(FATAL_ERROR "This file is for Windows x86 only. Given: ${CMAKE_VS_PLATFORM_NAME}")
  12 +endif()
  13 +
  14 +if(BUILD_SHARED_LIBS)
  15 + message(FATAL_ERROR "This file is for building static libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}")
  16 +endif()
  17 +
  18 +set(onnxruntime_URL "https://huggingface.co/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-win-x86-static-1.15.1.tar.bz2")
  19 +set(onnxruntime_URL2 "")
  20 +set(onnxruntime_HASH "SHA256=94d9a30976b5c4a5dff7508d00f141835916e5a36315d5f53be9b3edb85148b5")
  21 +
  22 +# If you don't have access to the Internet,
  23 +# please download onnxruntime to one of the following locations.
  24 +# You can add more if you want.
  25 +set(possible_file_locations
  26 + $ENV{HOME}/Downloads/onnxruntime-win-x86-static-1.15.1.tar.bz2
  27 + ${PROJECT_SOURCE_DIR}/onnxruntime-win-x86-static-1.15.1.tar.bz2
  28 + ${PROJECT_BINARY_DIR}/onnxruntime-win-x86-static-1.15.1.tar.bz2
  29 + /tmp/onnxruntime-win-x86-static-1.15.1.tar.bz2
  30 +)
  31 +
  32 +foreach(f IN LISTS possible_file_locations)
  33 + if(EXISTS ${f})
  34 + set(onnxruntime_URL "${f}")
  35 + file(TO_CMAKE_PATH "${onnxruntime_URL}" onnxruntime_URL)
  36 + message(STATUS "Found local downloaded onnxruntime: ${onnxruntime_URL}")
  37 + set(onnxruntime_URL2)
  38 + break()
  39 + endif()
  40 +endforeach()
  41 +
  42 +FetchContent_Declare(onnxruntime
  43 + URL
  44 + ${onnxruntime_URL}
  45 + ${onnxruntime_URL2}
  46 + URL_HASH ${onnxruntime_HASH}
  47 +)
  48 +
  49 +FetchContent_GetProperties(onnxruntime)
  50 +if(NOT onnxruntime_POPULATED)
  51 + message(STATUS "Downloading onnxruntime from ${onnxruntime_URL}")
  52 + FetchContent_Populate(onnxruntime)
  53 +endif()
  54 +message(STATUS "onnxruntime is downloaded to ${onnxruntime_SOURCE_DIR}")
  55 +
  56 +# for static libraries, we use onnxruntime_lib_files directly below
  57 +include_directories(${onnxruntime_SOURCE_DIR}/include)
  58 +
  59 +file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/*.lib")
  60 +set(onnxruntime_lib_files ${onnxruntime_lib_files} PARENT_SCOPE)
  61 +
  62 +message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")
  63 +if(SHERPA_ONNX_ENABLE_PYTHON)
  64 + install(FILES ${onnxruntime_lib_files} DESTINATION ..)
  65 +else()
  66 + install(FILES ${onnxruntime_lib_files} DESTINATION lib)
  67 +endif()
  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_VS_PLATFORM_NAME: ${CMAKE_VS_PLATFORM_NAME}")
  5 +
  6 +if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
  7 + message(FATAL_ERROR "This file is for Windows only. Given: ${CMAKE_SYSTEM_NAME}")
  8 +endif()
  9 +
  10 +if(NOT (CMAKE_VS_PLATFORM_NAME STREQUAL Win32 OR CMAKE_VS_PLATFORM_NAME STREQUAL win32))
  11 + message(FATAL_ERROR "This file is for Windows x86 only. Given: ${CMAKE_VS_PLATFORM_NAME}")
  12 +endif()
  13 +
  14 +if(NOT BUILD_SHARED_LIBS)
  15 + message(FATAL_ERROR "This file is for building shared libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}")
  16 +endif()
  17 +
  18 +set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.15.1/onnxruntime-win-x86-1.15.1.zip")
  19 +set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/onnxruntime-win-x86-1.15.1.zip")
  20 +set(onnxruntime_HASH "SHA256=8de18fdf274a8adcd95272fcf58beda0fe2fb37f0cd62c02bc4bb6200429e4e2")
  21 +
  22 +# If you don't have access to the Internet,
  23 +# please download onnxruntime to one of the following locations.
  24 +# You can add more if you want.
  25 +set(possible_file_locations
  26 + $ENV{HOME}/Downloads/onnxruntime-win-x86-1.15.1.zip
  27 + ${PROJECT_SOURCE_DIR}/onnxruntime-win-x86-1.15.1.zip
  28 + ${PROJECT_BINARY_DIR}/onnxruntime-win-x86-1.15.1.zip
  29 + /tmp/onnxruntime-win-x86-1.15.1.zip
  30 +)
  31 +
  32 +foreach(f IN LISTS possible_file_locations)
  33 + if(EXISTS ${f})
  34 + set(onnxruntime_URL "${f}")
  35 + file(TO_CMAKE_PATH "${onnxruntime_URL}" onnxruntime_URL)
  36 + message(STATUS "Found local downloaded onnxruntime: ${onnxruntime_URL}")
  37 + set(onnxruntime_URL2)
  38 + break()
  39 + endif()
  40 +endforeach()
  41 +
  42 +FetchContent_Declare(onnxruntime
  43 + URL
  44 + ${onnxruntime_URL}
  45 + ${onnxruntime_URL2}
  46 + URL_HASH ${onnxruntime_HASH}
  47 +)
  48 +
  49 +FetchContent_GetProperties(onnxruntime)
  50 +if(NOT onnxruntime_POPULATED)
  51 + message(STATUS "Downloading onnxruntime from ${onnxruntime_URL}")
  52 + FetchContent_Populate(onnxruntime)
  53 +endif()
  54 +message(STATUS "onnxruntime is downloaded to ${onnxruntime_SOURCE_DIR}")
  55 +
  56 +find_library(location_onnxruntime onnxruntime
  57 + PATHS
  58 + "${onnxruntime_SOURCE_DIR}/lib"
  59 + NO_CMAKE_SYSTEM_PATH
  60 +)
  61 +
  62 +message(STATUS "location_onnxruntime: ${location_onnxruntime}")
  63 +
  64 +add_library(onnxruntime SHARED IMPORTED)
  65 +
  66 +set_target_properties(onnxruntime PROPERTIES
  67 + IMPORTED_LOCATION ${location_onnxruntime}
  68 + INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_SOURCE_DIR}/include"
  69 +)
  70 +
  71 +set_property(TARGET onnxruntime
  72 + PROPERTY
  73 + IMPORTED_IMPLIB "${onnxruntime_SOURCE_DIR}/lib/onnxruntime.lib"
  74 +)
  75 +
  76 +file(COPY ${onnxruntime_SOURCE_DIR}/lib/onnxruntime.dll
  77 + DESTINATION
  78 + ${CMAKE_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}
  79 +)
  80 +
  81 +file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/*.dll")
  82 +
  83 +message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")
  84 +
  85 +if(SHERPA_ONNX_ENABLE_PYTHON)
  86 + install(FILES ${onnxruntime_lib_files} DESTINATION ..)
  87 +else()
  88 + install(FILES ${onnxruntime_lib_files} DESTINATION lib)
  89 +endif()
  90 +
  91 +install(FILES ${onnxruntime_lib_files} DESTINATION bin)
  1 +# Copyright (c) 2022-2023 Xiaomi Corporation
1 function(download_onnxruntime) 2 function(download_onnxruntime)
2 include(FetchContent) 3 include(FetchContent)
3 4
@@ -5,115 +6,33 @@ function(download_onnxruntime) @@ -5,115 +6,33 @@ function(download_onnxruntime)
5 message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}") 6 message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
6 7
7 if(CMAKE_SYSTEM_NAME STREQUAL Linux AND CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64) 8 if(CMAKE_SYSTEM_NAME STREQUAL Linux AND CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64)
8 - # For embedded systems  
9 - set(possible_file_locations  
10 - $ENV{HOME}/Downloads/onnxruntime-linux-aarch64-1.15.1.tgz  
11 - ${PROJECT_SOURCE_DIR}/onnxruntime-linux-aarch64-1.15.1.tgz  
12 - ${PROJECT_BINARY_DIR}/onnxruntime-linux-aarch64-1.15.1.tgz  
13 - /tmp/onnxruntime-linux-aarch64-1.15.1.tgz  
14 - /star-fj/fangjun/download/github/onnxruntime-linux-aarch64-1.15.1.tgz  
15 - )  
16 - set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.15.1/onnxruntime-linux-aarch64-1.15.1.tgz")  
17 - set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/onnxruntime-linux-aarch64-1.15.1.tgz")  
18 - set(onnxruntime_HASH "SHA256=85272e75d8dd841138de4b774a9672ea93c1be108d96038c6c34a62d7f976aee") 9 + include(onnxruntime-linux-aarch64)
19 elseif(CMAKE_SYSTEM_NAME STREQUAL Linux AND CMAKE_SYSTEM_PROCESSOR STREQUAL arm) 10 elseif(CMAKE_SYSTEM_NAME STREQUAL Linux AND CMAKE_SYSTEM_PROCESSOR STREQUAL arm)
20 - # For embedded systems  
21 - set(possible_file_locations  
22 - $ENV{HOME}/Downloads/onnxruntime-linux-arm-1.15.1.zip  
23 - ${PROJECT_SOURCE_DIR}/onnxruntime-linux-arm-1.15.1.zip  
24 - ${PROJECT_BINARY_DIR}/onnxruntime-linux-arm-1.15.1.zip  
25 - /tmp/onnxruntime-linux-arm-1.15.1.zip  
26 - /star-fj/fangjun/download/github/onnxruntime-linux-arm-1.15.1.zip  
27 - )  
28 - set(onnxruntime_URL "https://huggingface.co/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-linux-arm-1.15.1.zip")  
29 - set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/onnxruntime-linux-arm-1.15.1.zip")  
30 - set(onnxruntime_HASH "SHA256=867b96210a347e4b1bb949e7c9a3f222371ea0c00c9deaaba9fdd66c689f7fb7") 11 + include(onnxruntime-linux-arm)
31 elseif(CMAKE_SYSTEM_NAME STREQUAL Linux AND CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64) 12 elseif(CMAKE_SYSTEM_NAME STREQUAL Linux AND CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64)
32 - # If you don't have access to the Internet,  
33 - # please pre-download onnxruntime  
34 - set(possible_file_locations  
35 - $ENV{HOME}/Downloads/onnxruntime-linux-x64-1.15.1.tgz  
36 - ${PROJECT_SOURCE_DIR}/onnxruntime-linux-x64-1.15.1.tgz  
37 - ${PROJECT_BINARY_DIR}/onnxruntime-linux-x64-1.15.1.tgz  
38 - /tmp/onnxruntime-linux-x64-1.15.1.tgz  
39 - /star-fj/fangjun/download/github/onnxruntime-linux-x64-1.15.1.tgz  
40 - )  
41 -  
42 - set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.15.1/onnxruntime-linux-x64-1.15.1.tgz")  
43 - set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/onnxruntime-linux-x64-1.15.1.tgz")  
44 - set(onnxruntime_HASH "SHA256=5492f9065f87538a286fb04c8542e9ff7950abb2ea6f8c24993a940006787d87")  
45 - # After downloading, it contains:  
46 - # ./lib/libonnxruntime.so.1.15.1  
47 - # ./lib/libonnxruntime.so, which is a symlink to lib/libonnxruntime.so.1.15.1  
48 - #  
49 - # ./include  
50 - # It contains all the needed header files  
51 if(SHERPA_ONNX_ENABLE_GPU) 13 if(SHERPA_ONNX_ENABLE_GPU)
52 - set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.15.1/onnxruntime-linux-x64-gpu-1.15.1.tgz")  
53 - set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/onnxruntime-linux-x64-gpu-1.15.1.tgz")  
54 - set(onnxruntime_HASH "SHA256=eab891393025edd5818d1aa26a42860e5739fcc49e3ca3f876110ec8736fe7f1")  
55 -  
56 - set(possible_file_locations  
57 - $ENV{HOME}/Downloads/onnxruntime-linux-x64-gpu-1.15.1.tgz  
58 - ${PROJECT_SOURCE_DIR}/onnxruntime-linux-x64-gpu-1.15.1.tgz  
59 - ${PROJECT_BINARY_DIR}/onnxruntime-linux-x64-gpu-1.15.1.tgz  
60 - /tmp/onnxruntime-linux-x64-gpu-1.15.1.tgz  
61 - /star-fj/fangjun/download/github/onnxruntime-linux-x64-gpu-1.15.1.tgz  
62 - ) 14 + include(onnxruntime-linux-x86_64-gpu)
  15 + else()
  16 + include(onnxruntime-linux-x86_64)
  17 + endif()
  18 + elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
  19 + if (arm64 IN_LIST CMAKE_OSX_ARCHITECTURES OR x86_64 IN_LIST CMAKE_OSX_ARCHITECTURES)
  20 + include(onnxruntime-darwin-universal)
  21 + elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64)
  22 + include(onnxruntime-darwin-x86_64)
  23 + elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL arm64)
  24 + include(onnxruntime-darwin-arm64)
  25 + else()
  26 + message(FATAL_ERROR "Unsupport processor {CMAKE_SYSTEM_PROCESSOR} for Darwin")
63 endif() 27 endif()
64 - # After downloading, it contains:  
65 - # ./lib/libonnxruntime.so.1.15.1  
66 - # ./lib/libonnxruntime.so, which is a symlink to lib/libonnxruntime.so.1.15.1  
67 - # ./lib/libonnxruntime_providers_cuda.so  
68 - # ./include, which contains all the needed header files  
69 - elseif(APPLE)  
70 - # If you don't have access to the Internet,  
71 - # please pre-download onnxruntime  
72 - set(possible_file_locations  
73 - $ENV{HOME}/Downloads/onnxruntime-osx-universal2-1.15.1.tgz  
74 - ${PROJECT_SOURCE_DIR}/onnxruntime-osx-universal2-1.15.1.tgz  
75 - ${PROJECT_BINARY_DIR}/onnxruntime-osx-universal2-1.15.1.tgz  
76 - /tmp/onnxruntime-osx-universal2-1.15.1.tgz  
77 - )  
78 - set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.15.1/onnxruntime-osx-universal2-1.15.1.tgz")  
79 - set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/onnxruntime-osx-universal2-1.15.1.tgz")  
80 - set(onnxruntime_HASH "SHA256=ecb7651c216fe6ffaf4c578e135d98341bc5bc944c5dc6b725ef85b0d7747be0")  
81 - # After downloading, it contains:  
82 - # ./lib/libonnxruntime.1.15.1.dylib  
83 - # ./lib/libonnxruntime.dylib, which is a symlink to lib/libonnxruntime.1.15.1.dylib  
84 - #  
85 - # ./include  
86 - # It contains all the needed header files  
87 elseif(WIN32) 28 elseif(WIN32)
88 message(STATUS "CMAKE_VS_PLATFORM_NAME: ${CMAKE_VS_PLATFORM_NAME}") 29 message(STATUS "CMAKE_VS_PLATFORM_NAME: ${CMAKE_VS_PLATFORM_NAME}")
89 30
90 if(CMAKE_VS_PLATFORM_NAME STREQUAL Win32 OR CMAKE_VS_PLATFORM_NAME STREQUAL win32) 31 if(CMAKE_VS_PLATFORM_NAME STREQUAL Win32 OR CMAKE_VS_PLATFORM_NAME STREQUAL win32)
91 if(BUILD_SHARED_LIBS) 32 if(BUILD_SHARED_LIBS)
92 - # If you don't have access to the Internet,  
93 - # please pre-download onnxruntime  
94 - #  
95 - # for 32-bit windows  
96 - set(possible_file_locations  
97 - $ENV{HOME}/Downloads/onnxruntime-win-x86-1.15.1.zip  
98 - ${PROJECT_SOURCE_DIR}/onnxruntime-win-x86-1.15.1.zip  
99 - ${PROJECT_BINARY_DIR}/onnxruntime-win-x86-1.15.1.zip  
100 - /tmp/onnxruntime-win-x86-1.15.1.zip  
101 - )  
102 -  
103 - set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.15.1/onnxruntime-win-x86-1.15.1.zip")  
104 - set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/onnxruntime-win-x86-1.15.1.zip")  
105 - set(onnxruntime_HASH "SHA256=8de18fdf274a8adcd95272fcf58beda0fe2fb37f0cd62c02bc4bb6200429e4e2") 33 + include(onnxruntime-win-x86)
106 else() 34 else()
107 - set(possible_file_locations  
108 - $ENV{HOME}/Downloads/onnxruntime-win-x86-static-1.15.1.tar.bz2  
109 - ${PROJECT_SOURCE_DIR}/onnxruntime-win-x86-static-1.15.1.tar.bz2  
110 - ${PROJECT_BINARY_DIR}/onnxruntime-win-x86-static-1.15.1.tar.bz2  
111 - /tmp/onnxruntime-win-x86-static-1.15.1.tar.bz2  
112 - )  
113 -  
114 - set(onnxruntime_URL "https://huggingface.co/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-win-x86-static-1.15.1.tar.bz2")  
115 - set(onnxruntime_URL2 "")  
116 - set(onnxruntime_HASH "SHA256=94d9a30976b5c4a5dff7508d00f141835916e5a36315d5f53be9b3edb85148b5") 35 + include(onnxruntime-win-x86-static)
117 endif() 36 endif()
118 37
119 if(SHERPA_ONNX_ENABLE_GPU) 38 if(SHERPA_ONNX_ENABLE_GPU)
@@ -123,166 +42,22 @@ function(download_onnxruntime) @@ -123,166 +42,22 @@ function(download_onnxruntime)
123 # for 64-bit windows 42 # for 64-bit windows
124 43
125 if(BUILD_SHARED_LIBS) 44 if(BUILD_SHARED_LIBS)
126 - # If you don't have access to the Internet,  
127 - # please pre-download onnxruntime  
128 - set(possible_file_locations  
129 - $ENV{HOME}/Downloads/onnxruntime-win-x64-1.15.1.zip  
130 - ${PROJECT_SOURCE_DIR}/onnxruntime-win-x64-1.15.1.zip  
131 - ${PROJECT_BINARY_DIR}/onnxruntime-win-x64-1.15.1.zip  
132 - /tmp/onnxruntime-win-x64-1.15.1.zip  
133 - )  
134 -  
135 - set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.15.1/onnxruntime-win-x64-1.15.1.zip")  
136 - set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/onnxruntime-win-x64-1.15.1.zip")  
137 - set(onnxruntime_HASH "SHA256=261308ee5526dfd3f405ce8863e43d624a2e0bcd16b2d33cdea8c120ab3534d3")  
138 -  
139 if(SHERPA_ONNX_ENABLE_GPU) 45 if(SHERPA_ONNX_ENABLE_GPU)
140 - set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.15.1/onnxruntime-win-x64-gpu-1.15.1.zip")  
141 - set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/onnxruntime-win-x64-gpu-1.15.1.zip")  
142 - set(onnxruntime_HASH "SHA256=dcc3a385b415dd2e4a813018b71da5085d9b97774552edf17947826a255a3732")  
143 - set(possible_file_locations  
144 - $ENV{HOME}/Downloads/onnxruntime-win-x64-gpu-1.15.1.zip  
145 - ${PROJECT_SOURCE_DIR}/onnxruntime-win-x64-gpu-1.15.1.zip  
146 - ${PROJECT_BINARY_DIR}/onnxruntime-win-x64-gpu-1.15.1.zip  
147 - /tmp/onnxruntime-win-x64-gpu-1.15.1.zip  
148 - ) 46 + include(onnxruntime-win-x64-gpu)
  47 + else()
  48 + include(onnxruntime-win-x64)
149 endif() 49 endif()
150 else() 50 else()
151 # static libraries for windows x64 51 # static libraries for windows x64
152 message(STATUS "Use static onnxruntime libraries") 52 message(STATUS "Use static onnxruntime libraries")
153 - # If you don't have access to the Internet,  
154 - # please pre-download onnxruntime  
155 - set(possible_file_locations  
156 - $ENV{HOME}/Downloads/onnxruntime-win-x64-static-1.15.1.tar.bz2  
157 - ${PROJECT_SOURCE_DIR}/onnxruntime-win-x64-static-1.15.1.tar.bz2  
158 - ${PROJECT_BINARY_DIR}/onnxruntime-win-x64-static-1.15.1.tar.bz2  
159 - /tmp/onnxruntime-win-x64-static-1.15.1.tar.bz2  
160 - )  
161 -  
162 - set(onnxruntime_URL "https://huggingface.co/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-win-x64-static-1.15.1.tar.bz2")  
163 - set(onnxruntime_URL2 "")  
164 - set(onnxruntime_HASH "SHA256=c809a8510a89b8b37ae7d563c39229db22bac8fbefcbfe5c81a60b367d065b1b") 53 + include(onnxruntime-win-x64-static)
165 endif() 54 endif()
166 endif() 55 endif()
167 - # After downloading, it contains:  
168 - # ./lib/onnxruntime.{dll,lib,pdb}  
169 - # ./lib/onnxruntime_providers_shared.{dll,lib,pdb}  
170 - #  
171 - # ./include  
172 - # It contains all the needed header files  
173 else() 56 else()
174 message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}") 57 message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
175 message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}") 58 message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
176 message(FATAL_ERROR "Only support Linux, macOS, and Windows at present. Will support other OSes later") 59 message(FATAL_ERROR "Only support Linux, macOS, and Windows at present. Will support other OSes later")
177 endif() 60 endif()
178 -  
179 - foreach(f IN LISTS possible_file_locations)  
180 - if(EXISTS ${f})  
181 - set(onnxruntime_URL "${f}")  
182 - file(TO_CMAKE_PATH "${onnxruntime_URL}" onnxruntime_URL)  
183 - message(STATUS "Found local downloaded onnxruntime: ${onnxruntime_URL}")  
184 - set(onnxruntime_URL2)  
185 - break()  
186 - endif()  
187 - endforeach()  
188 -  
189 - FetchContent_Declare(onnxruntime  
190 - URL  
191 - ${onnxruntime_URL}  
192 - ${onnxruntime_URL2}  
193 - URL_HASH ${onnxruntime_HASH}  
194 - )  
195 -  
196 - FetchContent_GetProperties(onnxruntime)  
197 - if(NOT onnxruntime_POPULATED)  
198 - message(STATUS "Downloading onnxruntime from ${onnxruntime_URL}")  
199 - FetchContent_Populate(onnxruntime)  
200 - endif()  
201 - message(STATUS "onnxruntime is downloaded to ${onnxruntime_SOURCE_DIR}")  
202 -  
203 - if(BUILD_SHARED_LIBS OR NOT WIN32)  
204 - find_library(location_onnxruntime onnxruntime  
205 - PATHS  
206 - "${onnxruntime_SOURCE_DIR}/lib"  
207 - NO_CMAKE_SYSTEM_PATH  
208 - )  
209 -  
210 - message(STATUS "location_onnxruntime: ${location_onnxruntime}")  
211 -  
212 - add_library(onnxruntime SHARED IMPORTED)  
213 -  
214 - set_target_properties(onnxruntime PROPERTIES  
215 - IMPORTED_LOCATION ${location_onnxruntime}  
216 - INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_SOURCE_DIR}/include"  
217 - )  
218 - endif()  
219 -  
220 - if(SHERPA_ONNX_ENABLE_GPU AND NOT WIN32)  
221 - find_library(location_onnxruntime_cuda_lib onnxruntime_providers_cuda  
222 - PATHS  
223 - "${onnxruntime_SOURCE_DIR}/lib"  
224 - NO_CMAKE_SYSTEM_PATH  
225 - )  
226 - add_library(onnxruntime_providers_cuda SHARED IMPORTED)  
227 - set_target_properties(onnxruntime_providers_cuda PROPERTIES  
228 - IMPORTED_LOCATION ${location_onnxruntime_cuda_lib}  
229 - )  
230 - endif()  
231 -  
232 - if(WIN32)  
233 - if(BUILD_SHARED_LIBS)  
234 - set_property(TARGET onnxruntime  
235 - PROPERTY  
236 - IMPORTED_IMPLIB "${onnxruntime_SOURCE_DIR}/lib/onnxruntime.lib"  
237 - )  
238 -  
239 - file(COPY ${onnxruntime_SOURCE_DIR}/lib/onnxruntime.dll  
240 - DESTINATION  
241 - ${CMAKE_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}  
242 - )  
243 - if(SHERPA_ONNX_ENABLE_GPU)  
244 - add_library(onnxruntime_providers_cuda SHARED IMPORTED)  
245 -  
246 - set_target_properties(onnxruntime_providers_cuda PROPERTIES  
247 - IMPORTED_LOCATION ${location_onnxruntime}  
248 - INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_SOURCE_DIR}/include"  
249 - )  
250 -  
251 - set_property(TARGET onnxruntime_providers_cuda  
252 - PROPERTY  
253 - IMPORTED_IMPLIB "${onnxruntime_SOURCE_DIR}/lib/onnxruntime_providers_cuda.lib"  
254 - )  
255 -  
256 - file(COPY ${onnxruntime_SOURCE_DIR}/lib/onnxruntime_providers_cuda.dll  
257 - DESTINATION  
258 - ${CMAKE_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}  
259 - )  
260 - endif()  
261 - else()  
262 - # for static libraries, we use onnxruntime_lib_files directly below  
263 - include_directories(${onnxruntime_SOURCE_DIR}/include)  
264 - endif()  
265 - endif()  
266 -  
267 - if(UNIX AND NOT APPLE)  
268 - file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/lib*")  
269 - elseif(APPLE)  
270 - file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/libonnxruntime.*.*dylib")  
271 - elseif(WIN32)  
272 - if(BUILD_SHARED_LIBS)  
273 - file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/*.dll")  
274 - else()  
275 - file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/*.lib")  
276 - set(onnxruntime_lib_files ${onnxruntime_lib_files} PARENT_SCOPE)  
277 - endif()  
278 - endif()  
279 -  
280 - message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")  
281 - if(SHERPA_ONNX_ENABLE_PYTHON AND WIN32)  
282 - install(FILES ${onnxruntime_lib_files} DESTINATION ..)  
283 - else()  
284 - install(FILES ${onnxruntime_lib_files} DESTINATION lib)  
285 - endif()  
286 endfunction() 61 endfunction()
287 62
288 # First, we try to locate the header and the lib if the use has already 63 # First, we try to locate the header and the lib if the use has already
@@ -31,7 +31,7 @@ extern "C" { @@ -31,7 +31,7 @@ extern "C" {
31 #define SHERPA_ONNX_IMPORT 31 #define SHERPA_ONNX_IMPORT
32 #endif 32 #endif
33 #else // WIN32 33 #else // WIN32
34 -#define SHERPA_ONNX_EXPORT __attribute__((__visibility__("default"))) 34 +#define SHERPA_ONNX_EXPORT
35 #define SHERPA_ONNX_IMPORT SHERPA_ONNX_EXPORT 35 #define SHERPA_ONNX_IMPORT SHERPA_ONNX_EXPORT
36 #endif 36 #endif
37 37
@@ -125,6 +125,10 @@ else() @@ -125,6 +125,10 @@ else()
125 install(TARGETS sherpa-onnx-core DESTINATION lib) 125 install(TARGETS sherpa-onnx-core DESTINATION lib)
126 endif() 126 endif()
127 127
  128 +if(WIN32 AND BUILD_SHARED_LIBS)
  129 + install(TARGETS sherpa-onnx-core DESTINATION bin)
  130 +endif()
  131 +
128 install( 132 install(
129 TARGETS 133 TARGETS
130 sherpa-onnx 134 sherpa-onnx