-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmakeMain.txt
186 lines (164 loc) · 4.93 KB
/
cmakeMain.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES
# Copyright (c) 2021-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.10)
set(CMAKE_CUDA_COMPILER /usr/local/cuda-12.2/bin/nvcc)
project(collision LANGUAGES CXX CUDA)
# Default to C++17
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()
# Default to release build
if(NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
endif()
message( STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}" )
# Setup dependencies. Note that will also setup cuda architecture flags in CMAKE_CUDA_ARCHITECTURES
find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()
# Default behavior is to build for all supported CUDA architectures. In order to improve build
# speed we can select to build only for the native architecture by using
# colcon build --cmake-args "-DUSE_NATIVE_CUDA_ARCHITECTURE=1"
# Then the core lib will determine the current cuda architecture for us.
if(DEFINED USE_NATIVE_CUDA_ARCHITECTURE)
unset(CMAKE_CUDA_ARCHITECTURES)
message(STATUS "nvblox_ros is built with native CUDA architectures.")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
set(CMAKE_CUDA_ARCHITECTURES "87")
message(STATUS "nvblox_ros is built for Jetson/Orin CUDA architecture: ${CMAKE_CUDA_ARCHITECTURES}")
else()
message(STATUS "nvblox_ros is built for the following CUDA architectures: ${CMAKE_CUDA_ARCHITECTURES}")
endif()
# The core nvblox lib is built together with nvblox_ros
add_subdirectory(nvblox/nvblox)
################
# DEPENDENCIES #
################
find_package(ament_cmake REQUIRED)
find_package(ament_cmake_auto REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_components REQUIRED)
find_package(std_msgs REQUIRED)
find_package(std_srvs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(visualization_msgs REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(libstatistics_collector REQUIRED)
find_package(message_filters REQUIRED)
find_package(Threads REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(CUDAToolkit REQUIRED)
##################
# COMPILER SETUP #
##################
include(nvblox/nvblox/cmake/setup_compilers.cmake)
#############
# EXECUTABLE #
#############
add_executable(collision_executable
src/main.cpp
)
target_link_libraries(collision_executable
nvblox_lib
nvblox_eigen
pthread
)
ament_target_dependencies(collision_executable
rclcpp
rclcpp_components
sensor_msgs
geometry_msgs
std_msgs
visualization_msgs
std_srvs
tf2_ros
message_filters
cv_bridge
nav_msgs
)
target_include_directories(collision_executable PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_include_directories(collision_executable BEFORE PRIVATE
$<TARGET_PROPERTY:nvblox_eigen,INTERFACE_INCLUDE_DIRECTORIES>)
# NOTE(alexmillane 14.02.2024): This is needed at the moment to find libgxf_isaac_optimizer.so
# See: https://nvidia.slack.com/archives/C023NB2F7SN/p1707529762925559.
# TODO(alexmillane): Move to a generic Isaac ROS-wide solution at some point.
set_target_properties(collision_executable PROPERTIES
BUILD_WITH_INSTALL_RPATH TRUE
BUILD_RPATH_USE_ORIGIN TRUE
INSTALL_RPATH_USE_LINK_PATH TRUE)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.18)
get_target_property(CUDA_ARCHS nvblox_lib CUDA_ARCHITECTURES)
set_property(TARGET collision_executable APPEND PROPERTY CUDA_ARCHITECTURES ${CUDA_ARCHS})
endif()
###########
# INSTALL #
###########
# Install includes.
install(
DIRECTORY include/
DESTINATION include
)
# Install the executable target.
install(
TARGETS collision_executable
DESTINATION bin
)
# Install tests
# install(DIRECTORY
# test
# DESTINATION share/${PROJECT_NAME}
# )
# install(DIRECTORY
# scripts
# DESTINATION share/${PROJECT_NAME}/scripts/
# )
##########
# EXPORT #
##########
# ament_export_include_directories(
# include
# )
# ament_export_libraries(
# collision_executable
# )
# ament_export_targets(
# collision_executable
# )
# ament_export_dependencies(
# nvblox
# tf2_ros
# message_filters
# libstatistics_collector
# visualization_msgs
# cv_bridge
# nav_msgs
# # nvblox_ros_common
# )
ament_export_include_directories(
include
)
ament_export_dependencies(
nvblox
tf2_ros
message_filters
libstatistics_collector
visualization_msgs
cv_bridge
nav_msgs
)
ament_package()