File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,30 @@ MESSAGE(STATUS "Found TensorRT headers at ${TENSORRT_INCLUDE_DIR}")
110110find_path (TENSORRT_PYTHON_INCLUDE_DIR plugin.h
111111 HINTS ${TENSORRT_ROOT}
112112 PATH_SUFFIXES python/include /impl)
113+
114+ # If header is not found, download it from open source release.
115+ if (NOT TENSORRT_PYTHON_INCLUDE_DIR)
116+ set (PLUGIN_URL "https://raw.githubusercontent.com/NVIDIA/TensorRT/refs/heads/release/${ONNX2TRT_MAJOR} .${ONNX2TRT_MINOR} /python/include/impl/plugin.h" )
117+ set (FILE_DESTINATION "${CMAKE_CURRENT_BINARY_DIR} /plugin.h" )
118+
119+ message (NOTICE "Required header plugin.h not found. Downloading from ${PLUGIN_URL} to ${FILE_DESTINATION} " )
120+
121+ file (DOWNLOAD ${PLUGIN_URL} ${FILE_DESTINATION}
122+ SHOW_PROGRESS
123+ STATUS DOWNLOAD_STATUS
124+ LOG DOWNLOAD_LOG
125+ )
126+
127+ list (GET DOWNLOAD_STATUS 0 STATUS_CODE)
128+ list (GET DOWNLOAD_STATUS 1 ERROR_MESSAGE)
129+
130+ if (NOT STATUS_CODE EQUAL 0)
131+ message (FATAL_ERROR "Error downloading file: ${ERROR_MESSAGE} " )
132+ endif ()
133+
134+ set (TENSORRT_PYTHON_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR} )
135+ endif ()
136+
113137message (NOTICE "Found TensorRT Python headers at ${TENSORRT_PYTHON_INCLUDE_DIR} " )
114138
115139# Output dynamic library names depends on platform:
You can’t perform that action at this time.
0 commit comments