|
| 1 | +# Copyright (c) 2025-present Polymath Robotics, Inc. |
| 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 | + |
| 15 | +cmake_minimum_required(VERSION 3.22) |
| 16 | +project(behaviortree_cpp_pluginlib) |
| 17 | + |
| 18 | +if(NOT CMAKE_C_STANDARD) |
| 19 | + set(CMAKE_C_STANDARD 99) |
| 20 | +endif() |
| 21 | +if(NOT CMAKE_CXX_STANDARD) |
| 22 | + set(CMAKE_CXX_STANDARD 17) |
| 23 | +endif() |
| 24 | +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
| 25 | + add_compile_options(-Wall -Wextra -Wpedantic) |
| 26 | + add_link_options(-Wl,-no-undefined) |
| 27 | +endif() |
| 28 | + |
| 29 | +find_package(ament_cmake_auto REQUIRED) |
| 30 | +ament_auto_find_build_dependencies() |
| 31 | + |
| 32 | +# Create library |
| 33 | +add_library(${PROJECT_NAME} SHARED |
| 34 | + src/factory.cpp |
| 35 | +) |
| 36 | +target_include_directories(${PROJECT_NAME} PUBLIC |
| 37 | + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| 38 | + $<INSTALL_INTERFACE:include> |
| 39 | +) |
| 40 | +target_link_libraries(${PROJECT_NAME} |
| 41 | + PUBLIC |
| 42 | + behaviortree_cpp::behaviortree_cpp |
| 43 | + pluginlib::pluginlib |
| 44 | + PRIVATE |
| 45 | + rcutils::rcutils |
| 46 | +) |
| 47 | + |
| 48 | +# Install and export resources |
| 49 | +install( |
| 50 | + TARGETS ${PROJECT_NAME} |
| 51 | + EXPORT ${PROJECT_NAME}_TARGETS |
| 52 | + ARCHIVE DESTINATION lib |
| 53 | + LIBRARY DESTINATION lib |
| 54 | + RUNTIME DESTINATION bin |
| 55 | +) |
| 56 | +install( |
| 57 | + EXPORT ${PROJECT_NAME}_TARGETS |
| 58 | + NAMESPACE ${PROJECT_NAME}:: |
| 59 | + DESTINATION share/${PROJECT_NAME}/cmake |
| 60 | +) |
| 61 | +install( |
| 62 | + FILES src/autoregistrar.cpp.in src/plugin_description.xml.in |
| 63 | + DESTINATION share/${PROJECT_NAME} |
| 64 | +) |
| 65 | +install( |
| 66 | + DIRECTORY include/ |
| 67 | + DESTINATION include |
| 68 | +) |
| 69 | +install( |
| 70 | + DIRECTORY cmake |
| 71 | + DESTINATION share/${PROJECT_NAME} |
| 72 | +) |
| 73 | + |
| 74 | +if(BUILD_TESTING) |
| 75 | + ament_auto_find_test_dependencies() |
| 76 | + |
| 77 | + set(arg_TARGET test_register) |
| 78 | + configure_file( |
| 79 | + src/autoregistrar.cpp.in |
| 80 | + ${PROJECT_BINARY_DIR}/test/autoregistrar.cpp |
| 81 | + @ONLY |
| 82 | + ) |
| 83 | + |
| 84 | + ament_add_gtest(test_register |
| 85 | + test/test_register.cpp |
| 86 | + ${PROJECT_BINARY_DIR}/test/autoregistrar.cpp |
| 87 | + ) |
| 88 | + target_link_libraries(test_register ${PROJECT_NAME}) |
| 89 | +endif() |
| 90 | + |
| 91 | +ament_export_targets(${PROJECT_NAME}_TARGETS HAS_LIBRARY_TARGET) |
| 92 | +ament_export_dependencies(behaviortree_cpp pluginlib) |
| 93 | +ament_package( |
| 94 | + CONFIG_EXTRAS "${PROJECT_NAME}-extras.cmake" |
| 95 | +) |
0 commit comments