• Diff for "rosbuild"
Differences between revisions 25 and 26
Revision 25 as of 2010-01-13 03:17:28
Size: 6958
Editor: BrianGerkey
Comment:
Revision 26 as of 2010-01-13 19:49:45
Size: 7021
Editor: VijayPradeep
Comment:
Deletions are marked like this. Additions are marked like this.
Line 69: Line 69:
    * {{{     * Turn on static libs, but turn off shared libs: {{{
Line 77: Line 77:
}}}Another example, changing the warnings:{{{ }}}
    *
Another example, changing the warnings:{{{
Line 84: Line 85:
}}}Another example, changing from Debug to Release build:{{{ }}}
    *
Another example, changing from Debug to Release build:{{{

  Show EOL distros: 

ros: mk | rosbash | rosboost_cfg | rosbuild | rosclean | roscreate | rosdep | rosemacs | roslang | roslib | rosmake | rospack | rosunit

Package Summary

rosbuild contains scripts for managing the CMake-based build system for ROS.

Package Summary

rosbuild contains scripts for managing the CMake-based build system for ROS.

ros: mk | rosbash | rosboost_cfg | rosbuild | rosclean | roscreate | roslang | roslib | rosmake | rosunit

Package Summary

rosbuild contains scripts for managing the CMake-based build system for ROS.

ros: mk | rosbash | rosboost_cfg | rosbuild | rosclean | roscreate | roslang | roslib | rosmake | rosunit

Package Summary

rosbuild contains scripts for managing the CMake-based build system for ROS.

  • Maintainer status: maintained
  • Maintainer: Dirk Thomas <dthomas AT osrfoundation DOT org>
  • Author: Brian Gerkey, Troy Straszheim, Morgan Quigley
  • License: BSD
  • Source: git https://github.com/ros/ros.git (branch: groovy-devel)
ros: mk | rosbash | rosboost_cfg | rosbuild | rosclean | roscreate | roslang | roslib | rosmake | rosunit

Package Summary

rosbuild contains scripts for managing the CMake-based build system for ROS.

  • Maintainer status: maintained
  • Maintainer: Dirk Thomas <dthomas AT osrfoundation DOT org>
  • Author: Brian Gerkey, Troy Straszheim, Morgan Quigley
  • License: BSD
  • Source: git https://github.com/ros/ros.git (branch: hydro-devel)
ros: mk | rosbash | rosboost_cfg | rosbuild | rosclean | roscreate | roslang | roslib | rosmake | rosunit

Package Summary

rosbuild contains scripts for managing the CMake-based build system for ROS.

  • Maintainer status: maintained
  • Maintainer: Dirk Thomas <dthomas AT osrfoundation DOT org>
  • Author: Brian Gerkey, Troy Straszheim, Morgan Quigley
  • License: BSD
  • Source: git https://github.com/ros/ros.git (branch: indigo-devel)
ros: mk | rosbash | rosboost_cfg | rosbuild | rosclean | roscreate | roslang | roslib | rosmake | rosunit

Package Summary

rosbuild contains scripts for managing the CMake-based build system for ROS.

  • Maintainer status: maintained
  • Maintainer: Dirk Thomas <dthomas AT osrfoundation DOT org>
  • Author: Brian Gerkey, Troy Straszheim, Morgan Quigley
  • License: BSD
  • Source: git https://github.com/ros/ros.git (branch: jade-devel)
ros: mk | rosbash | rosboost_cfg | rosbuild | rosclean | roscreate | roslang | roslib | rosmake | rosunit

Package Summary

rosbuild contains scripts for managing the CMake-based build system for ROS.

  • Maintainer status: maintained
  • Maintainer: Dirk Thomas <dthomas AT osrfoundation DOT org>
  • Author: Brian Gerkey, Troy Straszheim, Morgan Quigley
  • License: BSD
  • Source: git https://github.com/ros/ros.git (branch: kinetic-devel)
ros: mk | rosbash | rosboost_cfg | rosbuild | rosclean | roscreate | roslang | roslib | rosmake | rosunit

Package Summary

rosbuild contains scripts for managing the CMake-based build system for ROS.

  • Maintainer status: maintained
  • Maintainer: Dirk Thomas <dthomas AT osrfoundation DOT org>
  • Author: Brian Gerkey, Troy Straszheim, Morgan Quigley
  • License: BSD
  • Source: git https://github.com/ros/ros.git (branch: kinetic-devel)
ros: mk | rosbash | rosboost_cfg | rosbuild | rosclean | roscreate | roslang | roslib | rosmake | rosunit

Package Summary

rosbuild contains scripts for managing the CMake-based build system for ROS.

  • Maintainer status: maintained
  • Maintainer: Michel Hidalgo <michel AT ekumenlabs DOT com>, Jacob Perron <jacob AT openrobotics DOT org>
  • Author: Brian Gerkey, Troy Straszheim, Morgan Quigley, Dirk Thomas <dthomas AT openrobotics DOT org>
  • License: BSD
  • Source: git https://github.com/ros/ros.git (branch: noetic-devel)

Overview

The core build tool ROS uses is CMake. CMake is a powerful cross-platform build tool that provides both configure and make functionality. The ROS build system is currently focused on x86 platforms.

To build packages, use rosmake.

Every ROS package should have the following three files in its top-level directory:

  • CMakeLists.txt : a CMake build file, possibly using ROS macros

  • manifest.xml : the package manifest.xml. This file include the license, author, and description information. It also includes packages on which this package depends, and provides compiler and linker flags for other packages that depend on this one.

  • Makefile : a standard Makefile. For backward compatibility, we still invoke make to build a package. For all new packages, the Makefile should contain just one line, which will properly invoke CMake:

    • include $(shell rospack find mk)/cmake.mk

API (writing a CMakeLists.txt file)

Most of rosbuild is an API for writing CMakeLists.txt files that are used to control the build and test of packages. See API documentation.

Cross-Compiling

ROS does not yet have strong support for cross compiling, though there has been some success building ROS for non-x86 platforms. You can see our notes on cross-compiling to find out more.

Customizing the build (debug, optimizations, etc.)

There are a number of things that you might want to change about how the build occurs, such as debug vs. optimization, and shared vs. static libraries. The system defaults for ROS are specified in $ROS_ROOT/core/rosbuild/rosconfig.cmake; do not edit this file:

# Set the build type.  Options are:
#  Coverage       : w/ debug symbols, w/o optimization, w/ code-coverage
#  Debug          : w/ debug symbols, w/o optimization
#  Release        : w/o debug symbols, w/ optimization
#  RelWithDebInfo : w/ debug symbols, w/ optimization
#  MinSizeRel     : w/o debug symbols, w/ optimization, stripped binaries
if(NOT DEFINED ROS_BUILD_TYPE)
  set(ROS_BUILD_TYPE Debug)
endif(NOT DEFINED ROS_BUILD_TYPE)

# Build static-only executables (e.g., for copying over to another
# machine)? true or false
if(NOT DEFINED ROS_BUILD_STATIC_EXES)
  set(ROS_BUILD_STATIC_EXES false)
endif(NOT DEFINED ROS_BUILD_STATIC_EXES)

# Build shared libs? true or false
if(NOT DEFINED ROS_BUILD_SHARED_LIBS)
  set(ROS_BUILD_SHARED_LIBS true)
endif(NOT DEFINED ROS_BUILD_SHARED_LIBS)

# Build static libs? true or false
if(NOT DEFINED ROS_BUILD_STATIC_LIBS)
  set(ROS_BUILD_STATIC_LIBS false)
endif(NOT DEFINED ROS_BUILD_STATIC_LIBS)

# Default compile flags for all source files
if(NOT DEFINED ROS_COMPILE_FLAGS)
  set(ROS_COMPILE_FLAGS "-W -Wall -Wno-unused-parameter -fno-strict-aliasing")
endif(NOT DEFINED ROS_COMPILE_FLAGS)

# Default link flags for all executables and libraries
if(NOT DEFINED ROS_LINK_FLAGS)
  set(ROS_LINK_FLAGS "")
endif(NOT DEFINED ROS_LINK_FLAGS)

You can override the system defaults by set()ting different values in three places, listed here in increasing priority (i.e., later settings overwrite earlier ones):

  1. The current package's CMakeLists.txt (i.e., the content *preceding* the rosbuild_init() invocation), e.g.:

    • Turn on static libs, but turn off shared libs:

      cmake_minimum_required(VERSION 2.4.6)
      include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
      # Turn off shared libs and turn on static libs, just for this package
      set(ROS_BUILD_STATIC_LIBS true)
      set(ROS_BUILD_SHARED_LIBS false)
      rosbuild_init()
      rosbuild_add_library(mylib mysrc.cpp)
    • Another example, changing the warnings:

      cmake_minimum_required(VERSION 2.4.6)
      include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
      # Turn on higher warnings, because I'm hard-core
      set(ROS_COMPILE_FLAGS "-W -Wall -Wextra -pedantic")
      rosbuild_init()
      rosbuild_add_library(mylib mysrc.cpp)
    • Another example, changing from Debug to Release build:

      cmake_minimum_required(VERSION 2.4.6)
      include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
      # Go to a release build, because I'm done debugging and I want compiler optimizations
      set(ROS_BUILD_TYPE Release)
      rosbuild_init()
      rosbuild_add_library(mylib mysrc.cpp)
  2. If present, $(ROS_ROOT)/rosconfig.cmake, e.g.:
    • # I want both static and shared libs for all ROS packages (shared are enabled by default)
      set(ROS_BUILD_STATIC_LIBS true)
  3. If present, rosconfig.cmake in the current package's top-level directory, e.g.:
    • # I want just static libs, just for this package
      set(ROS_BUILD_STATIC_LIBS true)
      set(ROS_BUILD_SHARED_LIBS false)

NOTE: this ordering is a little non-intuitive, in that the setting in the package's CMakeLists.txt is overridden by the settings in the rosconfig.cmake files.

Miscellaneous configurations

Using the Intel Compilers

To compile ROS with Intel C/C++ compiler, first install Intel compilers as instructed on the Intel website. Next, modify your CMakeLists.txt in the ROS package to contain the following lines:

set (CMAKE_C_COMPILER $(INTEL_DIR)/bin/icc)
set (CMAKE_CXX_COMPILER $(INTEL_DIR)/bin/icpc)

set (CMAKE_C_EXECUTABLE $(INTEL_DIR)/bin/xild)
set (CMAKE_CXX_EXECUTABLE $(INTEL_DIR)/bin/xild)

set (CMAKE_C_FLAGS   "-msse3 -ip  -no-prec-div         -parallel -O3 -fPIC" )
set (CMAKE_CXX_FLAGS "-msse3 -ip  -no-prec-div         -parallel -O3 -fPIC" )

set (CMAKE_EXE_LINKER_FLAGS  "-Wl,-rpath,$(INTEL_DIR)/lib -L$(INTEL_DIR)/lib -lguide -lcxaguard -limf -lsvml -lirc -lpthread -lintlc" )

Where $(INTEL_DIR) is the Intel compiler install directory (e.g. /opt/intel/cc/10.1.008), optimization flags used here are optional.

If the package you want to compile is a third-party package (e.g. ODE), you will need to customize the Makefiles and pass in the correct flags.

Using ccache and distcc

The ROS build system can take advantage of ccache and distcc. Just configure them as you normally would.

E.g., to enable ccache:

export PATH=/usr/lib/ccache:$PATH

Make sure that

which gcc

points to ccache's wrapper (e.g., /usr/lib/ccache/gcc).

E.g., to enable distcc, in concert with ccache, assuming that you have four machines, named pre1 through pre4:

export DISTCC_HOSTS='@pre1/1 @pre2/1 @pre3/1 @pre4/1'
export CCACHE_PREFIX=distcc

Parallel jobs

If you have a multi-core machine, you can set ROS_PARALLEL_JOBS to take advantage of it during the build.

Wiki: rosbuild (last edited 2019-11-27 12:46:01 by jschleicher)