-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
130 lines (105 loc) · 3.45 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
cmake_minimum_required(VERSION 3.8)
project(tensorrt_rtmdet)
find_package(tensorrt_common)
if(NOT ${tensorrt_common_FOUND})
message(WARNING "The tensorrt_common package is not found. Please check its dependencies.")
return()
endif()
find_package(autoware_cmake REQUIRED)
autoware_package()
find_package(OpenCV REQUIRED)
include(CheckLanguage)
check_language(CUDA)
if(CMAKE_CUDA_COMPILER)
enable_language(CUDA)
else()
message(WARNING "CUDA is not found. preprocess acceleration using CUDA will not be available.")
endif()
find_package(OpenMP)
if(OpenMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
# tensorrt_rtmdet
ament_auto_add_library(${PROJECT_NAME} SHARED
src/tensorrt_rtmdet.cpp
)
ament_target_dependencies(${PROJECT_NAME}
OpenCV
)
if(CMAKE_CUDA_COMPILER)
# trt_batched_nms
find_library(NVINFER_LIB nvinfer PATHS ${TENSORRT_ROOT}/lib)
find_library(NVPLUGIN_LIB nvinfer_plugin PATHS ${TENSORRT_ROOT}/lib)
include_directories(
include
include/tensorrt_rtmdet/trt_batched_nms
)
cuda_add_library(${PROJECT_NAME}_plugin SHARED
src/trt_batched_nms/common_impl/nms/batched_nms_kernel.cpp
src/trt_batched_nms/common_impl/nms/kernel.cu
src/trt_batched_nms/common_impl/nms/allClassNMS.cu
src/trt_batched_nms/common_impl/nms/gatherNMSOutputs.cu
src/trt_batched_nms/common_impl/nms/permuteData.cu
src/trt_batched_nms/common_impl/nms/sortScoresPerClass.cu
src/trt_batched_nms/common_impl/nms/sortScoresPerImage.cu
src/trt_batched_nms/batched_nms/trt_batched_nms.cpp
)
target_link_libraries(${PROJECT_NAME}_plugin ${CUDA_LIBRARIES} ${NVINFER_LIB} ${NVPLUGIN_LIB} ${OpenCV_LIBS} dl)
# preprocess
cuda_add_library(${PROJECT_NAME}_gpu_preprocess
SHARED
src/preprocess.cu
)
target_include_directories(${PROJECT_NAME}_gpu_preprocess PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>
)
# postprocess
cuda_add_library(${PROJECT_NAME}_gpu_postprocess
SHARED
src/postprocess.cu
)
target_include_directories(${PROJECT_NAME}_gpu_postprocess PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>
)
target_link_libraries(${PROJECT_NAME}
${tensorrt_common_LIBRARIES}
${PROJECT_NAME}_gpu_preprocess
${PROJECT_NAME}_gpu_postprocess
${PROJECT_NAME}_plugin
)
else()
target_link_libraries(${PROJECT_NAME}
${tensorrt_common_LIBRARIES}
)
endif()
target_compile_definitions(${PROJECT_NAME} PRIVATE
TENSORRT_VERSION_MAJOR=${TENSORRT_VERSION_MAJOR}
)
# tensorrt_rtmdet_node
ament_auto_add_library(${PROJECT_NAME}_node SHARED
src/tensorrt_rtmdet_node.cpp
)
ament_target_dependencies(${PROJECT_NAME}_node
OpenCV
)
target_link_libraries(${PROJECT_NAME}_node
${PROJECT_NAME}
)
target_compile_definitions(${PROJECT_NAME}_node PRIVATE
TENSORRT_VERSION_MAJOR=${TENSORRT_VERSION_MAJOR}
)
rclcpp_components_register_node(${PROJECT_NAME}_node
PLUGIN "tensorrt_rtmdet::TrtRTMDetNode"
EXECUTABLE tensorrt_rtmdet_node_exe
)
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()
ament_auto_package(INSTALL_TO_SHARE
launch
config
)