Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions src/ros2_medkit_cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2026 bburda
#
# 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.

cmake_minimum_required(VERSION 3.8)
project(ros2_medkit_cmake NONE)

find_package(ament_cmake REQUIRED)

# Install cmake modules to the ament share directory.
# The *-extras.cmake hook adds this path to CMAKE_MODULE_PATH automatically.
install(
FILES
cmake/ROS2MedkitCompat.cmake
cmake/ROS2MedkitCcache.cmake
cmake/ROS2MedkitLinting.cmake
DESTINATION share/${PROJECT_NAME}/cmake
)

# Install .clang-tidy config alongside the cmake modules so
# ROS2MedkitLinting.cmake can find it via CMAKE_CURRENT_LIST_DIR.
# Conditional: in colcon workspace the file exists at ../../.clang-tidy;
# on the buildfarm it doesn't, but BUILD_TESTING=OFF so linting is disabled.
set(_CLANG_TIDY_SRC "${CMAKE_CURRENT_SOURCE_DIR}/../../.clang-tidy")
if(EXISTS "${_CLANG_TIDY_SRC}")
install(FILES "${_CLANG_TIDY_SRC}" DESTINATION share/${PROJECT_NAME}/cmake)
endif()

ament_package(
CONFIG_EXTRAS cmake/ros2_medkit_cmake-extras.cmake
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
# Centralizes all dependency resolution workarounds for supporting multiple
# ROS 2 distributions (Humble, Jazzy, Rolling) in a single place.
#
# Usage (in each package's CMakeLists.txt, after find_package(ament_cmake)):
# list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake")
# Usage (in each package's CMakeLists.txt):
# find_package(ros2_medkit_cmake REQUIRED)
# include(ROS2MedkitCompat)
#
# Macros provided:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ include_guard(GLOBAL)
option(ENABLE_CLANG_TIDY "Register clang-tidy as a CTest target" OFF)

# Capture at include-time: inside a function CMAKE_CURRENT_LIST_DIR resolves to the caller.
set(_ROS2_MEDKIT_CLANG_TIDY_CONFIG "${CMAKE_CURRENT_LIST_DIR}/../.clang-tidy")
set(_ROS2_MEDKIT_CLANG_TIDY_CONFIG "${CMAKE_CURRENT_LIST_DIR}/.clang-tidy")

function(ros2_medkit_clang_tidy)
if(NOT ENABLE_CLANG_TIDY)
Expand Down
20 changes: 20 additions & 0 deletions src/ros2_medkit_cmake/cmake/ros2_medkit_cmake-extras.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2026 bburda
#
# 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.

# Automatically sourced by ament after find_package(ros2_medkit_cmake).
# Adds the installed cmake module directory to CMAKE_MODULE_PATH so that
# include(ROS2MedkitCompat), include(ROS2MedkitCcache), and
# include(ROS2MedkitLinting) work transparently.

list(APPEND CMAKE_MODULE_PATH "${ros2_medkit_cmake_DIR}")
15 changes: 15 additions & 0 deletions src/ros2_medkit_cmake/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>ros2_medkit_cmake</name>
<version>0.3.0</version>
<description>Shared CMake modules for ros2_medkit packages (multi-distro compat, ccache, linting)</description>
<maintainer email="bartoszburda93@gmail.com">bburda</maintainer>
<license>Apache-2.0</license>

<buildtool_depend>ament_cmake</buildtool_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
4 changes: 1 addition & 3 deletions src/ros2_medkit_diagnostic_bridge/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake")
find_package(ros2_medkit_cmake REQUIRED)
include(ROS2MedkitCcache)
include(ROS2MedkitLinting)

Expand All @@ -37,8 +37,6 @@ endif()

find_package(ament_cmake REQUIRED)

# Multi-distro compatibility (Humble / Jazzy / Rolling)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake")
include(ROS2MedkitCompat)

find_package(rclcpp REQUIRED)
Expand Down
1 change: 1 addition & 0 deletions src/ros2_medkit_diagnostic_bridge/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<license>Apache-2.0</license>

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>ros2_medkit_cmake</buildtool_depend>

<depend>rclcpp</depend>
<depend>diagnostic_msgs</depend>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Shared cmake modules (multi-distro compat)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake")
# Shared cmake modules (multi-distro compat, ccache, linting)
find_package(ros2_medkit_cmake REQUIRED)
include(ROS2MedkitCompat)

find_package(ament_cmake REQUIRED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<license>Apache-2.0</license>

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>ros2_medkit_cmake</buildtool_depend>

<depend>ros2_medkit_msgs</depend>
<depend>ros2_medkit_gateway</depend>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Shared cmake modules (3 levels up from src/ros2_medkit_discovery_plugins/ros2_medkit_linux_introspection/)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake")
# Shared cmake modules (multi-distro compat, ccache, linting)
find_package(ros2_medkit_cmake REQUIRED)
include(ROS2MedkitCompat)
include(ROS2MedkitCcache)
include(ROS2MedkitLinting)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<license>Apache-2.0</license>

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>ros2_medkit_cmake</buildtool_depend>

<depend>ros2_medkit_gateway</depend>
<depend>nlohmann-json-dev</depend>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Shared cmake modules (multi-distro compat)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake")
# Shared cmake modules (multi-distro compat, ccache, linting)
find_package(ros2_medkit_cmake REQUIRED)
include(ROS2MedkitCompat)

find_package(ament_cmake REQUIRED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<license>Apache-2.0</license>

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>ros2_medkit_cmake</buildtool_depend>

<depend>ros2_medkit_beacon_common</depend>
<depend>ros2_medkit_gateway</depend>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Shared cmake modules (multi-distro compat)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake")
# Shared cmake modules (multi-distro compat, ccache, linting)
find_package(ros2_medkit_cmake REQUIRED)
include(ROS2MedkitCompat)

find_package(ament_cmake REQUIRED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<license>Apache-2.0</license>

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>ros2_medkit_cmake</buildtool_depend>

<depend>ros2_medkit_beacon_common</depend>
<depend>ros2_medkit_msgs</depend>
Expand Down
4 changes: 2 additions & 2 deletions src/ros2_medkit_fault_manager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Multi-distro compatibility (Humble / Jazzy / Rolling)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake")
# Shared cmake modules (multi-distro compat, ccache, linting)
find_package(ros2_medkit_cmake REQUIRED)
include(ROS2MedkitCompat)
include(ROS2MedkitCcache)
include(ROS2MedkitLinting)
Expand Down
1 change: 1 addition & 0 deletions src/ros2_medkit_fault_manager/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<license>Apache-2.0</license>

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>ros2_medkit_cmake</buildtool_depend>

<depend>rclcpp</depend>
<depend>ros2_medkit_msgs</depend>
Expand Down
4 changes: 1 addition & 3 deletions src/ros2_medkit_fault_reporter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake")
find_package(ros2_medkit_cmake REQUIRED)
include(ROS2MedkitCcache)
include(ROS2MedkitLinting)

Expand All @@ -37,8 +37,6 @@ endif()

find_package(ament_cmake REQUIRED)

# Multi-distro compatibility (Humble / Jazzy / Rolling)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake")
include(ROS2MedkitCompat)

find_package(rclcpp REQUIRED)
Expand Down
1 change: 1 addition & 0 deletions src/ros2_medkit_fault_reporter/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<license>Apache-2.0</license>

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>ros2_medkit_cmake</buildtool_depend>

<depend>rclcpp</depend>
<depend>ros2_medkit_msgs</depend>
Expand Down
4 changes: 2 additions & 2 deletions src/ros2_medkit_gateway/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Multi-distro compatibility (Humble / Jazzy / Rolling)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake")
# Shared cmake modules (multi-distro compat, ccache, linting)
find_package(ros2_medkit_cmake REQUIRED)
include(ROS2MedkitCompat)
include(ROS2MedkitCcache)
include(ROS2MedkitLinting)
Expand Down
1 change: 1 addition & 0 deletions src/ros2_medkit_gateway/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<license>Apache-2.0</license>

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>ros2_medkit_cmake</buildtool_depend>

<depend>rclcpp</depend>
<depend>diagnostic_msgs</depend>
Expand Down
4 changes: 2 additions & 2 deletions src/ros2_medkit_integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ endif()

find_package(ament_cmake REQUIRED)

# Multi-distro compatibility (Humble / Jazzy / Rolling)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake")
# Shared cmake modules (multi-distro compat, ccache, linting)
find_package(ros2_medkit_cmake REQUIRED)
include(ROS2MedkitCompat)

find_package(ament_cmake_python REQUIRED)
Expand Down
1 change: 1 addition & 0 deletions src/ros2_medkit_integration_tests/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<license>Apache-2.0</license>

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>ros2_medkit_cmake</buildtool_depend>
<buildtool_depend>ament_cmake_python</buildtool_depend>

<!-- Demo node C++ dependencies -->
Expand Down
4 changes: 2 additions & 2 deletions src/ros2_medkit_serialization/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Multi-distro compatibility (Humble / Jazzy / Rolling)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake")
# Shared cmake modules (multi-distro compat, ccache, linting)
find_package(ros2_medkit_cmake REQUIRED)
include(ROS2MedkitCompat)
include(ROS2MedkitCcache)
include(ROS2MedkitLinting)
Expand Down
1 change: 1 addition & 0 deletions src/ros2_medkit_serialization/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<license>Apache-2.0</license>

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>ros2_medkit_cmake</buildtool_depend>

<depend>rclcpp</depend>
<depend>rcutils</depend>
Expand Down
Loading