|
| 1 | +# Copyright (c) 2025-present WATonomous. All rights reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +cmake_minimum_required(VERSION 3.10) |
| 15 | +project(object_detection) |
| 16 | + |
| 17 | +# Set compiler to use C++ 17 standard |
| 18 | +if(NOT CMAKE_CXX_STANDARD) |
| 19 | + set(CMAKE_CXX_STANDARD 17) |
| 20 | +endif() |
| 21 | + |
| 22 | +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
| 23 | + add_compile_options(-Wall -Wextra -Wpedantic) |
| 24 | +endif() |
| 25 | + |
| 26 | +# Search for dependencies required for building this package |
| 27 | +find_package(ament_cmake REQUIRED) # ROS2 build tool |
| 28 | +find_package(rclcpp REQUIRED) # ROS2 C++ package |
| 29 | + |
| 30 | +# Compiles source files into a library |
| 31 | +# A library is not executed, instead other executables can link |
| 32 | +# against it to access defined methods and classes. |
| 33 | +# We build a library so that the methods defined can be used by |
| 34 | +# both the unit test and ROS2 node executables. |
| 35 | +add_library(object_detection_lib |
| 36 | + src/object_detection_core.cpp) |
| 37 | +# Indicate to compiler where to search for header files |
| 38 | +target_include_directories(object_detection_lib |
| 39 | + PUBLIC include) |
| 40 | +# Add ROS2 dependencies required by package |
| 41 | +ament_target_dependencies(object_detection_lib |
| 42 | + rclcpp |
| 43 | +) |
| 44 | + |
| 45 | +# Create ROS2 node executable from source files |
| 46 | +add_executable(object_detection_node src/object_detection_node.cpp) |
| 47 | +# Link to the previously built library to access object_detection classes and methods |
| 48 | +target_link_libraries(object_detection_node object_detection_lib) |
| 49 | + |
| 50 | +# Copy executable to installation location |
| 51 | +install(TARGETS |
| 52 | + object_detection_node |
| 53 | + DESTINATION lib/${PROJECT_NAME}) |
| 54 | + |
| 55 | +# Copy launch and config files to installation location |
| 56 | +install(DIRECTORY |
| 57 | + config |
| 58 | + DESTINATION share/${PROJECT_NAME}) |
| 59 | + |
| 60 | + |
| 61 | +ament_package() |
0 commit comments