|
| 1 | +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES |
| 2 | +# Copyright (c) 2023-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | +# |
| 16 | +# SPDX-License-Identifier: Apache-2.0 |
| 17 | + |
| 18 | +cmake_minimum_required(VERSION 3.22.1) |
| 19 | +project(gxf_isaac_fiducials LANGUAGES C CXX) |
| 20 | + |
| 21 | +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
| 22 | + add_compile_options(-fPIC -w) |
| 23 | +endif() |
| 24 | + |
| 25 | +find_package(ament_cmake_auto REQUIRED) |
| 26 | +ament_auto_find_build_dependencies() |
| 27 | + |
| 28 | +# Dependencies |
| 29 | +find_package(Eigen3 3.3 REQUIRED NO_MODULE) |
| 30 | +find_package(isaac_ros_nitros_april_tag_detection_array_type REQUIRED) |
| 31 | +find_package(yaml-cpp) |
| 32 | + |
| 33 | +# cuapriltags (resolve path from ament_index) |
| 34 | +ament_index_get_resource(CUAPRILTAGS_RELATIVE_PATH cuapriltags isaac_ros_nitros) |
| 35 | +ament_index_get_prefix_path(AMENT_INDEX_PREFIX_PATHS) |
| 36 | +foreach(PREFIX_PATH IN LISTS AMENT_INDEX_PREFIX_PATHS) |
| 37 | + if(EXISTS "${PREFIX_PATH}/${CUAPRILTAGS_RELATIVE_PATH}") |
| 38 | + set(CUAPRILTAGS "${PREFIX_PATH}/${CUAPRILTAGS_RELATIVE_PATH}") |
| 39 | + break() |
| 40 | + endif() |
| 41 | +endforeach() |
| 42 | +message( STATUS "Found cuapriltags at ${CUAPRILTAGS}") |
| 43 | + |
| 44 | +add_library(cuapriltags STATIC IMPORTED) |
| 45 | +set_property(TARGET cuapriltags PROPERTY IMPORTED_LOCATION ${CUAPRILTAGS}/lib/libcuapriltags.a) |
| 46 | + |
| 47 | +# Fiducials extension |
| 48 | +ament_auto_add_library(${PROJECT_NAME} SHARED |
| 49 | + gxf/extensions/fiducials/components/cuda_april_tag_detector.cpp |
| 50 | + gxf/extensions/fiducials/fiducials.cpp |
| 51 | +) |
| 52 | +target_include_directories(${PROJECT_NAME} PUBLIC |
| 53 | + "${CUAPRILTAGS}/cuapriltags" |
| 54 | + "${CMAKE_CURRENT_SOURCE_DIR}/gxf" |
| 55 | + "${isaac_ros_nitros_april_tag_detection_array_type_INCLUDE_DIRS}" |
| 56 | +) |
| 57 | +target_link_libraries(${PROJECT_NAME} |
| 58 | + Eigen3::Eigen |
| 59 | + ${isaac_ros_nitros_april_tag_detection_array_type_LIBRARIES} |
| 60 | + cuapriltags |
| 61 | + yaml-cpp |
| 62 | +) |
| 63 | + |
| 64 | +set_target_properties(${PROJECT_NAME} PROPERTIES |
| 65 | + BUILD_WITH_INSTALL_RPATH TRUE |
| 66 | + BUILD_RPATH_USE_ORIGIN TRUE |
| 67 | + INSTALL_RPATH_USE_LINK_PATH TRUE |
| 68 | +) |
| 69 | + |
| 70 | +# Install the binary file |
| 71 | +install(TARGETS ${PROJECT_NAME} DESTINATION share/${PROJECT_NAME}/gxf/lib) |
| 72 | + |
| 73 | +ament_auto_package(INSTALL_TO_SHARE) |
0 commit comments