Using stage directory with catkin plugin

Hi, i have seen the great tutorial from @kyrofa in order to create a snap from a ROS workspace.
I am using catkin plugin like @kyrofa does in his tutorial and everything went well with all my dependencies installed in my local machine while building the snap - Perfect.
Now, i am using snapcore/snapcraft docker image and try to build my snap without any local dependencies and so, i need to install them via parts or override-build if they are not available through a package manager like apt.
I am struggling to make my Catkin plugin find aravis when it is installed via another part and staged. I thought that the build phase from reader-worskpace would use the stage directory from aravis, maybe i am wrong.

Here is my snapcraft.yml:

name: dataset-collector
version: '0.2'
summary: Dataset collector.
description: |
  This snap packages the dataset-collector to collect datas on a ship.

grade: stable                                                                                                                                                                                           
confinement: devmode                                                                                                                                                                                                 

    plugin: autotools
    source-type: tar
      - build-essential
      - intltool
      - libglib2.0-dev
      - libxml2-dev
        - ./include/*
        - ./lib/*
      ./include/*: /usr/local/include
      ./lib/*: /usr/local/lib
      - usr

    plugin: catkin
    rosdistro: kinetic
      - wget
    catkin-packages: [..., camera]
    after: [aravis]

    command: roslaunch dataset_collector main_record.launch
    plugs: [network, network-bind]
    daemon: simple

As you can see i am trying to stage aravis in usr/ in the stage directory which works great but when catkin tries to find ARAVIS it only search for it in his part and so fails to build:

CMake Error at /root/ros_workspace/parts/reader-workspace/install/usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
Could NOT find Aravis (missing: Aravis_INCLUDE_DIRS Aravis_LIBRARIES)
Call Stack (most recent call first):
/root/ros_workspace/parts/reader-workspace/install/usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
CMakeModules/FindAravis.cmake:13 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:23 (find_package)

I did succeed to make it work with override-build by installing aravis in the reader-workspace part but i feel like it will be cleaner to have a part to build aravis.

Is it possible to access the stage directory from reader-workspace when it is building so that it finds aravis ?


Hey there @aure, you’re off to a great start! Given that I don’t have any code to work with, help me to understand: FindAravis.cmake is provided in the reader-workspace somewhere, is that right? You might need to adjust it to also check in $SNAPCRAFT_STAGE (where aravis will be installed since you used after).

You can also use catkin-cmake-args to tell cmake look in the proper place for aravis (you can use $SNAPCRAFT_STAGE there as well). What that looks like kinda depends on what’s within FindAravis.cmake, but does that help?

1 Like

Hey @kyrofa,

First, thanks you for your quick answer. I did not give you that much context and you provided me with the right solution,

You are right, the issue came from my CMakeLists that needed to reference $SNAPCRAFT_STAGE.

Here is the configuration I have now in order to build with the stage directory:





It now works like a charm.
I have another issue with a gadget but will open a new topic on that after i have done more research about it.

Thanks again !

1 Like

Excellent, glad I could help!