Ask Your Question
0

catkin_make ignores INCLUDE_DIRS directive in catkin_generate_package

asked 2014-05-28 13:51:32 -0500

bjem85 gravatar image

Hi All,

I am having a problem with catkin_make ignoring an include directory directive. The only way for catkin_make to 'see' it is to use the include_directories(src/include) directive. For some reason the INCLUDE_DIRS directive in catkin_package works in another project of mine just fine, but not in this project. It also has the unpleasant side effect of rebuilding all other projects when include_directories is first used, which is not pleasant if you have RViz in your catkin_make source tree.

Here is the CMakeLists.txt file I am using. There are probably a few unneeded dependencies as this file is derived from another project. I still have not got my head around the intracacies of CMake and its interactoins with catkin_make and ROS.

# Instructions from
# wiki.ros.org/catkin/CMakeLists.txt
#
# 1. Required CMake Version (cmake_minimum_required)
cmake_minimum_required(VERSION 2.8.3)

# 2. Package Name (project())
project(can_bus_read)

# 3. Find other CMake/Catkin packages needed for build (find_package())
find_package(catkin REQUIRED nodelet roscpp rospy std_msgs message_generation sensor_msgs)
find_package(roscpp REQUIRED)

# 4. Message/Service/Action Generators (add_message_files(), add_service_files(), add_action_files())
add_message_files(
   FILES
   canbus_raw.msg
)

# 5. Invoke message/service/action generation (generate_messages())
catkin_python_setup()
generate_messages(DEPENDENCIES sensor_msgs)

# 6. Specify package build info export (catkin_package())
catkin_package(
   INCLUDE_DIRS src/include
   LIBRARIES ${PROJECT_NAME}
   CATKIN_DEPENDS roscpp
   DEPENDS)

# 7. Libraries/Executables to build (add_library()/add_executable()/target_link_libraries())
include_directories(src/include)

add_executable(candump src/candump.c
 src/lib.c
 src/lib.h
 src/terminal.h
 src/include/linux/can.h
 src/include/linux/can/bcm.h
 src/include/linux/can/error.h
 src/include/linux/can/gw.h
 src/include/linux/can/isotp.h
 src/include/linux/can/netlink.h
 src/include/linux/can/raw.h
 )

target_link_libraries(candump ${catkin_LIBRARIES})
add_definitions(-D_LINUX -D__STDC_FORMAT_MACROS -DUSE_INTTYPES__ -DHAVE_PCAP -D_FILE_OFFSET_BITS=64 -DSO_RXQ_OVFL=40 -DPF_CAN=29 -DAF_CAN=PF_CAN)

# 8. Tests to build (catkin_add_gtest())

# 9. Install rules (install()) 

#### END OF FILE #####
`
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2014-05-28 14:45:44 -0500

ahendrix gravatar image

The INCLUDE_DIRS directive to catkin_package is not intended to add include directories to your package; you should use include_directories for that, as you've found.

The catkin_package function specifies which dependencies your package exports to its dependencies. In particular, INCLUDE_DIRS specifies which directory in your package contains the header directory that should be on the include path for any packages that compile against your package.

edit flag offensive delete link more

Comments

Hmmm, the mystery deepens. I will have to find out why my other project has always worked without the `include_directories` directive, despite it having a very similar scenario of having project specific include files in a subdirectory of the code.

bjem85 gravatar image bjem85  ( 2014-05-28 14:57:26 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-05-28 13:51:32 -0500

Seen: 1,467 times

Last updated: May 28 '14