@@ -1,39 +1,52 @@
|
||||
function(download_onnxruntime)
|
||||
if(CMAKE_VERSION VERSION_LESS 3.11)
|
||||
# FetchContent is available since 3.11,
|
||||
# we've copied it to ${CMAKE_SOURCE_DIR}/cmake/Modules
|
||||
# so that it can be used in lower CMake versions.
|
||||
message(STATUS "Use FetchContent provided by sherpa-onnx")
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
|
||||
endif()
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
if(UNIX AND NOT APPLE)
|
||||
set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.12.1/onnxruntime-linux-x64-1.12.1.tgz")
|
||||
# If you don't have access to the Internet,
|
||||
# please pre-download onnxruntime
|
||||
set(possible_file_locations
|
||||
$ENV{HOME}/Downloads/onnxruntime-linux-x64-1.14.0.tgz
|
||||
${PROJECT_SOURCE_DIR}/onnxruntime-linux-x64-1.14.0.tgz
|
||||
${PROJECT_BINARY_DIR}/onnxruntime-linux-x64-1.14.0.tgz
|
||||
/tmp/onnxruntime-linux-x64-1.14.0.tgz
|
||||
)
|
||||
|
||||
# If you don't have access to the internet, you can first download onnxruntime to some directory, and the use
|
||||
# set(onnxruntime_URL "file:///ceph-fj/fangjun/open-source/sherpa-onnx/onnxruntime-linux-x64-1.12.1.tgz")
|
||||
|
||||
set(onnxruntime_HASH "SHA256=8f6eb9e2da9cf74e7905bf3fc687ef52e34cc566af7af2f92dafe5a5d106aa3d")
|
||||
set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.14.0/onnxruntime-linux-x64-1.14.0.tgz")
|
||||
set(onnxruntime_HASH "SHA256=92bf534e5fa5820c8dffe9de2850f84ed2a1c063e47c659ce09e8c7938aa2090")
|
||||
# After downloading, it contains:
|
||||
# ./lib/libonnxruntime.so.1.12.1
|
||||
# ./lib/libonnxruntime.so, which is a symlink to lib/libonnxruntime.so.1.12.1
|
||||
# ./lib/libonnxruntime.so.1.14.0
|
||||
# ./lib/libonnxruntime.so, which is a symlink to lib/libonnxruntime.so.1.14.0
|
||||
#
|
||||
# ./include
|
||||
# It contains all the needed header files
|
||||
elseif(APPLE)
|
||||
set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.12.1/onnxruntime-osx-x86_64-1.12.1.tgz")
|
||||
set(onnxruntime_HASH "SHA256=10921c2e75817edcbfc8b29882612be07e25dd33c8449d5892a9d45588898099")
|
||||
# If you don't have access to the Internet,
|
||||
# please pre-download onnxruntime
|
||||
set(possible_file_locations
|
||||
$ENV{HOME}/Downloads/onnxruntime-osx-x86_64-1.14.0.tgz
|
||||
${PROJECT_SOURCE_DIR}/onnxruntime-osx-x86_64-1.14.0.tgz
|
||||
${PROJECT_BINARY_DIR}/onnxruntime-osx-x86_64-1.14.0.tgz
|
||||
/tmp/onnxruntime-osx-x86_64-1.14.0.tgz
|
||||
)
|
||||
set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.14.0/onnxruntime-osx-x86_64-1.14.0.tgz")
|
||||
set(onnxruntime_HASH "SHA256=abd2056d56051e78263af37b8dffc3e6da110d2937af7a581a34d1a58dc58360")
|
||||
# After downloading, it contains:
|
||||
# ./lib/libonnxruntime.1.12.1.dylib
|
||||
# ./lib/libonnxruntime.dylib, which is a symlink to lib/libonnxruntime.1.12.1.dylib
|
||||
# ./lib/libonnxruntime.1.14.0.dylib
|
||||
# ./lib/libonnxruntime.dylib, which is a symlink to lib/libonnxruntime.1.14.0.dylib
|
||||
#
|
||||
# ./include
|
||||
# It contains all the needed header files
|
||||
elseif(WIN32)
|
||||
set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.12.1/onnxruntime-win-x64-1.12.1.zip")
|
||||
set(onnxruntime_HASH "SHA256=c69650ba14aeae5903b05256a82e77164fff2de992072bc695a3838c1830b85a")
|
||||
# If you don't have access to the Internet,
|
||||
# please pre-download onnxruntime
|
||||
set(possible_file_locations
|
||||
$ENV{HOME}/Downloads/onnxruntime-win-x64-1.14.0.zip
|
||||
${PROJECT_SOURCE_DIR}/onnxruntime-win-x64-1.14.0.zip
|
||||
${PROJECT_BINARY_DIR}/onnxruntime-win-x64-1.14.0.zip
|
||||
/tmp/onnxruntime-win-x64-1.14.0.zip
|
||||
)
|
||||
set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.14.0/onnxruntime-win-x64-1.14.0.zip")
|
||||
set(onnxruntime_HASH "SHA256=300eafef456748cde2743ee08845bd40ff1bab723697ff934eba6d4ce3519620")
|
||||
# After downloading, it contains:
|
||||
# ./lib/onnxruntime.{dll,lib,pdb}
|
||||
# ./lib/onnxruntime_providers_shared.{dll,lib,pdb}
|
||||
@@ -44,6 +57,13 @@ function(download_onnxruntime)
|
||||
message(FATAL_ERROR "Only support Linux and macOS at present. Will support other OSes later")
|
||||
endif()
|
||||
|
||||
foreach(f IN LISTS possible_file_locations)
|
||||
if(EXISTS ${f})
|
||||
set(onnxruntime_URL "file://${f}")
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
FetchContent_Declare(onnxruntime
|
||||
URL ${onnxruntime_URL}
|
||||
URL_HASH ${onnxruntime_HASH}
|
||||
@@ -51,7 +71,7 @@ function(download_onnxruntime)
|
||||
|
||||
FetchContent_GetProperties(onnxruntime)
|
||||
if(NOT onnxruntime_POPULATED)
|
||||
message(STATUS "Downloading onnxruntime ${onnxruntime_URL}")
|
||||
message(STATUS "Downloading onnxruntime from ${onnxruntime_URL}")
|
||||
FetchContent_Populate(onnxruntime)
|
||||
endif()
|
||||
message(STATUS "onnxruntime is downloaded to ${onnxruntime_SOURCE_DIR}")
|
||||
|
||||
Reference in New Issue
Block a user