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

Using ExternalProject_Add with catkin

asked 2013-05-22 09:03:25 -0500

derekjchow gravatar image

updated 2014-01-28 17:16:36 -0500

ngrennan gravatar image

I've been trying to add an external project to catkin using the ExternalProject_Add feature in CMake. My CMakeLists.txt files looks something like follows:

cmake_minimum_required(VERSION 2.8.3)

include(ExternalProject)

ExternalProject_Add( foreignproject
  PREFIX foreignprojectlib
  GIT_REPOSITORY foreignproject.git
  BUILD_IN_SOURCE
  BUILD_COMMAND cmake --build .
  INSTALL_COMMAND ""
)

project(rosproject)

catkin_package(
  INCLUDE_DIRS include ${DIRECTORY_TO_FOREIGN_PROJECT_HEADERS}
  LIBRARIES rosproject foreignproject
  CATKIN_DEPENDS opencv2 roscpp tf
  DEPENDS system_lib
)

include_directories(include
  ${catkin_INCLUDE_DIRS}
)

add_executable(rosnode src/rosnode.cpp)

The problem I am coming across is that the header file from the external project is not being found. In fact, I'm finding that catkin_make (-j1) tries to build rosnode before it builds the external library. Could someone explain the proper way of using ExternalProject_Add or post an example of a CMakeLists.txt file that successfully uses ExternalProject_Add?

edit retag flag offensive close merge delete

Comments

Hi there! I've found myself in a similar situation. Have you found a solution/workaround yet?

Murilo F. M. gravatar image Murilo F. M.  ( 2013-07-18 12:49:37 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
2

answered 2013-07-18 15:33:02 -0500

ahendrix gravatar image

I believe catkin_package sets the include directories for downstream projects, but does not set the include directories for the current project.

You probably also need to do:

include_directories(
    include
    ${catkin_INCLUDE_DIRS}
    ${DIRECTORY_TO_FOREIGN_PROJECT_HEADERS}
)

Also, what @William said.

edit flag offensive delete link more
1

answered 2013-07-18 13:55:32 -0500

William gravatar image

You probably need to add a dependency on the external project target, so that the node is built later:

add_dependencies(rosnode foreignproject)
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2013-05-22 09:03:25 -0500

Seen: 3,713 times

Last updated: Jul 18 '13