Note: This tutorial assumes that you have completed the previous tutorials: Partial Cross.
(!) Please ask about problems and questions regarding this tutorial on Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Install/Uninstall Targets

Description: This shows how to add install/uninstall targets to your package. This is most useful when building strictly c++ packages (no ros) within the ros build environment and you want a regular install step.

Keywords: install uninstall deploy

Tutorial Level: BEGINNER


This is an approach not built into ros and requires your packages to have cmake install targets. However, this can still be a useful way to add an install step to your stack. If you are looking to deploy an entire ros tree, then using Unison is a far simpler approach.

C++ Packages

In practice, this is far more useful when working with ros packages that are strictly c++ packages and want a regular kind of install step. This is great for regular package installs (e.g. ecl packages can be used inside ros or installed on the system).

It is also especially useful in a partial cross where you are not building an ros platform and want to install a target and all of its dependency libs/binaries/other into a fakeroot for later transfer to the embedded board. This allows you far easier scaling and management for (non-ros) embedded development.


  • eros_build/cmake/modules/build_utilities.cmake

  • eros_build/cmake/templates/

  • eros_build/mk/

Package Configuration


Firstly, we need to ensure the root makefile includes the install/uninstall targets defined in To do this, we simply include this so that your root makefile looks as follows:

include $(shell rospack find eros_build)/mk/

Note that this makefile in turn, includes the mk/ file that is usually included when building ros packages.


Your manifest needs to depend on ecl_build so that it can gain access to the cmake modules therein.

  <depend package="eros_build"/>


In your root CMakeLists.txt, you will need to access the api that provides cmake with an uninstall target (cmake does not generate uninstall targets by default). The following lines will do this:

rosbuild_include(eros_build eros_build_utilities)

You can then set up components of your package for installation in the usual cmake way, Some examples: For a library:

rosbuild_add_library(ace ${SOURCES})

For a binary:

rosbuild_add_executable(waykook_ace ${ACE_SOURCES})
install(TARGETS waykook_ace RUNTIME DESTINATION bin)

For a directory:

install(DIRECTORY ${PREFIX}/bin/
        DESTINATION bin


Once this is done, configure your install prefix with rosprefix (or set CMAKE_INSTALL_PREFIX in ROS_ROOT/rosconfig.cmake manually). Example,

mkdir -p /tmp/fakeroot/usr
rosprefix /tmp/fakeroot/usr
roscd mypackage
make install
// later, if needed
make uninstall

Alternatively, you can hook this into rosmake to install a package and all of its dependencies, e.g. to preclean, make and then make install an entire chain:

rosmake --pre-clean --target="install" mypackage

You can then very easily bundle up the libraries and binaries in a tarball for copying across to your embedded board.

Wiki: eros/Tutorials/Install Targets (last edited 2011-04-27 04:19:59 by DanielStonier)