# Revision history [back]

Buried (deep in the catkin documentation)[http://docs.ros.org/api/catkin/html/dev_guide/generated_cmake_api.html] there is a note that after calling catkin_pacakge(), the package version is available as a cmake variable that is named after your package: <packagename>_VERSION

You could make this available to C++ code using the add_definitions cmake command, like:

catkin_package(
# any arguments to catkin_package here
)

add_definitions("-D${PROJECT_NAME}_VERSION=\"${${PROJECT_NAME}_VERSION}\"")  This uses the -D option to the compiler, which is equivalent to a #define. You could use the version in your code as a string, for example: ROS_INFO("Package version is %s", mypackage_VERSION); // replace mypackage with your package name  Buried (deep deep in the catkin documentation)[http://docs.ros.org/api/catkin/html/dev_guide/generated_cmake_api.html] documentation there is a note that after calling catkin_pacakge(), the package version is available as a cmake variable that is named after your package: <packagename>_VERSION You could make this available to C++ code using the add_definitions cmake command, like: catkin_package( # any arguments to catkin_package here ) add_definitions("-D${PROJECT_NAME}_VERSION=\"${${PROJECT_NAME}_VERSION}\"")


This uses the -D option to the compiler, which is equivalent to a #define.

You could use the version in your code as a string, for example:

ROS_INFO("Package version is %s", mypackage_VERSION); // replace mypackage with your package name