-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
86 lines (74 loc) · 2.13 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
cmake_minimum_required(VERSION 3.0.2)
project(depth_anything_ros)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
sensor_msgs
cv_bridge
jsk_data
)
# Find and include CUDA
find_package(CUDA REQUIRED)
# Find and include OpenCV
find_package(OpenCV REQUIRED)
# ------------------------------------------------------------------------------------
# Download models
# ------------------------------------------------------------------------------------
add_custom_target(${PROJECT_NAME}_install_trained_data ALL COMMAND python$ENV{ROS_PYTHON_VERSION} ${PROJECT_SOURCE_DIR}/scripts/install_trained_data.py)
# Add source files
set(SOURCES
src/utils.cpp
src/depth_anything.cpp
src/depth_estimation_node.cpp
)
# Add headers
set(HEADERS
include/utils.h
include/depth_anything.h
)
include_directories(
${CUDA_INCLUDE_DIRS}
${catkin_INCLUDE_DIRS}
${OpenCV_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/include
)
# Set TensorRT path
# If TENSORRT_DIR env variable is not set, set it to default path
if(NOT DEFINED ENV{TENSORRT_DIR})
message("TENSORRT_DIR is not set. Setting it to default path.")
set(TENSORRT_DIR "$ENV{HOME}/tensorrt")
else()
message("TENSORRT_DIR is set to $ENV{TENSORRT_DIR}")
set(TENSORRT_DIR "$ENV{TENSORRT_DIR}")
endif()
# Include TensorRT
include_directories(${TENSORRT_DIR}/include)
link_directories(${TENSORRT_DIR}/lib)
# Read TensorRT version
file(STRINGS "${TENSORRT_DIR}/include/NvInferVersion.h" tensorrt_version REGEX "#define NV_TENSORRT_MAJOR +[0-9]+")
string(REGEX MATCH "[0-9]+" tensorrt_version_major ${tensorrt_version})
# Check TensorRT version and set library accordingly
if (tensorrt_version_major EQUAL 10)
set(TENSORRT_LIBS nvinfer nvinfer_plugin nvonnxparser)
else()
set(TENSORRT_LIBS nvinfer nvinfer_plugin nvparsers nvonnxparser)
endif()
catkin_package (CATKIN_DEPENDS
roscpp
rospy
std_msgs
sensor_msgs
cv_bridge
jsk_data
LIBRARIES {PROJECT_NAME}
)
# Add executable
add_executable(depth_estimation_node ${SOURCES} ${HEADERS})
# Link libraries
target_link_libraries(depth_estimation_node
${OpenCV_LIBS}
${CUDA_LIBRARIES}
${TENSORRT_LIBS}
${catkin_LIBRARIES}
)