Skip to content

Commit

Permalink
Add TensorRT library suffix for Windows
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Chen <[email protected]>
  • Loading branch information
kevinch-nv committed Apr 24, 2024
1 parent 9372e9a commit 8a0e2b2
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions cmake/onnxruntime_providers_tensorrt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,39 @@
MESSAGE(STATUS "[Note] There is an issue when running \"Debug build\" TRT EP with \"Release build\" TRT built-in parser on Windows. This build will use tensorrt oss parser instead.")
endif()

if (onnxruntime_USE_TENSORRT_BUILTIN_PARSER)
# Add TensorRT library
find_path(TENSORRT_INCLUDE_DIR NvInfer.h
find_path(TENSORRT_INCLUDE_DIR NvInfer.h
HINTS ${TENSORRT_ROOT}
PATH_SUFFIXES include)
MESSAGE(STATUS "Found TensorRT headers at ${TENSORRT_INCLUDE_DIR}")
find_library(TENSORRT_LIBRARY_INFER nvinfer

file(STRINGS "${TENSORRT_INCLUDE_DIR}/NvInferVersion.h" VERSION_STRINGS REGEX "#define NV_TENSORRT_.*")

foreach(TYPE MAJOR MINOR PATCH BUILD)
string(REGEX MATCH "NV_TENSORRT_${TYPE} [0-9]+" TRT_TYPE_STRING ${VERSION_STRINGS})
string(REGEX MATCH "[0-9]+" TRT_${TYPE} ${TRT_TYPE_STRING})
endforeach(TYPE)

# Windows library names have major version appended starting from TRT 10.
if (MSVC AND TRT_MAJOR STREQUAL "10")
set(nvinfer_lib_name "nvinfer_${TRT_MAJOR}")
set(nvinfer_plugin_lib_name "nvinfer_plugin_${TRT_MAJOR}")
set(nvonnxparser_lib_name "nvonnxparser_${TRT_MAJOR}")
else()
set(nvinfer_lib_name "nvinfer")
set(nvinfer_plugin_lib_name "nvinfer_plugin")
set(nvonnxparser_lib_name "nvonnxparser")
endif()

MESSAGE(STATUS "Looking for TensorRT libraries: ${nvinfer_lib_name}, ${nvinfer_plugin_lib_name}, ${nvonnxparser_lib_name}")

if (onnxruntime_USE_TENSORRT_BUILTIN_PARSER)
# Add TensorRT library
find_library(TENSORRT_LIBRARY_INFER ${nvinfer_lib_name}
HINTS ${TENSORRT_ROOT}
PATH_SUFFIXES lib lib64 lib/x64)
find_library(TENSORRT_LIBRARY_INFER_PLUGIN nvinfer_plugin
find_library(TENSORRT_LIBRARY_INFER_PLUGIN ${nvinfer_plugin_lib_name}
HINTS ${TENSORRT_ROOT}
PATH_SUFFIXES lib lib64 lib/x64)
find_library(TENSORRT_LIBRARY_NVONNXPARSER nvonnxparser
find_library(TENSORRT_LIBRARY_NVONNXPARSER ${nvonnxparser_lib_name}
HINTS ${TENSORRT_ROOT}
PATH_SUFFIXES lib lib64 lib/x64)
set(TENSORRT_LIBRARY ${TENSORRT_LIBRARY_INFER} ${TENSORRT_LIBRARY_INFER_PLUGIN} ${TENSORRT_LIBRARY_NVONNXPARSER})
Expand Down

0 comments on commit 8a0e2b2

Please sign in to comment.