[Documentation] [TitleIndex] [WordIndex

Rosbuild2

Goal: Creating rosbuild1+rosbuild2 compatible packages.

These notes assume you've already created parallel build directories build/debug and build/release for rosbuild2 and set it up with the appropriate call to cmake as outlined in the Visual Studio Build Environment tutorial.

Creating Packages

Set up your package as you would usually do for rosbuild1 somewhere in your source tree. We don't have roscreate-pkg so just copy across files by hand.

> mkdir new_foo
> cp existing_foo/manifest.xml new_foo
> cp existing_foo/Makefile new_foo
> cp existing_foo/CMakeLists.txt new_foo

Modifications

A regular ros package requires some modifications to make it both rosbuild1 and rosbuild2 compatible.

Manifest

Add a small excerpt to your manifest.xml which deals with:

A complete example (from qt_tutorials in the qt_ros stack).

<rosbuild2>
   <!-- private dependencies -->
   <depend package="qt_build"/>
   <!-- ros dependencies -->
   <depend package="roscpp"/>
   <depend package="std_msgs"/>
   <!-- system dependencies -->
   <rosdep name="qt4"/>
   <!-- msg/srv's -->
   <srvs>srv/TwoInts.srv</srvs>
</rosbuild2>

CMake

You'll need an alternative CMakeLists.txt for when your project detects rosbuild2.

The usual method is to insert an alternative call at the top of your CMakeLists.txt:

f(ROSBUILD)  
  # This is the rosbuild2 path
  include(rosbuild.cmake OPTIONAL)
  return()
endif()

# CMake for rosbuild1 should follow this.

and then in rosbuild.cmake put the rosbuild2 compatible cmake. Most of the function calls are essentially the same - the only really big difference is that msg and srv generation is no longer needed in the cmake itself - it's automatic.

Most of the fundamental ros packages have this embedded already - browse the CMakeLists.txt and rosbuild.cmake in packages such as cpp_common, rostime, roscpp for examples. Keep in mind that the cmake for rosbuild2 is stored in the cmake stack, not rosbuild.

Building

<!> Rosbuild2 builds in a parallel build directory to the whole ros tree.

This differs from rosbuild1 - where it simply builds in a parallel directory of an individual package. Remember that we're talking about rosbuild2 parallel directories below, either build/debug or build/release.

Configure

If you re-run cmake in an existing rosbuild2 parallel build dir, it will rescan your package list, find your new package and configure it for the build.

> cd build\debug      # or build\release
> cmake .             # this will discover your new package

Build

Usually simply changing to the package directory under the parallel build directory, followed by a make,nmake will do. e.g.

> cd build\debug      # or build\release
> cd roscpp_tutorials
> nmake
> cd ..\foo
> nmake           # windows-msvc
> nmake install   

Note the last install step - that is optional and will install binaries, headers, libraries and anything else you've manually marked in your cmake to the CMAKE_INSTALL_PREFIX root.

Global Build Options

To modify global build options (e.g. debug, release, install prefix):

> cd build\debug      # or build\release
> cmake-gui .

Do some modifications to the cached variables and then remake.


2024-11-23 17:59