ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

How to include external automake/autoconf projects into ament_cmake?

asked 2019-09-16 07:55:41 -0600

Hi guys,

I'm porting a package from ROS1 to ROS2 that builds and exposes a 3rd-party project to the ROS world. That external library uses automake and autoconf, and I do not want to change that to stay compatible with upstream provider of the lib. In the past, I used the cmake macro ExternalProject_Add to do this. Now, I am having trouble porting this functionality to ament_cmake.

My initial questions are: 1) What is the preferred way to build, install, and export 3rd-party non-cmake source projects for ament_cmake? 2) Has anybody successfully compiled, installed, and exported such an library using ExternalProject_Add?

I will refine my questions, once the issue has become clearer. ;)

For reference, this is the catkin CMakeLists that I want to port to ROS2: CMakeLists

edit retag flag offensive close merge delete



In the past, I used the cmake macro ExternalProject_Add to do this. Now, I am having trouble porting this functionality to ament_cmake.

I would actually expect this to still be the preferred way to do this in ROS 2 (as essentially 'nothing' has changed afaik).

At least on, the *_vendor packages use ExternalProject_Add(..) quite a bit. See ros2/yaml_cpp_vendor/CMakeLists.txt for instance.

It would be good if you could describe the issues you encountered with ExternalProject_Add in your ROS 2 port.

gvdhoorn gravatar image gvdhoorn  ( 2019-09-16 08:31:05 -0600 )edit

@gvdhoorn Thank you for the fast response and the link to yamlccp. That looks great! I will provide a more detailed description of my issues. For the moment, we continued work by making our own debian for the upstream library, and installing that on the system.

Georg Bartels gravatar image Georg Bartels  ( 2019-09-17 05:40:13 -0600 )edit

Another possible option would be to implement a colcon-automake/autoconf extension which invokes these tools directly. That would avoid the need to use CMake / ExternalProject. It would require more effort for the first package but any following packages would work out-of-the-box. Feel free to ask questions if you want to go that route. E.g. colcon-cmake is also just an extension to support CMake based packages in colcon.

Dirk Thomas gravatar image Dirk Thomas  ( 2019-09-17 10:38:35 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2020-07-25 12:59:01 -0600

updated 2020-07-25 12:59:30 -0600

After some months, I am revisiting this question, and I found a solution. For completeness sake, I post my solution here. It turned out that using ExternalProject_Add was still the easiest solution, after all.

The package contains only CMakeLists.txt, package.xml, readme, and license files.

Relevant parts of package.xml:


The CMakeLists looks like this:

cmake_minimum_required(VERSION 3.5)

find_package(ament_cmake REQUIRED)

ExternalProject_Add(upstream_igh_eml    # Name for custom target
  #--Download step--------------
  #The following TAG should correspond to the same version as your installed kernel modules
  GIT_TAG 7d73d5b2b372b37b95ce5d7bf16aa5b032190004
  TIMEOUT 30           # Time allowed for file download operations
  #--Update/Patch step----------
  UPDATE_COMMAND touch <SOURCE_DIR>/config.h COMMAND mkdir -p <SOURCE_DIR>/include <SOURCE_DIR>/lib    # Source work-tree update command
  #--Configure step-------------
  CONFIGURE_COMMAND touch <SOURCE_DIR>/ChangeLog COMMAND autoreconf -i <SOURCE_DIR> COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR> --disable-kernel --enable-hrtimer --enable-tool  # Build tree configuration command
  #--Build step-----------------
  BUILD_IN_SOURCE 1         # Use source dir for build dir
  #--Install step---------------
  INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}"  # Installation prefix



For understanding: ethercat is a library built by that project and it resides in ${CMAKE_CURRENT_BINARY_DIR}/lib after ExternalProject_Add completed. Headers are in ${CMAKE_CURRENT_BINARY_DIR}/include after the macro. I was surprised that ament_export_include_directories(include) actually did the right thing even though I neither specified an absolute path nor is there such a directory in the source repository.

edit flag offensive delete link more

answered 2020-08-03 12:17:14 -0600

Dirk Thomas gravatar image

The alternative of wrapping automake / autoconf as an external project in CMake would be to implement an extension to colcon to handle such packages natively. While that would be some more effort it would allow more specific features and also work for other automake / autoconf packages in the future.

edit flag offensive delete link more

Question Tools



Asked: 2019-09-16 07:55:41 -0600

Seen: 1,486 times

Last updated: Aug 03 '20