Skip to content

Commit 0c817ac

Browse files
committed
Temporary make plugin TRT links against the protobuf, onnx, flatbuffers built from ORT repo
1 parent b911754 commit 0c817ac

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

plugin_execution_providers/tensorrt/CMakeLists.txt

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ enable_language(CUDA)
99
file(TO_CMAKE_PATH CUDAToolkit_ROOT "/usr/local/cuda")
1010
find_package(CUDAToolkit REQUIRED)
1111

12+
# Use dynamic runtime /MD and /MDd
13+
set(CMAKE_CUDA_FLAGS_DEBUG "${CMAKE_CUDA_FLAGS_DEBUG} -Xcompiler=\"/MTd\"")
14+
1215
add_definitions(-DONNX_NAMESPACE=onnx)
1316
add_definitions(-DONNX_ML)
1417
add_definitions(-DNV_TENSORRT_MAJOR=10)
@@ -71,15 +74,16 @@ FetchContent_MakeAvailable(flatbuffers)
7174
set(DEPS_PATH "${CMAKE_BINARY_DIR}/_deps")
7275

7376
if (WIN32) # Windows
74-
set(ORT_LIB "${ORT_HOME}/lib/onnxruntime.lib")
75-
#set(ORT_LIB "${ORT_HOME}/lib/onnxruntime.dll")
77+
set(PLATFORM "Windows")
78+
set(ORT_LIB "${ORT_HOME}/build/${PLATFORM}/${CMAKE_BUILD_TYPE}/${CMAKE_BUILD_TYPE}/onnxruntime.lib")
79+
set(DEPS_PATH "${ORT_HOME}/build/${PLATFORM}/${CMAKE_BUILD_TYPE}/_deps")
7680
set(TRT_LIBS "${TENSORRT_HOME}/lib/nvinfer_10.lib"
7781
"${TENSORRT_HOME}/lib/nvinfer_plugin_10.lib"
7882
"${TENSORRT_HOME}/lib/nvonnxparser_10.lib")
7983
set(DEPS_LIBS "${DEPS_PATH}/flatbuffers-build/${CMAKE_BUILD_TYPE}/flatbuffers.lib"
80-
"${DEPS_PATH}/onnx-build/${CMAKE_BUILD_TYPE}/onnx.lib"
81-
"${DEPS_PATH}/onnx-build/${CMAKE_BUILD_TYPE}/onnx_proto.lib")
82-
84+
"${DEPS_PATH}/onnx-build/${CMAKE_BUILD_TYPE}/onnx.lib"
85+
"${DEPS_PATH}/onnx-build/${CMAKE_BUILD_TYPE}/onnx_proto.lib")
86+
8387
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
8488
set(DEPS_LIBS ${DEPS_LIBS}
8589
"${DEPS_PATH}/protobuf-build/${CMAKE_BUILD_TYPE}/libprotobufd.lib"
@@ -89,6 +93,10 @@ if (WIN32) # Windows
8993
"${DEPS_PATH}/protobuf-build/${CMAKE_BUILD_TYPE}/libprotobuf.lib"
9094
"${DEPS_PATH}/protobuf-build/${CMAKE_BUILD_TYPE}/libprotoc.lib")
9195
endif()
96+
97+
set(TRT_EP_LIB_LINK_FLAG
98+
"-DEF:${CMAKE_SOURCE_DIR}/tensorrt_execution_provider.def")
99+
92100
else() # Linux
93101
set(ORT_LIB "${ORT_HOME}/lib/libonnxruntime.so")
94102
set(TRT_LIBS "${TENSORRT_HOME}/lib/libnvinfer.so"
@@ -114,12 +122,16 @@ MESSAGE(STATUS "ORT lib : ${ORT_LIB}")
114122
MESSAGE(STATUS "TRT libs : ${TRT_LIBS}")
115123
MESSAGE(STATUS "Deps libs: ${DEPS_LIBS}")
116124

117-
target_include_directories(TensorRTEp PUBLIC "${ORT_HOME}/include"
125+
set_property(TARGET TensorRTEp APPEND_STRING PROPERTY LINK_FLAGS
126+
${TRT_EP_LIB_LINK_FLAG})
127+
128+
target_include_directories(TensorRTEp PUBLIC #"${ORT_HOME}/include"
129+
"${ORT_HOME}/include/onnxruntime/core/session"
118130
"./utils"
119131
"/usr/local/cuda/include"
120132
"${TENSORRT_HOME}/include"
121133
"${DEPS_PATH}/flatbuffers-src/include"
122-
"${DEPS_PATH}/gsl-src/include"
134+
"${DEPS_PATH}/gsl-src/include" # GSL is header-only
123135
"${DEPS_PATH}/onnx-src"
124136
"${DEPS_PATH}/onnx-build"
125137
"${DEPS_PATH}/protobuf-src/src"
@@ -128,8 +140,5 @@ target_include_directories(TensorRTEp PUBLIC "${ORT_HOME}/include"
128140
target_link_libraries(TensorRTEp PUBLIC ${ORT_LIB}
129141
${TRT_LIBS}
130142
CUDA::cudart
131-
protobuf
132-
onnx
133-
gsl
134-
flatbuffers
143+
${DEPS_LIBS}
135144
)

0 commit comments

Comments
 (0)