Skip to content

Commit 5501f9f

Browse files
authored
Merge branch 'master' into alv2
2 parents 5a5f10c + 984e57c commit 5501f9f

File tree

2 files changed

+30
-16
lines changed

2 files changed

+30
-16
lines changed

CMakeLists.txt

+28-16
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,16 @@ if(BUILD_ONNXIFI)
5656
set(ONNXIFI_SOURCES onnx_trt_backend.cpp)
5757
endif()
5858

59-
set(EXECUTABLE_SOURCES
60-
main.cpp
61-
)
62-
63-
set(API_TESTS_SOURCES
64-
getSupportedAPITest.cpp
65-
ModelImporter.cpp
66-
)
59+
# Build executables if BUILD_LIBRARY_ONLY flag is not set
60+
if (NOT DEFINED BUILD_LIBRARY_ONLY)
61+
set(EXECUTABLE_SOURCES
62+
main.cpp
63+
)
64+
set(API_TESTS_SOURCES
65+
getSupportedAPITest.cpp
66+
ModelImporter.cpp
67+
)
68+
endif()
6769

6870
set(HEADERS
6971
NvOnnxParser.h
@@ -140,25 +142,28 @@ endif()
140142
# --------------------------------
141143
# Converter executable
142144
# --------------------------------
143-
add_executable(onnx2trt ${EXECUTABLE_SOURCES})
144-
target_include_directories(onnx2trt PUBLIC ${ONNX_INCLUDE_DIRS})
145-
target_link_libraries(onnx2trt PUBLIC ${PROTOBUF_LIB} onnx nvonnxparser_static ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) #${CUDA_LIBRARIES}
145+
if (NOT DEFINED BUILD_LIBRARY_ONLY)
146+
add_executable(onnx2trt ${EXECUTABLE_SOURCES})
147+
target_include_directories(onnx2trt PUBLIC ${ONNX_INCLUDE_DIRS})
148+
target_link_libraries(onnx2trt PUBLIC ${PROTOBUF_LIB} onnx nvonnxparser_static ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) #${CUDA_LIBRARIES}
149+
endif()
146150

147151
# --------------------------------
148152
# API Tests
149153
# --------------------------------
150-
add_executable(getSupportedAPITest ${API_TESTS_SOURCES})
151-
target_include_directories(getSupportedAPITest PUBLIC ${ONNX_INCLUDE_DIRS} ${CUDNN_INCLUDE_DIR})
152-
target_link_libraries(getSupportedAPITest PUBLIC ${PROTOBUF_LIB} nvonnxparser_static ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) #${CUDA_LIBRARIES}
154+
155+
if (NOT DEFINED BUILD_LIBRARY_ONLY)
156+
add_executable(getSupportedAPITest ${API_TESTS_SOURCES})
157+
target_include_directories(getSupportedAPITest PUBLIC ${ONNX_INCLUDE_DIRS} ${CUDNN_INCLUDE_DIR})
158+
target_link_libraries(getSupportedAPITest PUBLIC ${PROTOBUF_LIB} nvonnxparser_static ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) #${CUDA_LIBRARIES}
159+
endif()
153160

154161
# --------------------------------
155162
# Installation
156163
# --------------------------------
157164
install(TARGETS
158-
onnx2trt
159165
nvonnxparser
160166
nvonnxparser_static
161-
RUNTIME DESTINATION bin
162167
LIBRARY DESTINATION lib
163168
ARCHIVE DESTINATION lib
164169
)
@@ -167,6 +172,13 @@ install(FILES ${HEADERS}
167172
DESTINATION include
168173
)
169174

175+
if (NOT DEFINED BUILD_LIBRARY_ONLY)
176+
install(TARGETS
177+
onnx2trt
178+
RUNTIME DESTINATION bin
179+
)
180+
endif()
181+
170182
SET(CPACK_GENERATOR "DEB")
171183
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Mike Houston") #required
172184
SET(CPACK_PACKAGE_NAME "onnx-trt-dev")

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ Once you have cloned the repository, you can build the parser libraries and exec
5959
// Ensure that you update your LD_LIBRARY_PATH to pick up the location of the newly built library:
6060
export LD_LIBRARY_PATH=$PWD:$LD_LIBRARY_PATH
6161

62+
For building only the libraries, append `-DBUILD_LIBRARY_ONLY=1` to the CMake build command.
63+
6264
## Executable Usage
6365

6466
ONNX models can be converted to serialized TensorRT engines using the `onnx2trt` executable:

0 commit comments

Comments
 (0)