From 1cbb441c5f1a9bc5cf6ba9ed7cda3b68bc1d66dc Mon Sep 17 00:00:00 2001 From: Jose Luis Blanco-Claraco Date: Sun, 28 Jan 2024 19:33:32 +0100 Subject: [PATCH] FIX: include deprecated header --- mola_input_rosbag2/CMakeLists.txt | 39 +++++++++++++++++++++++ mola_input_rosbag2/src/Rosbag2Dataset.cpp | 5 +++ 2 files changed, 44 insertions(+) diff --git a/mola_input_rosbag2/CMakeLists.txt b/mola_input_rosbag2/CMakeLists.txt index 927c5477..c8d26efc 100644 --- a/mola_input_rosbag2/CMakeLists.txt +++ b/mola_input_rosbag2/CMakeLists.txt @@ -53,3 +53,42 @@ mola_add_library( mrpt-obs mrpt-ros2bridge ) + +# Credits: https://gist.github.com/jtanx/96ded5e050d5ee5b19804195ee5cf5f9 +function(pad_string output str padchar length) + string(LENGTH "${str}" _strlen) + math(EXPR _strlen "${length} - ${_strlen}") + + if(_strlen GREATER 0) + string(REPEAT ${padchar} ${_strlen} _pad) + string(PREPEND str ${_pad}) + endif() + + set(${output} "${str}" PARENT_SCOPE) +endfunction() + +# 2 hex digits for each version part: +# For example: "0.5.1" => "0x000501" +macro(mrpt_version_to_hex VER TARGET_VAR_NAME) + string(REGEX MATCHALL "[0-9]+" __parts "${${VER}}") + + if(__parts) + list(GET __parts 0 __VERSION_NUMBER_MAJOR) + list(GET __parts 1 __VERSION_NUMBER_MINOR) + list(GET __parts 2 __VERSION_NUMBER_PATCH) + pad_string(__VERSION_NUMBER_MAJOR ${__VERSION_NUMBER_MAJOR} "0" 2) + pad_string(__VERSION_NUMBER_MINOR ${__VERSION_NUMBER_MINOR} "0" 2) + pad_string(__VERSION_NUMBER_PATCH ${__VERSION_NUMBER_PATCH} "0" 2) + set(${TARGET_VAR_NAME} "0x${__VERSION_NUMBER_MAJOR}${__VERSION_NUMBER_MINOR}${__VERSION_NUMBER_PATCH}") + else() + set(${TARGET_VAR_NAME} "0x000") + endif() +endmacro() + +# Convert package versions to hex so they can be used in preprocessor for wider +# versions compatibility of "one-source for all": +mrpt_version_to_hex(cv_bridge_VERSION cv_bridge_VERSION_HEX) + +target_compile_definitions(${PROJECT_NAME} PRIVATE CV_BRIDGE_VERSION=${cv_bridge_VERSION_HEX}) + +message(STATUS "Found: cv_bridge_VERSION: ${cv_bridge_VERSION} (${cv_bridge_VERSION_HEX})") \ No newline at end of file diff --git a/mola_input_rosbag2/src/Rosbag2Dataset.cpp b/mola_input_rosbag2/src/Rosbag2Dataset.cpp index 896a98b3..d75e478d 100644 --- a/mola_input_rosbag2/src/Rosbag2Dataset.cpp +++ b/mola_input_rosbag2/src/Rosbag2Dataset.cpp @@ -38,7 +38,12 @@ #include #include +#if CV_BRIDGE_VERSION < 0x030400 +#include +#else #include +#endif + #include #include #include