I am trying to snap an application that is built using cmake.
Unfortunately, building it using the default behaviour of the cmake plugin would not work. So, I have to use the override-build functionality for the build step.
But I was not able to find the best way to imitate the default behaviour. I let the pulled files at the location they were automatically pulled to by the default behaviour of the pull step and passed this path to the cmake command using the environment variables. Is this the recommended way, or should I copy the pulled repository to the install directory?
My next issue is that I do not know where I am supposed to put the compiled binary from the build step. Should I manually copy it to the CRAFT_PART_INSTALL directory? Or is it automatically put there?
Should I manually copy it to the CRAFT_PART_INSTALL directory?
Yes, this is probably the best path forward. Something cp <artifact> $CRAFT_PART_INSTALL/ will get the artifact in the part’s install directory, which will then get staged and primed.
If you share your snapcraft.yaml, we may be able to provide an alternative solution. For example, if you’re using override-build and not calling craftctl default, then you may be better off just using the nil plugin.
Building actually does not fail and using the --shell-after flag I could actually see that the built binary is in /parts/my-part/build/bin, and it is at least able to print its version.
But I am unsure how to proceed from here. I know I have to expose this binary eventually, but I guess I am not there yet. I still need to get my artifact through the stage and the prime phase, right?
You still may be able to use the cmake plugin. The --target clangd part is the a problem. That wouldn’t work since craft-parts hardcodes the target to install. If --target install works, then you could experiment with something like: