-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCMakeLists.txt
69 lines (63 loc) · 1.81 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
cmake_minimum_required(VERSION 3.12)
project(tensorrt_yolov9_ros)
### Set compiler
ADD_COMPILE_OPTIONS(-std=c++17 )
set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions -g -ggdb -O3") # -std=c++17 is commented to avoid conflict with CUDA
set(CMAKE_CXX_FLAGS_RELEASE "-Wall ${CMAKE_CXX_FLAGS}")
### Get packages
# catkin
find_package(catkin REQUIRED COMPONENTS
roscpp
std_msgs
sensor_msgs
cv_bridge
message_generation
message_runtime
)
# Find CUDA
find_package(CUDA REQUIRED)
# Find OpenCV
find_package(OpenCV REQUIRED)
# Include TensorRT
set(TENSORRT_INCLUD_DIR /usr/include/x86_64-linux-gnu) # TensorRT include directory, NvInfer.h etc.
set(TENSORRT_LIB_DIR /usr/lib/x86_64-linux-gnu) # TensorRT library directory, libnvinfer.so etc.
link_directories(${TENSORRT_LIB_DIR})
include_directories( # Include directories
include
${catkin_INCLUDE_DIRS}
${CUDA_INCLUDE_DIRS}
${TENSORRT_INCLUD_DIR}
${OpenCV_INCLUDE_DIRS}
)
# Get TensorRT version and set libraries
file(READ /usr/include/x86_64-linux-gnu/NvInferVersion.h TRT_VERSION_FILE)
string(REGEX MATCH "#define NV_TENSORRT_MAJOR ([0-9]+)" _ ${TRT_VERSION_FILE})
set(TENSORRT_MAJOR_VERSION ${CMAKE_MATCH_1})
if(TENSORRT_MAJOR_VERSION GREATER_EQUAL 10)
set(TENSORRT_LIBS nvinfer nvinfer_plugin nvonnxparser)
else()
set(TENSORRT_LIBS nvinfer nvinfer_plugin nvparsers nvonnxparser)
endif()
### Generate messages
add_message_files(
FILES
bbox.msg
bboxes.msg
)
generate_messages(
DEPENDENCIES
std_msgs
)
### Catkin package
catkin_package()
### Build
cuda_add_executable(${PROJECT_NAME}_node src/main.cpp include/preprocess.cu)
target_link_libraries(${PROJECT_NAME}_node # Link libraries
${catkin_LIBRARIES}
${OpenCV_LIBS}
${CUDA_LIBRARIES}
${TENSORRT_LIBS}
)