Skip to content

Commit 1f7709f

Browse files
committed
Testing dependency download
1 parent 17f9596 commit 1f7709f

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,16 @@ if(NOT CMAKE_BUILD_TYPE)
131131
endif()
132132

133133
set(TRITON_ONNXRUNTIME_DOCKER_BUILD OFF)
134+
# Download onnxruntime
135+
include(cmake/download_onnxruntime.cmake)
134136
if(TRITON_ONNXRUNTIME_LIB_PATHS STREQUAL "")
135137
set(TRITON_ONNXRUNTIME_DOCKER_BUILD ON)
136138
endif()
137139

138140
message(STATUS "Using Onnxruntime docker: ${TRITON_ONNXRUNTIME_DOCKER_BUILD}")
139141

140142
if(NOT TRITON_ONNXRUNTIME_DOCKER_BUILD)
141-
find_library(ONNXRUNTIME_LIBRARY NAMES onnxruntime PATHS ${TRITON_ONNXRUNTIME_LIB_PATHS})
143+
find_library(ONNXRUNTIME_LIBRARY NAMES onnxruntime PATHS ${TRITON_ONNXRUNTIME_LIB_PATHS} REQUIRED)
142144
if(${TRITON_ENABLE_ONNXRUNTIME_OPENVINO})
143145
find_library(OV_LIBRARY
144146
NAMES openvino

cmake/download_onnxruntime.cmake

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
if(WIN32)
2+
3+
message(NOTICE "Downloading onnxruntime")
4+
5+
# Define the download and extraction paths)
6+
set(DOWNLOAD_PATH "${CMAKE_BINARY_DIR}/_deps/downloads/onnxruntime.zip")
7+
set(EXTRACT_DIR "${CMAKE_BINARY_DIR}/_deps/downloads/onnxruntime")
8+
9+
# Download the file
10+
file(DOWNLOAD $ENV{TRITON_ONNXRUNTIME_PACKAGE_URL} ${DOWNLOAD_PATH} SHOW_PROGRESS STATUS DOWNLOAD_STATUS)
11+
12+
# Check the download status
13+
list(GET DOWNLOAD_STATUS 0 DOWNLOAD_RESULT)
14+
if(NOT DOWNLOAD_RESULT EQUAL 0)
15+
message(SEND_ERROR "Failed to download ${ONNXRUNTIME_PACKAGE_URL}")
16+
else()
17+
message(NOTICE "Download successful: ${DOWNLOAD_PATH}" )
18+
19+
# Extract the downloaded file
20+
file(ARCHIVE_EXTRACT INPUT ${DOWNLOAD_PATH} DESTINATION ${EXTRACT_DIR} VERBOSE )
21+
22+
# Make the extracted directory searchable for CMake
23+
list(APPEND CMAKE_PREFIX_PATH ${EXTRACT_DIR})
24+
25+
# Find a specific library in the extracted folder
26+
# find_library(ONNXRUNTIME_LIBRARY onnxruntime NAMES onnxruntime.dll onnxruntime.so PATHS ${EXTRACT_DIR} PATH_SUFFIXES lib include NO_DEFAULT_PATH)
27+
28+
set(TRITON_ONNXRUNTIME_LIB_PATHS ${EXTRACT_DIR}/lib)
29+
30+
endif(NOT DOWNLOAD_RESULT EQUAL 0)
31+
32+
endif(WIN32)

0 commit comments

Comments
 (0)