forked from dusty-nv/ros_deep_learning
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
105 lines (74 loc) · 3.24 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
cmake_minimum_required(VERSION 3.5)
project(ros_deep_learning)
# locate dependencies
find_package(jetson-utils REQUIRED)
find_package(jetson-inference REQUIRED)
find_package(CUDA REQUIRED)
# detect ROS1 vs ROS2
find_package(catkin QUIET)
if( catkin_FOUND )
message("detected ROS1 (catkin_make)")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/package.ros1.xml ${CMAKE_CURRENT_SOURCE_DIR}/package.xml COPYONLY)
find_package(catkin REQUIRED COMPONENTS
image_transport
roscpp
sensor_msgs
vision_msgs
std_msgs
)
catkin_package(
LIBRARIES ros_deep_learning_nodelets
CATKIN_DEPENDS nodelet roscpp image_transport sensor_msgs
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") # enable c++11 (TensorRT requirement)
include_directories(${catkin_INCLUDE_DIRS} ${CUDA_INCLUDE_DIRS})
add_definitions(-DROS1)
else()
find_package(ament_cmake QUIET)
if( ament_cmake_FOUND )
message("detected ROS2 (ament_cmake)")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/package.ros2.xml ${CMAKE_CURRENT_SOURCE_DIR}/package.xml COPYONLY)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(vision_msgs REQUIRED)
set(CMAKE_CXX_STANDARD 14)
include_directories(${CUDA_INCLUDE_DIRS})
add_definitions(-DROS2)
else()
message(FATAL_ERROR "could not find either ROS1 (catkin_make) or ROS2 (ament_cmake) packages")
endif()
endif()
# sources shared across nodes
set(common_src src/image_converter.cpp src/ros_compat.cpp)
# inference nodes
add_executable(imagenet src/node_imagenet.cpp ${common_src})
target_link_libraries(imagenet ${catkin_LIBRARIES} jetson-inference)
add_executable(detectnet src/node_detectnet.cpp ${common_src})
target_link_libraries(detectnet ${catkin_LIBRARIES} jetson-inference)
add_executable(segnet src/node_segnet.cpp ${common_src})
target_link_libraries(segnet ${catkin_LIBRARIES} jetson-inference)
add_executable(video_source src/node_video_source.cpp ${common_src})
target_link_libraries(video_source ${catkin_LIBRARIES} jetson-inference)
add_executable(video_output src/node_video_output.cpp ${common_src})
target_link_libraries(video_output ${catkin_LIBRARIES} jetson-inference)
if( catkin_FOUND )
add_library(ros_deep_learning_nodelets src/nodelet_imagenet.cpp src/image_converter.cpp)
target_link_libraries(ros_deep_learning_nodelets ${catkin_LIBRARIES} jetson-inference)
if(catkin_EXPORTED_LIBRARIES)
add_dependencies(ros_deep_learning_nodelets ${catkin_EXPORTED_LIBRARIES})
endif()
else()
ament_target_dependencies(imagenet rclcpp std_msgs sensor_msgs vision_msgs)
install(TARGETS imagenet DESTINATION lib/${PROJECT_NAME})
ament_target_dependencies(detectnet rclcpp std_msgs sensor_msgs vision_msgs)
install(TARGETS detectnet DESTINATION lib/${PROJECT_NAME})
ament_target_dependencies(segnet rclcpp std_msgs sensor_msgs vision_msgs)
install(TARGETS segnet DESTINATION lib/${PROJECT_NAME})
ament_target_dependencies(video_source rclcpp std_msgs sensor_msgs vision_msgs)
install(TARGETS video_source DESTINATION lib/${PROJECT_NAME})
ament_target_dependencies(video_output rclcpp std_msgs sensor_msgs vision_msgs)
install(TARGETS video_output DESTINATION lib/${PROJECT_NAME})
install(DIRECTORY launch DESTINATION share/${PROJECT_NAME}/)
ament_package()
endif()