Cmake plugin and ninja backend

Hello all,

Recently I discovered some build issues in a project that I create a snap package for: when make was used as the cmake backend, there were race conditions that caused the build to fail.

Switching to the ninja backend (i.e. cmake -GNinja), as supplied by the ninja-build deb package, solved the race conditions, but required some workarounds: I had to create a custom override-build script that completely excluded the regular snapcraftctl build. The solution I came up with is here:

… but in short amounts to,

cmake ../src [OTHER_OPTIONS]
DESTDIR=../install ninja install

The reason this is necessary is because the cmake plugin hardcodes the assumption of a make backend; in fact, it explicitly derives from the make plugin:

… and invokes that plugin’s make method to actually build:

This seems worth submitting a feature request on launchpad for (the cmake plugin should probably support multiple backends, probably by using composition with a plugin for that backend rather than inheritance) but I thought I’d raise the concern here first in case anyone has any interesting/relevant comments. Alternatively it might be possible to use more generic cmake commands (cmake --build for example) which invoke the backend under the hood.

I’d also be interested in people’s thoughts on my custom solution and whether it can be improved.

Thanks & best wishes,

  -- Joe
1 Like