ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Treat catkin_package() version mismatch as error

asked 2018-09-27 03:32:10 -0600

tjk gravatar image

updated 2018-09-27 09:14:29 -0600

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 'version_gt' tags and similar. Adjusting the version in CMakeLists.txt -> find_package() is not an option for me.

Thanks for answers :)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-09-27 06:47:35 -0600

aPonza gravatar image

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)

edit flag offensive delete link more

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.

gvdhoorn gravatar image gvdhoorn  ( 2018-09-27 07:14:27 -0600 )edit
1

@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.

gvdhoorn gravatar image gvdhoorn  ( 2018-09-27 07:15:38 -0600 )edit

@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 :(

tjk gravatar image tjk  ( 2018-09-27 09:13:09 -0600 )edit

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.

gvdhoorn gravatar image gvdhoorn  ( 2018-09-27 09:18:10 -0600 )edit

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.

Dirk Thomas gravatar image Dirk Thomas  ( 2018-10-08 13:01:02 -0600 )edit

See https://github.com/ament/ament_cmake/... for what variables are being generated or look in the generated CMake file directly: build/<pkgname>/ament_cmake_core/package.cmake.

Dirk Thomas gravatar image Dirk Thomas  ( 2018-10-08 13:02:17 -0600 )edit

@Dirk Thomas: in a ROS 1 package?

gvdhoorn gravatar image gvdhoorn  ( 2018-10-08 13:51:04 -0600 )edit

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.

Dirk Thomas gravatar image Dirk Thomas  ( 2018-10-08 13:56:54 -0600 )edit

Question Tools

Stats

Asked: 2018-09-27 03:32:10 -0600

Seen: 195 times

Last updated: Sep 27 '18