0
$\begingroup$

Rosanswers logo

I have a problem where I want to depend on a newer interface than what is in the debain install. To do this I am building the library I'm depending on (moveit) from source in an upstream workspace. However for some reason catkin/cmake is creating an include list that is always including the debian based includes first. This is from the compile step:

-I/opt/ros/melodic/include```

Here is the documentation from the man page of `g++` (-isystem is always searched after -I):

           The lookup order is as follows:
       1.  For the quote form of the include directive, the directory of the current file is searched first.
       2.  For the quote form of the include directive, the directories specified by -iquote options are searched in left-to-right
           order, as they appear on the command line.
       3.  Directories specified with -I options are scanned in left-to-right order.
       4.  Directories specified with -isystem options are scanned in left-to-right order.
       5.  Standard system directories are scanned.
       6.  Directories specified with -idirafter options are scanned in left-to-right order.

How can I instruct catkin/cmake to include my upstream include path first (by changing the -isystem to -I or something similar)?

Here are the relevant parts of my CMakeLists.txt:

    find_package(catkin REQUIRED COMPONENTS
      moveit_core
      moveit_ros_planning
      moveit_ros_planning_interface
      roscpp
    )
    
    catkin_package(
      CATKIN_DEPENDS
        moveit_core
        moveit_ros_planning
        moveit_ros_planning_interface
        roscpp
      INCLUDE_DIRS
        include
      LIBRARIES
        ${PROJECT_NAME}
      DEPENDS
        Boost
        EIGEN3
    )
    
    include_directories(
      include/
      ${catkin_INCLUDE_DIRS}
  ${Boost_INCLUDE_DIR}
      ${EIGEN3_INCLUDE_DIRS})
    
    add_library(${PROJECT_NAME} src/main.cpp)
    
    target_link_libraries(${PROJECT_NAME}
  ${catkin_LIBRARIES}
      ${Boost_LIBRARIES}
    )
    
    add_dependencies(${PROJECT_NAME} ${catkin_EXPORTED_TARGETS})


---

[Originally posted](https://answers.ros.org/question/342975/catkin/cmake-include-upstream-path-before-debian-path?/) by [tyler-picknik](https://answers.ros.org/users/48265/tyler-picknik/) on ROS Answers with karma: 241 on 2020-01-30


Post score: 0
$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

In case anyone else has this problem the solution to this is the word SYSTEM in the include_directories command:

include_directories(
  include
  SYSTEM
    ${catkin_INCLUDE_DIRS}
    ${Boost_INCLUDE_DIR}
    ${EIGEN3_INCLUDE_DIRS}
)

Originally posted by tyler-picknik with karma: 241 on 2020-01-31

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.