Dealing with inter-part dependencies?

I’m trying to build a snap on core22 that consists of an application and a plugin module (shared library) for that application. The plugin needs, besides Ubuntu standard libraries, three libraries that we need to build ourselves. Building the application works fine.

Now I added parts for the libraries. Below is one of them. This works just fine, but so far no part depended on another.

  magic_enum:
    source: https://github.com/Neargye/magic_enum
    source-type: git
    source-commit: 43a9272f450fd07e85868ed277ebd793e40806df
    plugin: cmake

Next step, I need to build the plugin. I was hoping I could do that using after, as in

  reasoning:
    after:
      - swipl
      - magic_enum
      - catch2
      - spdlog
   ...

But, it cannot find these dependencies :frowning: Running snapcraft --debug, the dependencies appear in /root/stage where CMake doesn’t find them. We could use -DCMAKE_PREFIX_PATH=/root/stage/usr, but then trying to run the staged binary (/root/stage/usr/bin/swipl) says it cannot find its shared library dependency. I can hack around that by setting LD_LIBRARY_PATH.

While eventually this may work, I’d assume there must be a simpler way, no?