use services defined in own package from outside catkin workplace

asked 2020-02-11 23:19:29 -0500

Harimus gravatar image

updated 2022-01-22 16:16:19 -0500

Evgeny gravatar image

Hello everyone,

I'm faced with CMake build/header include issue. I'm currently working in a code base that uses ROS, but not ROS exclusively but also other libraries and modules. The code is build using CMake, so the code structure looks like below:

project/
    catkin_ws/
        src/
            myPackage/
                src/
                    myServiceNode.cpp
                srv/
                    mysrv.srv
                package.xml
                CMakeLists.txt
        CMakeLists.txt
    src/ 
        myClientNodeOutside.cpp
    CMakeLists.txt  
    include/
    other_libraries/

What I'm trying to do is to use the srv defined inmysrv.srv in the code myClientNodeOutside.cpp outside catkin_ws. It also uses other libraries from outside the catkin workplace, and that's the reason it is outside catkin_ws.

I'm still a novice when it comes to CMake, and I've managed to make it work by using target_include_directories(myClientNodeOutside PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/catkin_ws/install/include/) after executing a catkin_make install, but I'm aware that this is just a dirty trick and not a viable (long term) solution. So I was wondering If there's a better practice, or the correct way of doing it.

Thanks in advance, and if the question need more detail I'll append it asap!

edit retag flag offensive close merge delete