Skip to content

Commit

Permalink
Merge branch 'master' into alv2
Browse files Browse the repository at this point in the history
  • Loading branch information
szha authored Mar 25, 2021
2 parents 5a5f10c + 984e57c commit 5501f9f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 16 deletions.
44 changes: 28 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,16 @@ if(BUILD_ONNXIFI)
set(ONNXIFI_SOURCES onnx_trt_backend.cpp)
endif()

set(EXECUTABLE_SOURCES
main.cpp
)

set(API_TESTS_SOURCES
getSupportedAPITest.cpp
ModelImporter.cpp
)
# Build executables if BUILD_LIBRARY_ONLY flag is not set
if (NOT DEFINED BUILD_LIBRARY_ONLY)
set(EXECUTABLE_SOURCES
main.cpp
)
set(API_TESTS_SOURCES
getSupportedAPITest.cpp
ModelImporter.cpp
)
endif()

set(HEADERS
NvOnnxParser.h
Expand Down Expand Up @@ -140,25 +142,28 @@ endif()
# --------------------------------
# Converter executable
# --------------------------------
add_executable(onnx2trt ${EXECUTABLE_SOURCES})
target_include_directories(onnx2trt PUBLIC ${ONNX_INCLUDE_DIRS})
target_link_libraries(onnx2trt PUBLIC ${PROTOBUF_LIB} onnx nvonnxparser_static ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) #${CUDA_LIBRARIES}
if (NOT DEFINED BUILD_LIBRARY_ONLY)
add_executable(onnx2trt ${EXECUTABLE_SOURCES})
target_include_directories(onnx2trt PUBLIC ${ONNX_INCLUDE_DIRS})
target_link_libraries(onnx2trt PUBLIC ${PROTOBUF_LIB} onnx nvonnxparser_static ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) #${CUDA_LIBRARIES}
endif()

# --------------------------------
# API Tests
# --------------------------------
add_executable(getSupportedAPITest ${API_TESTS_SOURCES})
target_include_directories(getSupportedAPITest PUBLIC ${ONNX_INCLUDE_DIRS} ${CUDNN_INCLUDE_DIR})
target_link_libraries(getSupportedAPITest PUBLIC ${PROTOBUF_LIB} nvonnxparser_static ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) #${CUDA_LIBRARIES}

if (NOT DEFINED BUILD_LIBRARY_ONLY)
add_executable(getSupportedAPITest ${API_TESTS_SOURCES})
target_include_directories(getSupportedAPITest PUBLIC ${ONNX_INCLUDE_DIRS} ${CUDNN_INCLUDE_DIR})
target_link_libraries(getSupportedAPITest PUBLIC ${PROTOBUF_LIB} nvonnxparser_static ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) #${CUDA_LIBRARIES}
endif()

# --------------------------------
# Installation
# --------------------------------
install(TARGETS
onnx2trt
nvonnxparser
nvonnxparser_static
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
Expand All @@ -167,6 +172,13 @@ install(FILES ${HEADERS}
DESTINATION include
)

if (NOT DEFINED BUILD_LIBRARY_ONLY)
install(TARGETS
onnx2trt
RUNTIME DESTINATION bin
)
endif()

SET(CPACK_GENERATOR "DEB")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Mike Houston") #required
SET(CPACK_PACKAGE_NAME "onnx-trt-dev")
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ Once you have cloned the repository, you can build the parser libraries and exec
// Ensure that you update your LD_LIBRARY_PATH to pick up the location of the newly built library:
export LD_LIBRARY_PATH=$PWD:$LD_LIBRARY_PATH

For building only the libraries, append `-DBUILD_LIBRARY_ONLY=1` to the CMake build command.

## Executable Usage

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

0 comments on commit 5501f9f

Please sign in to comment.