正在显示
1 个修改的文件
包含
18 行增加
和
9 行删除
| @@ -104,6 +104,8 @@ message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}") | @@ -104,6 +104,8 @@ message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}") | ||
| 104 | 104 | ||
| 105 | if(DEFINED ENV{SHERPA_ONNXRUNTIME_INCLUDE_DIR}) | 105 | if(DEFINED ENV{SHERPA_ONNXRUNTIME_INCLUDE_DIR}) |
| 106 | set(location_onnxruntime_header_dir $ENV{SHERPA_ONNXRUNTIME_INCLUDE_DIR}) | 106 | set(location_onnxruntime_header_dir $ENV{SHERPA_ONNXRUNTIME_INCLUDE_DIR}) |
| 107 | + | ||
| 108 | + include_directories(${location_onnxruntime_header_dir}) | ||
| 107 | else() | 109 | else() |
| 108 | find_path(location_onnxruntime_header_dir onnxruntime_cxx_api.h | 110 | find_path(location_onnxruntime_header_dir onnxruntime_cxx_api.h |
| 109 | PATHS | 111 | PATHS |
| @@ -122,6 +124,11 @@ if(DEFINED ENV{SHERPA_ONNXRUNTIME_LIB_DIR}) | @@ -122,6 +124,11 @@ if(DEFINED ENV{SHERPA_ONNXRUNTIME_LIB_DIR}) | ||
| 122 | endif() | 124 | endif() |
| 123 | if(NOT EXISTS ${location_onnxruntime_lib}) | 125 | if(NOT EXISTS ${location_onnxruntime_lib}) |
| 124 | set(location_onnxruntime_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime.a) | 126 | set(location_onnxruntime_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime.a) |
| 127 | + if(NOT EXISTS ${location_onnxruntime_lib}) | ||
| 128 | + message(FATAL_ERROR "${location_onnxruntime_lib} cannot be found") | ||
| 129 | + endif() | ||
| 130 | + set(onnxruntime_lib_files $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime.a) | ||
| 131 | + message("Use static lib: ${onnxruntime_lib_files}") | ||
| 125 | endif() | 132 | endif() |
| 126 | if(SHERPA_ONNX_ENABLE_GPU) | 133 | if(SHERPA_ONNX_ENABLE_GPU) |
| 127 | set(location_onnxruntime_cuda_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime_providers_cuda.so) | 134 | set(location_onnxruntime_cuda_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime_providers_cuda.so) |
| @@ -153,16 +160,18 @@ if(SHERPA_ONNX_ENABLE_GPU) | @@ -153,16 +160,18 @@ if(SHERPA_ONNX_ENABLE_GPU) | ||
| 153 | endif() | 160 | endif() |
| 154 | 161 | ||
| 155 | if(location_onnxruntime_header_dir AND location_onnxruntime_lib) | 162 | if(location_onnxruntime_header_dir AND location_onnxruntime_lib) |
| 156 | - add_library(onnxruntime SHARED IMPORTED) | ||
| 157 | - set_target_properties(onnxruntime PROPERTIES | ||
| 158 | - IMPORTED_LOCATION ${location_onnxruntime_lib} | ||
| 159 | - INTERFACE_INCLUDE_DIRECTORIES "${location_onnxruntime_header_dir}" | ||
| 160 | - ) | ||
| 161 | - if(SHERPA_ONNX_ENABLE_GPU AND location_onnxruntime_cuda_lib) | ||
| 162 | - add_library(onnxruntime_providers_cuda SHARED IMPORTED) | ||
| 163 | - set_target_properties(onnxruntime_providers_cuda PROPERTIES | ||
| 164 | - IMPORTED_LOCATION ${location_onnxruntime_cuda_lib} | 163 | + if(NOT DEFINED onnxruntime_lib_files) |
| 164 | + add_library(onnxruntime SHARED IMPORTED) | ||
| 165 | + set_target_properties(onnxruntime PROPERTIES | ||
| 166 | + IMPORTED_LOCATION ${location_onnxruntime_lib} | ||
| 167 | + INTERFACE_INCLUDE_DIRECTORIES "${location_onnxruntime_header_dir}" | ||
| 165 | ) | 168 | ) |
| 169 | + if(SHERPA_ONNX_ENABLE_GPU AND location_onnxruntime_cuda_lib) | ||
| 170 | + add_library(onnxruntime_providers_cuda SHARED IMPORTED) | ||
| 171 | + set_target_properties(onnxruntime_providers_cuda PROPERTIES | ||
| 172 | + IMPORTED_LOCATION ${location_onnxruntime_cuda_lib} | ||
| 173 | + ) | ||
| 174 | + endif() | ||
| 166 | endif() | 175 | endif() |
| 167 | else() | 176 | else() |
| 168 | message(STATUS "Could not find a pre-installed onnxruntime. Downloading pre-compiled onnxruntime") | 177 | message(STATUS "Could not find a pre-installed onnxruntime. Downloading pre-compiled onnxruntime") |
-
请 注册 或 登录 后发表评论