Ask Your Question
22

How to build just one package using catkin_make?

asked 2013-02-04 00:39:58 -0500

TommyP gravatar image

How do I build just one package using catkin_make? I now that I can cd to the build directory and build there but that is inconvenient. And how do I build one package and its dependencies?

edit retag flag offensive close merge delete

4 Answers

Sort by » oldest newest most voted
41

answered 2013-09-03 23:32:09 -0500

fivef gravatar image

updated 2019-06-16 11:43:00 -0500

catkin_make --pkg <my_package_name> Example:

catkin_make --pkg turtlebot

Multiple Packages:

catkin_make --pkg <package A> <package B>

But as this doesn't work robustly I recommend switching to catkin_tools which allows to build only one package and many more fancy features:

Catkin-Tools: Build Subset of Packages

edit flag offensive delete link more

Comments

1

You can also use `--from-pkg <package>` to skip to that package and then continue building the workspace after that.

William gravatar imageWilliam ( 2013-09-04 06:56:36 -0500 )edit
4

Is there any reason why I run this option and it keeps compiling everything within the catkin workspace?

Javier V. Gómez gravatar imageJavier V. Gómez ( 2013-11-22 02:44:10 -0500 )edit

Which option? If you mean the `--from-pkg <package>` option, if you specify the first package in the workspace then it will build them all. The idea is that it skips all packages which come before the one you specify, but builds that one package and all packages that follow it.

William gravatar imageWilliam ( 2013-11-22 08:47:13 -0500 )edit
5

I personally feel this is an important thing that ought to to be mentioned in the tutorials.

McMurdo gravatar imageMcMurdo ( 2014-01-07 02:36:57 -0500 )edit
2

I have the same problem as Javi V: I try to use this to make 1 package but it makes all the packages in the catkin_ws

edit: today it worked for reasons I don't understand.

korkor gravatar imagekorkor ( 2015-05-05 07:14:14 -0500 )edit
1

I also occasionally try to use this trick and it rarely works. It just builds all of the packages still. I also can't tab complete my package.

shoemakerlevy9 gravatar imageshoemakerlevy9 ( 2017-03-10 09:49:01 -0500 )edit

It did not worked for me either. catkin_make -DCATKIN_WHITELIST_PACKAGES="foo;bar" command worked.

burakaksoy gravatar imageburakaksoy ( 2018-11-26 18:53:16 -0500 )edit
15

answered 2013-02-04 01:23:07 -0500

KruseT gravatar image

Hi Tommy,

you can configure(!) a catkin workspace to only build one package using -DCATKIN_WHITELIST_PACKAGES

# "List of ';' separated packages to build"
catkin_make -DCATKIN_WHITELIST_PACKAGES="foo;bar"

This should really be documented in the docs and wiki. If you want to build more packages, you'd have to reconfigure.

Other than that, catkin relies on cmake, which generates targets named like the subfolders. So calling catkin_make <targetname> (or make <targetname> in a build folder) will make just this target, and all target it depends on.

Finally you can use catkin_build_isolated, which really invokes cmake+make for each package. It creates isolated build folders in which you can invoke make. If you#d like to suggest for catkin to provide for this in another way(such as an option to place the isolated build folders within the packagefolders, feel free to open an enhancement ticket on github.

edit flag offensive delete link more

Comments

3

Should catkin_make PACKAGE work, because for me it seems to do nothing?

dornhege gravatar imagedornhege ( 2013-02-04 01:49:44 -0500 )edit

I also have tested "catkin_make PACKAGE" and thought that that would work but it does not. That I could use "catkin_make TARGET" was not something I though about testing since I did not think it would work because of name collisions between targets. But it did work and can be very useful.

TommyP gravatar imageTommyP ( 2013-02-04 02:16:23 -0500 )edit

Wait, did it work for you or not?

dornhege gravatar imagedornhege ( 2013-02-04 02:53:48 -0500 )edit

No it does not. But e.g. "catkin_make mpinfo" were mpinfo is a target in the package lrs_quad works.

TommyP gravatar imageTommyP ( 2013-02-04 03:33:22 -0500 )edit

Doesn't work for me either. I'm not sure if it should. I don't want to hijack your question, so I described the problem here: http://answers.ros.org/question/54215/should-catkin_make-work-for-package-targets/ - the solution might be related though.

dornhege gravatar imagedornhege ( 2013-02-04 04:05:27 -0500 )edit

This solution worked for me: catkin_make -DCATKIN_WHITELIST_PACKAGES=foo;bar

fabbro gravatar imagefabbro ( 2018-02-22 10:09:23 -0500 )edit
1

catkin_make -DCATKIN_WHITELIST_PACKAGES="foo;bar" works fine but be aware that you will have to run catkin_make -DCATKIN_WHITELIST_PACKAGES="" to be able to build all your packages again. Also catkin_make -DCATKIN_BLACKLIST_PACKAGES="foo;bar" can be useful not to build some packages.

Delb gravatar imageDelb ( 2018-02-23 03:19:25 -0500 )edit

Hi Delb, thanks for that extra comment about building all packages again. The same thing may be said about blacklisted packages ( if you have a blacklisted package, just setting whitelisted = "" doesn't work... you will need to set blacklisted="" as well,, or remove it from blacklisted list somehow)

malharjajoo gravatar imagemalharjajoo ( 2018-06-05 16:38:13 -0500 )edit
1

answered 2019-05-29 21:31:21 -0500

Rufus gravatar image

updated 2019-05-29 21:34:42 -0500

The aforementioned answers are incorrect, --pkg still includes all packages as documented here which means if some untargeted package have unmet dependencies, the build will fail.

CATKIN_WHITELIST_PACKAGE does not correctly build dependent packages of the whitelisted package

The proper way is catkin_make --only-pkg-with-deps <target_package>

edit flag offensive delete link more

Comments

This command worked for me. The currently selected answer, catkin_make --pkg <package A> did not, as others noted it built all packages.

bakerhillpins gravatar imagebakerhillpins ( 2019-06-21 08:29:01 -0500 )edit
0

answered 2016-08-16 06:06:25 -0500

user23fj239 gravatar image

updated 2016-08-16 06:07:34 -0500

Add this to your CMakeLists.txt :

OPTION(BUILD_PACKAGE_X "Build package X")
# switch it ON or OFF depending on what you want
set(BUILD_PACKAGE_X ON)
if (BUILD_PACKAGE_X)

# paste your CMakeLists text here

#endif()

Another solution:
put an empty file with the name CATKIN_IGNORE into the package directory.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-02-04 00:39:58 -0500

Seen: 52,964 times

Last updated: Jun 16