From 78af788a1d54cf27b36273cc13b291988d812a8a Mon Sep 17 00:00:00 2001 From: artivis Date: Wed, 18 Jan 2023 12:02:06 +0100 Subject: [PATCH 1/3] add install_package_xml.cmake Signed-off-by: artivis --- .../cmake/packaging/install_package_xml.cmake | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 cmake_utils/cmake/packaging/install_package_xml.cmake diff --git a/cmake_utils/cmake/packaging/install_package_xml.cmake b/cmake_utils/cmake/packaging/install_package_xml.cmake new file mode 100644 index 00000000..c22d3435 --- /dev/null +++ b/cmake_utils/cmake/packaging/install_package_xml.cmake @@ -0,0 +1,25 @@ +# Copyright 2023 Canonical Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# 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. + +############################################################################### +# Install package.xml if it exists +############################################################################### + +macro(install_package_xml) + + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/package.xml) + install(FILES package.xml DESTINATION share/${PROJECT_NAME}) + endif() + +endmacro() From 50eaafa1b2b3ef84c12e08219ea349c0d9c7b722 Mon Sep 17 00:00:00 2001 From: artivis Date: Wed, 18 Jan 2023 12:02:21 +0100 Subject: [PATCH 2/3] add install_ament_index.cmake Signed-off-by: artivis --- .../cmake/packaging/install_ament_index.cmake | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 cmake_utils/cmake/packaging/install_ament_index.cmake diff --git a/cmake_utils/cmake/packaging/install_ament_index.cmake b/cmake_utils/cmake/packaging/install_ament_index.cmake new file mode 100644 index 00000000..75532ee4 --- /dev/null +++ b/cmake_utils/cmake/packaging/install_ament_index.cmake @@ -0,0 +1,45 @@ +# Copyright 2023 Canonical Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# 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. + +############################################################################### +# Install ament index +############################################################################### + +macro(install_ament_index) + + file( + WRITE + ${CMAKE_CURRENT_BINARY_DIR}/share/ament_index/resource_index/packages/${PROJECT_NAME} + "" + ) + install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/share/ament_index/resource_index/packages/${PROJECT_NAME} + DESTINATION + share/ament_index/resource_index/packages + ) + + file( + WRITE + ${CMAKE_CURRENT_BINARY_DIR}/share/${PROJECT_NAME}/hook/ament_prefix_path.dsv + "prepend-non-duplicate;AMENT_PREFIX_PATH;" + ) + install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/share/${PROJECT_NAME}/hook/ament_prefix_path.dsv + DESTINATION + share/${PROJECT_NAME}/hook + ) + +endmacro() \ No newline at end of file From 08a9144f4950e3e394d89f208624553ccb71a4a2 Mon Sep 17 00:00:00 2001 From: artivis Date: Wed, 18 Jan 2023 12:03:25 +0100 Subject: [PATCH 3/3] install package.xml and ament index in eprosima_packaging macro Signed-off-by: artivis --- cmake_utils/CMakeLists.txt | 2 ++ cmake_utils/cmake/packaging/eProsima_packaging.cmake | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/cmake_utils/CMakeLists.txt b/cmake_utils/CMakeLists.txt index 094827a5..f4c459a8 100644 --- a/cmake_utils/CMakeLists.txt +++ b/cmake_utils/CMakeLists.txt @@ -29,6 +29,8 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/project/installation_paths.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/project/configure_project.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/project/cmake_options.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/packaging/install_resources.cmake) +include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/packaging/install_package_xml.cmake) +include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/packaging/install_ament_index.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/packaging/eProsima_packaging.cmake) # Get all variables for project diff --git a/cmake_utils/cmake/packaging/eProsima_packaging.cmake b/cmake_utils/cmake/packaging/eProsima_packaging.cmake index 48f2c9f2..80d69cda 100644 --- a/cmake_utils/cmake/packaging/eProsima_packaging.cmake +++ b/cmake_utils/cmake/packaging/eProsima_packaging.cmake @@ -54,4 +54,10 @@ macro(eprosima_packaging) eprosima_install_resources() + # If compiled with ament, install the index ressources + if(DEFINED ENV{AMENT_PREFIX_PATH}) + install_package_xml() + install_ament_index() + endif() + endmacro()