[Documentation] [TitleIndex] [WordIndex

Overview

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 both explicit package by package control and a regular install step.

Caveats

Ros Packages

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 (i.e. no ros package dependencies) and want a regular ./configure, make, make install kind of install step. 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.

Resources

Package Configuration

Makefile

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

include $(shell rospack find eros_build)/mk/installer.mk

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

Manifest

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

  <depend package="eros_build"/>

CMakeLists

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:

include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
rosbuild_init()
rosbuild_include(eros_build eros_build_utilities)
eros_add_uninstall_target()

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})
install(TARGETS ace DESTINATION lib PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)

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
        USE_SOURCE_PERMISSIONS
        )

Usage

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


2024-11-09 14:29