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

CATKIN VS CMAKE

asked 2014-07-24 15:56:24 -0600

Yeshasvi Yeshi gravatar image

updated 2022-01-22 16:16:28 -0600

Evgeny gravatar image

I started working on ROS a while ago and I always used cmake . and make all to build ros packages before. I am working a project now where i have to use api header and source files provided for a product. I did both catkin_make and cmake for a particular package and which i rosrun the node it is asking to select which executable to run from workspace devel space or package devel space. Both of them have different outputs guess because with every update in source code I used cmake but when i run the executable from workspace devel the output is according to the old source code. Can someone please explain me what exactly is happening and what is the best practice using catkin_make or cmake . and make all

Thank you

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
7

answered 2014-07-24 16:29:20 -0600

McMurdo gravatar image

catkin_make is cmake + make!

The only difference is that it sets a few ENV variables before doing the actual cmake and make. At least for practical purposes it is safe to assume this, I guess.

For a catkin package, you don't have to do cmake at all. catkin_make will take care of all that.

One of the greatest advantages with catkin (in my opinion as a rookie user) is that it produces out of source builds - superb for portability, since you could just copy the source folder and compile it anywhere. This was not the case with rosbuild, which was apparently not entirely 'cmake'.

When you do a cmake in the source directory, you are in essence wasting this advantage (again only my opinion).

When you run cmake and make, doing catkin_make again will indeed produce two executables. a cmake + make from catkin will produce one executable in the catkin_workspace/devel. And a cmake + make that you did will produce an executable in the catkin_workspace/src/devel folder.

I suggest that you do ONLY ONE of the following:

  1. catkin_make from the catkin_workspace folder or the base of the catkin_workspace. OR
  2. go into the build directory and create a directory for your build files. suppose your project is called superb_project_1, then you will have sources in catkin_workspace/src/superb_project_1.

Now go into catkin_workspace/build and create a superb_project_1 folder.

Then go into this folder and execute the following command:

cmake ../../src/PROJECT_NAME -DCMAKE_INSTALL_PREFIX=../../install -DCATKIN_DEVEL_PREFIX=../../devel -G"Eclipse CDT4 - Unix Makefiles"

or in this particular case it is

cmake ../../src/superb_project_1 -DCMAKE_INSTALL_PREFIX=../../install -DCATKIN_DEVEL_PREFIX=../../devel -G"Eclipse CDT4 - Unix Makefiles"

Every time you need to build your project, go into build and do

cmake .

make

The last argument, as you are probably already aware, produces Eclipse .project files. It is optional and extremely helpful. Though this command has to be executed each time for every project created, it is extremely useful with eclipse.

Once imported into eclipse, all you have to do is click build project and eclipse takes care of the rest. This method is easy, doesn't involve doing a catkin_make (which means you can simply make just one project - But you take care of dependencies) and also preserves the overall idea of out-of-source builds.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2014-07-24 15:56:24 -0600

Seen: 9,777 times

Last updated: Jul 24 '14