Robotics StackExchange | Archived questions

Treat catkin_package() version mismatch as error

Hello everyone,

I wanted to know whether it is possible to treat a version mismatch in my catkin packages as an error. Right now I'm getting a warning like:

CMake Warning at /opt/ros/melodic/share/catkin/cmake/catkin_package.cmake:213 (message):
  catkin_package() version mismatch: the package.xml of 'my_package'
  build_depends on 'my_lib >= 1.4.3', but 'my_lib
  1.4.1' found
Call Stack (most recent call first):
  /opt/ros/melodic/share/catkin/cmake/catkin_package.cmake:102 (_catkin_package)
  CMakeLists.txt:80 (catkin_package)

But it happens that I overlook this warning, so I want catkin to be more strict.

EDIT: To be more clear: I'm handling my versions in the package.xml using the 'versiongt' tags and similar. Adjusting the version in CMakeLists.txt -> findpackage() is not an option for me.

Thanks for answers :)

Asked by tjk on 2018-09-27 03:32:10 UTC

Comments

Answers

You should edit in your CMakelists.txt adding the keyword REQUIRED. This blocks compilation with an error. An example:

find_package(my_lib 1.4.3 REQUIRED)

Asked by aPonza on 2018-09-27 06:47:35 UTC

Comments

While this is a good way to enforce it in the CMakeLists.txt, this is different from what the OP asks (which is how to make the warning given by catkin_package(..) an error). I believe that is not possible, but enforcing the version requirement using find_package(..) is a good alternative.

Asked by gvdhoorn on 2018-09-27 07:14:27 UTC

@tjk: please note that if you do end up using find_package(..), you must add the CMake variables the find script sets (in your case probably my_lib_INCLUDE_DIRS et al.) to statements such as include_directories(..) yourself. They will not longer be part of catkin_INCLUDE_DIRS.

Asked by gvdhoorn on 2018-09-27 07:15:38 UTC

@gvdhoorn You are right. I'm handling the versioning in the package xml using the 'version_gt' tag. Solving this over CMakeLists is not an option for me :(

Asked by tjk on 2018-09-27 09:13:09 UTC

There is no support for enforcing version of dependencies in pkg manifests.

There are some previous Q&As about it on this forum. I don't believe the situation has changed.

See #q254811 fi.

Asked by gvdhoorn on 2018-09-27 09:18:10 UTC

You can call ament_package_xml() which extracts information from the manifest file and then use CMake variables like BUILD_DEPENDS_my_dep_VERSION_GTE to not repeat yourself.

Asked by Dirk Thomas on 2018-10-08 13:01:02 UTC

See https://github.com/ament/ament_cmake/blob/88add8cab0ca579e89e95b3ab343af319c163195/ament_cmake_core/cmake/core/package_xml_2_cmake.py#L82 for what variables are being generated or look in the generated CMake file directly: build/<pkgname>/ament_cmake_core/package.cmake.

Asked by Dirk Thomas on 2018-10-08 13:02:17 UTC

@Dirk Thomas: in a ROS 1 package?

Asked by gvdhoorn on 2018-10-08 13:51:04 UTC

Sorry for the confusion. In ROS 1 you need to call catkin_package_xml() and the file containing the generated CMake variables is in build/<pkgname>/catkin_generated/package.cmake.

Asked by Dirk Thomas on 2018-10-08 13:56:54 UTC