[Documentation] [TitleIndex] [WordIndex

Goal

Configure a regular ros package to be ready for a mingw cross compile.

Even if you're looking to create qt apps, this is still necessary if your msg/srv packages are kept separate (recommended). You may however want to skip to the qt tutorial and come back to this one.

Create the Package

Set up your package as you would usually do for rosbuild1 somewhere in your source tree, e.g.

> roscreate-pkg foo

Confirm that you can build natively (rosbuild1 style) with the usual make command.

Configuring for Rosbuild2

The next step is to make the package rosbuild2 compatible.

Manifest

This involves adding a small excerpt to your manifest.xml which deals with:

An example (from qt_tutorials):

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

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

# CMake for rosbuild1 should follow this as normal.

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

If everything is all ok, you should be able to build a native version in the source tree (rosbuild1)

> roscd foo
> make

and a mingw compiled version in the rosbuild2 parallel build directory (refer to the mingw build environment tutorial.

> cd ~/mingwros/build
> cmake .      # cmake has to rerun to discover your new package
> cd foo
> make -j5     # -jx for number of parallel jobs

2024-03-23 12:44