|
| 1 | +# Copyright 2025 The Autoware Contributors |
| 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 | +macro(autoware_ament_auto_package) |
| 16 | + # cSpell:ignore ARGN |
| 17 | + cmake_parse_arguments(_ARG_AUTOWARE_AMENT_AUTO_PACKAGE |
| 18 | + "INSTALL_TO_PATH" |
| 19 | + "" |
| 20 | + "INSTALL_TO_SHARE" |
| 21 | + ${ARGN}) |
| 22 | + |
| 23 | + # Export all found build dependencies which are also run dependencies |
| 24 | + set(_run_depends |
| 25 | + ${${PROJECT_NAME}_BUILD_EXPORT_DEPENDS} |
| 26 | + ${${PROJECT_NAME}_BUILDTOOL_EXPORT_DEPENDS} |
| 27 | + ${${PROJECT_NAME}_EXEC_DEPENDS}) |
| 28 | + foreach(_dep |
| 29 | + ${${PROJECT_NAME}_FOUND_BUILD_DEPENDS} |
| 30 | + ${${PROJECT_NAME}_FOUND_BUILDTOOL_DEPENDS}) |
| 31 | + if(_dep IN_LIST _run_depends) |
| 32 | + ament_export_dependencies("${_dep}") |
| 33 | + endif() |
| 34 | + endforeach() |
| 35 | + |
| 36 | + # Export and install include directory maintaining Autoware structure |
| 37 | + # Always use "include" as destination (not "include/${PROJECT_NAME}") |
| 38 | + # to maintain Autoware's naming convention across all ROS 2 versions |
| 39 | + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/include") |
| 40 | + ament_export_include_directories("include") |
| 41 | + install(DIRECTORY include/ DESTINATION include |
| 42 | + FILES_MATCHING |
| 43 | + PATTERN "*.h" |
| 44 | + PATTERN "*.hpp" |
| 45 | + PATTERN "*.hh" |
| 46 | + PATTERN "*.hxx" |
| 47 | + ) |
| 48 | + endif() |
| 49 | + |
| 50 | + # Export and install all libraries |
| 51 | + if(NOT ${PROJECT_NAME}_LIBRARIES STREQUAL "") |
| 52 | + ament_export_libraries(${${PROJECT_NAME}_LIBRARIES}) |
| 53 | + install( |
| 54 | + TARGETS ${${PROJECT_NAME}_LIBRARIES} |
| 55 | + ARCHIVE DESTINATION lib |
| 56 | + LIBRARY DESTINATION lib |
| 57 | + RUNTIME DESTINATION bin |
| 58 | + ) |
| 59 | + endif() |
| 60 | + |
| 61 | + # Install executables |
| 62 | + if(NOT ${PROJECT_NAME}_EXECUTABLES STREQUAL "") |
| 63 | + if(_ARG_AUTOWARE_AMENT_AUTO_PACKAGE_INSTALL_TO_PATH) |
| 64 | + set(_executable_destination "bin") |
| 65 | + else() |
| 66 | + set(_executable_destination "lib/${PROJECT_NAME}") |
| 67 | + endif() |
| 68 | + install( |
| 69 | + TARGETS ${${PROJECT_NAME}_EXECUTABLES} |
| 70 | + DESTINATION ${_executable_destination} |
| 71 | + ) |
| 72 | + endif() |
| 73 | + |
| 74 | + # Install additional directories to share |
| 75 | + foreach(_dir ${_ARG_AUTOWARE_AMENT_AUTO_PACKAGE_INSTALL_TO_SHARE}) |
| 76 | + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_dir}") |
| 77 | + install(DIRECTORY "${_dir}/" DESTINATION "share/${PROJECT_NAME}/${_dir}") |
| 78 | + endif() |
| 79 | + endforeach() |
| 80 | + |
| 81 | + # Call ament_package with any unparsed arguments |
| 82 | + set(_unparsed_args ${_ARG_AUTOWARE_AMENT_AUTO_PACKAGE_UNPARSED_ARGUMENTS}) |
| 83 | + ament_package(${_unparsed_args}) |
| 84 | +endmacro() |
0 commit comments