# GNUInstallDir differences in prefix paths and inconsistency with documentation

**URL:** https://discourse.cmake.org/t/gnuinstalldir-differences-in-prefix-paths-and-inconsistency-with-documentation/5102
**Category:** Usage
**Tags:** os:linux
**Created:** [February 23, 2022, 5:27pm UTC](https://discourse.cmake.org/t/gnuinstalldir-differences-in-prefix-paths-and-inconsistency-with-documentation/5102 "2022-02-23T17:27:07Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![computerquip-work](https://discourse.cmake.org/user_avatar/discourse.cmake.org/computerquip-work/32/2223_2.png) [@computerquip-work](https://discourse.cmake.org/u/computerquip-work)
#### Post date: [February 23, 2022, 5:27pm UTC](https://discourse.cmake.org/t/gnuinstalldir-differences-in-prefix-paths-and-inconsistency-with-documentation/5102/1 "2022-02-23T17:27:07Z")

</div>

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](https://www.gnu.org/prep/standards/html_node/Directory-Variables.html), which state:
> > 
> > > When building the complete GNU system, the prefix will be empty and `/usr` will be a symbolic link to `/`.
> 
> `/usr`
> 
> > 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](https://github.com/computerquip-work/scaling-octo-journey). 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?

---

<div class="post-metadata">

### Author: ![computerquip-work](https://discourse.cmake.org/user_avatar/discourse.cmake.org/computerquip-work/32/2223_2.png) [@computerquip-work](https://discourse.cmake.org/u/computerquip-work)
#### Post date: [February 23, 2022, 8:44pm UTC](https://discourse.cmake.org/t/gnuinstalldir-differences-in-prefix-paths-and-inconsistency-with-documentation/5102/2 "2022-02-23T20:44:06Z")

</div>

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`](https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX.html#variable:CMAKE_INSTALL_PREFIX) is `/`, `/usr`, or `/usr/local`.

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

---

<div class="post-metadata">

### Author: ![anik01ic](https://discourse.cmake.org/user_avatar/discourse.cmake.org/anik01ic/32/5018_2.png) [@anik01ic](https://discourse.cmake.org/u/anik01ic)
#### Post date: [January 30, 2025, 10:26am UTC](https://discourse.cmake.org/t/gnuinstalldir-differences-in-prefix-paths-and-inconsistency-with-documentation/5102/3 "2025-01-30T10:26:52Z")

</div>

Any update regarding the issue described above? I’m also facing it (cmake version 3.22.11, Ubuntu 22.04.5 LTS). If I am using `--prefix /usr`, then files get installed in `/usr/etc` instead of `/etc`. If I am using `--prefix /`, then none of the directories get prepended with `usr` e.g., libraries get installed in `/lib` instead of `/usr/lib`. If I am not wrong, both special cases are not upheld (not sure about the third one, haven’t checked it). Also, I am not facing this issue in Yocto, but rather only on Ubuntu.

---

<div class="post-metadata">

### Author: ![petk](https://discourse.cmake.org/user_avatar/discourse.cmake.org/petk/32/4555_2.png) [@petk](https://discourse.cmake.org/u/petk)
#### Post date: [October 29, 2025, 12:06am UTC](https://discourse.cmake.org/t/gnuinstalldir-differences-in-prefix-paths-and-inconsistency-with-documentation/5102/4 "2025-10-29T00:06:52Z")

</div>

I’ve opened a merge request regarding the `--prefix` option:  
[https://gitlab.kitware.com/cmake/cmake/-/merge\_requests/11369](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/11369) to clarify a bit further when this option is intended to be used. The special GNU cases aren’t applied at the install phase when `CMAKE_INSTALL_PREFIX` is overridden via `--prefix`.

I was also stuck with understanding this issue and to properly fix it in CMake, it is simply too difficult. Installation prefix in CMake on such distributions where something needs to be installed to `/usr` prefix, should never be set via `--prefix` option. Only at the configuration time either by setting the CMAKE\_INSTALL\_PREFIX variable or by using the `--install-prefix` option. Yes, annoying, but there is no other way here.
