Committed by
GitHub
use pre-installed onnxruntime if possible (#47)
正在显示
1 个修改的文件
包含
35 行增加
和
7 行删除
| @@ -24,13 +24,13 @@ function(download_onnxruntime) | @@ -24,13 +24,13 @@ function(download_onnxruntime) | ||
| 24 | # If you don't have access to the Internet, | 24 | # If you don't have access to the Internet, |
| 25 | # please pre-download onnxruntime | 25 | # please pre-download onnxruntime |
| 26 | set(possible_file_locations | 26 | set(possible_file_locations |
| 27 | - $ENV{HOME}/Downloads/onnxruntime-osx-x86_64-1.14.0.tgz | ||
| 28 | - ${PROJECT_SOURCE_DIR}/onnxruntime-osx-x86_64-1.14.0.tgz | ||
| 29 | - ${PROJECT_BINARY_DIR}/onnxruntime-osx-x86_64-1.14.0.tgz | ||
| 30 | - /tmp/onnxruntime-osx-x86_64-1.14.0.tgz | 27 | + $ENV{HOME}/Downloads/onnxruntime-osx-universal2-1.14.0.tgz |
| 28 | + ${PROJECT_SOURCE_DIR}/onnxruntime-osx-universal2-1.14.0.tgz | ||
| 29 | + ${PROJECT_BINARY_DIR}/onnxruntime-osx-universal2-1.14.0.tgz | ||
| 30 | + /tmp/onnxruntime-osx-universal2-1.14.0.tgz | ||
| 31 | ) | 31 | ) |
| 32 | - set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.14.0/onnxruntime-osx-x86_64-1.14.0.tgz") | ||
| 33 | - set(onnxruntime_HASH "SHA256=abd2056d56051e78263af37b8dffc3e6da110d2937af7a581a34d1a58dc58360") | 32 | + set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.14.0/onnxruntime-osx-universal2-1.14.0.tgz") |
| 33 | + set(onnxruntime_HASH "SHA256=348563df91f17a2ac010519f37c3b46fd5b79140974e5c5a90a57e032bb25925") | ||
| 34 | # After downloading, it contains: | 34 | # After downloading, it contains: |
| 35 | # ./lib/libonnxruntime.1.14.0.dylib | 35 | # ./lib/libonnxruntime.1.14.0.dylib |
| 36 | # ./lib/libonnxruntime.dylib, which is a symlink to lib/libonnxruntime.1.14.0.dylib | 36 | # ./lib/libonnxruntime.dylib, which is a symlink to lib/libonnxruntime.1.14.0.dylib |
| @@ -115,4 +115,32 @@ function(download_onnxruntime) | @@ -115,4 +115,32 @@ function(download_onnxruntime) | ||
| 115 | install(FILES ${onnxruntime_lib_files} DESTINATION lib) | 115 | install(FILES ${onnxruntime_lib_files} DESTINATION lib) |
| 116 | endfunction() | 116 | endfunction() |
| 117 | 117 | ||
| 118 | -download_onnxruntime() | 118 | +# First, we try to locate the header and the lib if the use has already |
| 119 | +# installed onnxruntime. Otherwise, we will download the pre-compiled lib | ||
| 120 | + | ||
| 121 | +find_path(location_onnxruntime_header_dir onnxruntime_cxx_api.h | ||
| 122 | + PATHS | ||
| 123 | + /usr/include | ||
| 124 | + /usr/local/include | ||
| 125 | +) | ||
| 126 | +message(STATUS "location_onnxruntime_header_dir: ${location_onnxruntime_header_dir}") | ||
| 127 | + | ||
| 128 | +find_library(location_onnxruntime_lib onnxruntime | ||
| 129 | + PATHS | ||
| 130 | + /lib | ||
| 131 | + /usr/lib | ||
| 132 | + /usr/local/lib | ||
| 133 | +) | ||
| 134 | +message(STATUS "location_onnxruntime_lib: ${location_onnxruntime_lib}") | ||
| 135 | + | ||
| 136 | +if(location_onnxruntime_header_dir AND location_onnxruntime_lib) | ||
| 137 | + add_library(onnxruntime SHARED IMPORTED) | ||
| 138 | + set_target_properties(onnxruntime PROPERTIES | ||
| 139 | + IMPORTED_LOCATION ${location_onnxruntime_lib} | ||
| 140 | + INTERFACE_INCLUDE_DIRECTORIES "${location_onnxruntime_header_dir}" | ||
| 141 | + ) | ||
| 142 | +else() | ||
| 143 | + message(STATUS "Could not find a pre-installed onnxruntime. Downloading pre-compiled onnxruntime") | ||
| 144 | + download_onnxruntime() | ||
| 145 | +endif() | ||
| 146 | + |
-
请 注册 或 登录 后发表评论