avoid shadowing INCLUDE_DIRS of two versions of the same package

asked 2020-06-21 21:29:26 -0600

aveJ gravatar image

hello guys,

I have a compile issue, hope you guys can give some input

env: ubuntu 18, ROS Melodic

task: build my package which depends on octomap

problem: requires octomap version < 1.8, but the one shipped with ROS is 1.9.0

tried:

  1. find an old version(1.6.9) (branch: release/indigo/octomap) from here

  2. build from source: mkdir build; cd build; cmake ..; make

  3. in my package CMakeLists.txt, added:

find_package(octomap CONFIG REQUIRED PATHS /home/ubuntu18/pkgs/octomap-indigo NO_DEFAULT_PATH)

and

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

set(${PROJECT_NAME}_LIBRARIES
${catkin_LIBRARIES}
${OCTOMAP_LIBRARIES} )

4.got an error during compiling, complaining about a function is not defined, which is in fact defined in the old version i used, but not in the new system version.

so i figure the wrong version was used. Then i went to:

rosworkspace/build/mypackage/CMakeFiles/mypackage.dir/CXX.includecache, found out 'opt/ros/melodic/include/header.h' was used instead of the path that I downloaded and compiled from source

Then, i tried:

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

Then it compiled without issue.

So my question is: is the issue I had due to INCLUDE_DIRS shadowing? how to avoid INCLUDE_DIRS shadowing between two versions of the same package where one is installed by sudo apt-get install, and is under system directory, the other is built from source, and is under a local directory? I only figured out changing the include order. But I'm afraid there is a better/general way to solve this type of issues?

Any help will be appreciated. Thanks.

Edit: Found this question which is similar. And the octomap package is not in my ros workspace

edit retag flag offensive close merge delete