Snapcraft parts dependencies (cmake, catkin)

Hi all,

I am new to snapcraft but I really like the idea and simple configuration method.

I am trying to build a snap for my application but I can’t fix an apparently simple problem.
I checked similar topics but couldn’t figure out a working solution in my case.

Situation is this:

package A and package B.
A is built with cmake (an external library), B with catkin (application).

I can build correctly package A, but package B (which depends on A) doesn’t see package A correctly installed within the snap space (I imagine). I get errors at compile time for wrong or missing A library.
I tried to use the after: [A] and messing around with A installation path, but still can’t figure out a working configuration.

What am I missing? Is there a way to tell package B where to look for A?
I am telling A to install in -DCMAKE_INSTALL_PREFIX=$SNAPCRAFT_PART_INSTALL/ and related subdirectories.
Usually on my pc I install A in /usr/local.

Any idea or suggestion on this?
Any help is greatly appreciated.

Thanks,

Dan

I believe this is your issue. When snapcraft runs the make install step it will pass DESTDIR=$SNAPCRAFT_PART_INSTALL as a setting which will cause your files to be staged into $SNAPCRAFT_PART_INSTALL/$SNAPCRAFT_PART_INSTALL. You probably want to specify -DCMAKE_INSTALL_PREFIX=/usr and let the magic happen under the hood.

Thanks for the help. I tried and it still doesn’t work, unfortunately.

My snap yaml cointains the following:

protobuf:
    plugin: cmake
    source: "https://github.com/google/protobuf.git"
    source-tag: "v3.4.1"
    build: |
        cmake -G Ninja -DCMAKE_INSTALL_PREFIX=$SNAPCRAFT_STAGE/ -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_BUILD_TYPE=Release -Dprotobuf_BUILD_TESTS=OFF ../src/cmake
        ninja
    install: |
        ninja install
    
workspace:
    plugin: catkin
    rosdistro: kinetic
    catkin-packages: [ceres-solver, cartographer_ros_msgs, cartographer_ros, cartographer]
    after: [protobuf]
    build: |
        rosdep update
        rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y
        catkin_make_isolated --install --use-ninja

I took these instructions from cartographer build instructions.
With the instructions typed in manually I can compile the package. But when doing snapcraft I always get stuck when building the last package (cartographer), with errors on protobuf versions.

If I specify -DCMAKE_INSTALL_PREFIX=/ the libs get installed in host computer / folder (sudoing, error otherwise), not in the snap space.

Hello, may I ask if you have solved this problem? I have the same problem as you. Can you help me? Thank you very much.

Hello, may I ask if you have solved this problem? I have the same problem as you. Can you help me? Thank you very much.