From a3619bf4c1481314c28f2ed479dd96e370288acf Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Fri, 12 Apr 2024 12:58:02 -0700 Subject: [PATCH 1/2] Switch to ament_generate_version_header for tracetools Signed-off-by: Christophe Bedard --- tracetools/CMakeLists.txt | 6 ++---- tracetools/include/tracetools/tp_call.h | 4 +++- tracetools/package.xml | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tracetools/CMakeLists.txt b/tracetools/CMakeLists.txt index cd829d58..605f28f2 100644 --- a/tracetools/CMakeLists.txt +++ b/tracetools/CMakeLists.txt @@ -13,6 +13,7 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") add_compile_options(/W4) endif() +find_package(ament_cmake_gen_version_h REQUIRED) find_package(ament_cmake_ros REQUIRED) if(WIN32 OR APPLE OR ANDROID) @@ -102,6 +103,7 @@ if(NOT TRACETOOLS_DISABLED) set(export_target_options "HAS_LIBRARY_TARGET") endif() ament_export_targets(${PROJECT_NAME}_export ${export_target_options}) +ament_generate_version_header(${PROJECT_NAME}) if(TRACETOOLS_STATUS_CHECKING_TOOL) # Lib for status checking @@ -187,7 +189,3 @@ if(BUILD_TESTING) endif() ament_package() - -if(NOT TRACETOOLS_DISABLED) - target_compile_definitions(${PROJECT_NAME} PRIVATE ${PROJECT_NAME}_VERSION="${${PROJECT_NAME}_VERSION}") -endif() diff --git a/tracetools/include/tracetools/tp_call.h b/tracetools/include/tracetools/tp_call.h index aeb11400..2a9608f9 100644 --- a/tracetools/include/tracetools/tp_call.h +++ b/tracetools/include/tracetools/tp_call.h @@ -32,6 +32,8 @@ #include #include +#include "tracetools/version.h" + /// See RMW_GID_STORAGE_SIZE in rmw. #define TRACETOOLS_GID_STORAGE_SIZE 24u @@ -43,7 +45,7 @@ TRACEPOINT_EVENT( ), TP_FIELDS( ctf_integer_hex(const void *, context_handle, context_handle_arg) - ctf_string(version, tracetools_VERSION) + ctf_string(version, TRACETOOLS_VERSION_STR) ) ) diff --git a/tracetools/package.xml b/tracetools/package.xml index 9ee29e42..cd3ed9c6 100644 --- a/tracetools/package.xml +++ b/tracetools/package.xml @@ -13,6 +13,7 @@ Ingo Lütkebohle Christophe Bedard + ament_cmake_gen_version_h ament_cmake_ros pkg-config From 464bb980742676c2301483ca2655a187e5cec449 Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Mon, 15 Apr 2024 18:25:37 -0700 Subject: [PATCH 2/2] Do not call ament_generate_version_header if TRACETOOLS_DISABLED Signed-off-by: Christophe Bedard --- tracetools/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tracetools/CMakeLists.txt b/tracetools/CMakeLists.txt index 605f28f2..d9784c6f 100644 --- a/tracetools/CMakeLists.txt +++ b/tracetools/CMakeLists.txt @@ -103,7 +103,9 @@ if(NOT TRACETOOLS_DISABLED) set(export_target_options "HAS_LIBRARY_TARGET") endif() ament_export_targets(${PROJECT_NAME}_export ${export_target_options}) -ament_generate_version_header(${PROJECT_NAME}) +if(NOT TRACETOOLS_DISABLED) + ament_generate_version_header(${PROJECT_NAME}) +endif() if(TRACETOOLS_STATUS_CHECKING_TOOL) # Lib for status checking