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

Revision history [back]

gvdhoorn's answer pointed me into the right direction. I provide my own solution for documentation.

Here is the CMakeLists of igh_eml which checks out and builds the external mercurial repository:

cmake_minimum_required(VERSION 2.8.3)
project(igh_eml)

find_package(catkin REQUIRED)

include(ExternalProject)
ExternalProject_Add(upstream_igh_eml
  HG_REPOSITORY http://hg.code.sf.net/p/etherlabmaster/code
  HG_TAG 792892ab4806
  TIMEOUT 30
  UPDATE_COMMAND touch <SOURCE_DIR>/config.h COMMAND mkdir -p <SOURCE_DIR>/include <SOURCE_DIR>/lib
  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_IN_SOURCE 1
  INSTALL_DIR ${CATKIN_DEVEL_PREFIX}
)

add_library(ethercat SHARED IMPORTED)
set_target_properties(ethercat PROPERTIES IMPORTED_LOCATION ${CATKIN_DEVEL_PREFIX}/lib/libethercat.so)
add_dependencies(ethercat upstream_igh_eml)

catkin_package(
    LIBRARIES ethercat
)

Important notes: (1) catkin_package has to be called AFTER the build and import calls. (2) Exporting the include files at ${CATKIN_DEVEL_PREFIX}/include with catkin_package was not possible, that directory does not exist when catkin_package is interpreted.

The depending package omnidrive_ethercat has the following CMakeLIsts:

cmake_minimum_required(VERSION 2.8.3)
project(omni_ethercat)

find_package(catkin REQUIRED COMPONENTS ... igh_eml ...)

catkin_package(
  CATKIN_DEPENDS ... igh_eml ...)

include_directories(include ${catkin_INCLUDE_DIRS})

add_executable(omni_ethercat src/omni_ethercat.cpp src/omnilib/omnilib.c src/omnilib/realtime.c)
target_link_libraries(omni_ethercat ${catkin_LIBRARIES})
add_dependencies(omni_ethercat upstream_igh_eml)

Important note: I have to directly depend on the build target upstream_igh_eml to halt compilation until all the h-files and so-files in igh_eml have been downloaded and built. The target ethercat was not enough. Also, I did not find out how to export this target through a CMake variable.

So, this a working solution, but there is room for improvement...