diff --git a/tracetools/CMakeLists.txt b/tracetools/CMakeLists.txt index cd829d58..d9784c6f 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,9 @@ if(NOT TRACETOOLS_DISABLED) set(export_target_options "HAS_LIBRARY_TARGET") endif() ament_export_targets(${PROJECT_NAME}_export ${export_target_options}) +if(NOT TRACETOOLS_DISABLED) + ament_generate_version_header(${PROJECT_NAME}) +endif() if(TRACETOOLS_STATUS_CHECKING_TOOL) # Lib for status checking @@ -187,7 +191,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