Situation
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.
Problem
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.
Question
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.