Software author wants to add zsh completion to his project. Has written completion script, works.
Needs to figure out where under $CMAKE_INSTALL_PREFIX
to install so it gets found by default.
Testing Fedora 34 against Ubuntu 20.04, it was found that the only common member of $fpath
is /usr/local/share/zsh/site-functions; none of the /usr/share fpaths overlap. Especially, Ubuntu does not read /usr/share/zsh/site-functions.
So, I can't just install into $CMAKE_INSTALL_PREFIX/share/zsh/site-functions
, because that only works for $CMAKE_INSTALL_PREFIX==/usr/local
, but not later in packaging ($CMAKE_INSTALL_PREFIX==/usr
). I'd argue this is a Ubuntu inconsistency, but that doesn't effectively matter.
Is there a sensible way to figure out at CMake time where to put completion scripts?
Note that CMake is not usually run from zsh, so checking $fpath
is not an option.
$CMAKE_INSTALL_PREFIX/share/zsh/site-functions
is the right place.
It is the same with man pages, info pages, pkg-config path, binaries and libraries and whatever else. On a default install, man will only look in predefined places like /usr/share/man
and /usr/local/share/man
.
If someone decides to install to /opt/gnuradio
or whatever, it is then also their responsibility to ensure that they set $PATH
, $MANPATH
$INFOPATH
and whatever else accordingly. It is the same for $fpath
. The best software can do is ensure that they stick to established conventions and not to spew files elsewhere on the filesystem outside of $PREFIX
.
If Ubuntu wants to be clever and invent their own vendor-completion
directories then a consequence of that is that is that they need to patch everything they package that includes a zsh completion. That's their problem because they created the problem for themselves.