GNUInstallDir differences in prefix paths and inconsistency with documentation

I was under the impression that GNUInstallDirs treated certain directories specially:


For <dir> other than the SYSCONFDIR, LOCALSTATEDIR and RUNSTATEDIR, the value of CMAKE_INSTALL_<dir> is prefixed with usr/ if it is not user-specified as an absolute path. For example, the INCLUDEDIR value include becomes usr/include. This is required by the GNU Coding Standards, which state:

When building the complete GNU system, the prefix will be empty and /usr will be a symbolic link to /.


For <dir> equal to SYSCONFDIR, LOCALSTATEDIR or RUNSTATEDIR, the CMAKE_INSTALL_FULL_<dir> is computed by prepending just / to the value of CMAKE_INSTALL_<dir> if it is not user-specified as an absolute path. For example, the SYSCONFDIR value etc becomes /etc. This is required by the GNU Coding Standards.

When trying to take advantage of this, if I use the /usr prefix, the files that are installed to CMAKE_INSTALL_SYSCONFDIR are placed in /usr/etc which I can’t imagine ever being the correct location. This appears to be a direct conflict of the documentation above.

If I use the / prefix, it appears to forget to prepend the /usr when I use cmake --install with --prefix /. It does work if I configure with -DCMAKE_INSTALL_PREFIX=/ but only sometimes. I haven’t figured out why it doesn’t always work.

Anyways, I think I’ve gotten it to work (usually) when using the / prefix but I feel like I’m missing something. I created a very basic testcase. Simply: cmake . -DCMAKE_INSTALL_PREFIX=/usr; DESTDIR=bob cmake --install . should be enough to show what I’m talking about.

Am I misusing this somehow or misunderstanding the documentation?

Seems this is even worse because I have to use the install prefix /usr in order for it to respect the triplet in /usr/lib/ for distributions like Debian. Because of this, there isn’t a way to ever just “do the right thing” for all systems currently it seems like.

On Debian, this may be lib/<multiarch-tuple> when CMAKE_INSTALL_PREFIX is /, /usr, or /usr/local.

This documentation doesn’t seem to be upheld for / or /usr/local