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

Is there a simple way to find ROS headers in CMake without catkin?

asked 2016-07-06 19:03:09 -0500

dcconner gravatar image

I am building an external library that will be linked in as part of a ros package, but is built outside of Catkin.

I'd like to use some of the ROS messages (e.g. ROS_INFO, ROS_DEBUG) inside this library for debugging.

I have manually modified the CMake to include_directories( /opt/ros/kinetic/include/) and the code works as I want.

I'd like to do something like:

find_package( roscpp )
if (ROSCPP_FOUND)
   include_directories(${ROSCPP_INCLUDE_DIRS})
...

Unfortunately, CMake can't find roscpp without all of the catkin magic.
I don't want to find_package(catkin) as it messes with the normal CMake build setup for the library.

One hack I can think of is to check the ROS_ROOT environment variable, and if it exists, make the include relative to that. But that is a hack that I'd prefer to avoid.

Is there a clean minimal setup that can discover the ROS include directory with pure CMake?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2016-07-06 19:47:42 -0500

Dirk Thomas gravatar image

Your variable names just have the wrong case. You must use roscpp_FOUND and roscpp_INCLUDE_DIRS.

edit flag offensive delete link more

Comments

Gah! Thanks. I thought the example I was following made the tags all upper case.

dcconner gravatar image dcconner  ( 2016-07-07 11:27:21 -0500 )edit
3

answered 2016-07-06 19:20:53 -0500

William gravatar image

You might want to look at: https://github.com/gerkey/ros1_extern...

edit flag offensive delete link more

Comments

Great resource. If you're making a real ROS package, and will be defining new/custom messages, actionlib actions, services etc. then catkin might be your best bet, followed by CMake as described in this link. If you just need to use the roscpp lib, rosserial, predefined message types, etc. then it's possible to just call pkg-config from a Makefile (or similar) to get appropriate flags and other info, also as described in this link. You will need to identify which components provide which roscpp classes/symbols you are using, to pass the pkg-config names when calling pkg-config.

ReedHedges gravatar image ReedHedges  ( 2019-06-03 11:38:59 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2016-07-06 19:03:09 -0500

Seen: 2,102 times

Last updated: Jul 06 '16