forked from Natsu-Akatsuki/RangeNet-TensorRT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
97 lines (83 loc) · 2.29 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
cmake_minimum_required(VERSION 3.12)
project(rangenet_pp)
include(cmake/Color.cmake)
# >>> 设置宏定义 >>>
if (DEFINED PERFORMANCE_LOG)
add_compile_definitions(PERFORMANCE_LOG)
endif ()
# >>> 编译选项 >>>
# 设置 C++标准
# note:此处 std=c++14 不能改为 std=c++17,否则会报错(与 NVCC 有关),具体原理未知
INFO_LOG("CMAKE_BUILD_TYPE:${CMAKE_BUILD_TYPE}")
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RELEASE)
endif ()
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++14 -O3")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++14 -O0")
set(CMAKE_CXX_STANDARD 17)
# >>> 导入 ROS 架构下的相关代码 >>>
include(cmake/ROS.cmake)
# >>> 导入三方库 >>>
include(cmake/ThirdParty.cmake)
include_directories(
include
src/ops
src/utils)
# 处理点云 IO
add_library(pointcloud_io SHARED src/utils/pointcloud_io.cpp)
target_link_libraries(pointcloud_io ${PCL_LIBRARIES})
# CUDA 算子
cuda_add_library(project_ops src/ops/project_kernel.cu src/ops/project.cpp)
# 后处理
include_directories(src/utils)
add_library(postprocess src/utils/postprocess.cpp)
target_link_libraries(postprocess ${TORCH_LIBRARIES} ${OpenCV_LIBRARIES})
add_library(rangenet_lib src/network/net.cpp src/network/netTensorRT.cpp)
target_link_libraries(rangenet_lib
${YAML_CPP_LIBRARIES}
${OpenCV_LIBS}
${TENSORRT_LIBRARIES}
${CUDA_LIBRARIES}
${TORCH_LIBRARIES}
${PCL_LIBRARIES}
project_ops
)
add_executable(demo src/demo.cpp)
target_link_libraries(demo
${OpenCV_LIBS}
rangenet_lib
pointcloud_io
postprocess
)
# 检查 ROS 版本
if (DEFINED ENV{ROS_VERSION})
if ($ENV{ROS_VERSION} STREQUAL 1)
include_directories(
${catkin_INCLUDE_DIRS}
)
add_executable(ros1_demo src/ros1_demo.cpp)
target_link_libraries(ros1_demo ${catkin_LIBRARIES} ${OpenCV_LIBS}
rangenet_lib
pointcloud_io
postprocess
)
elseif ($ENV{ROS_VERSION} STREQUAL 2)
INFO_LOG("ROS2 is available!")
ament_auto_add_executable(ros2_demo src/ros2_demo.cpp)
ament_target_dependencies(ros2_demo
OpenCV
)
target_link_libraries(ros2_demo
${OpenCV_LIBS}
rangenet_lib
pointcloud_io
postprocess
)
ament_auto_package(
INSTALL_TO_SHARE
launch
model
data
)
endif ()
endif ()