# How to handle multiarch headers?

**URL:** <https://discourse.cmake.org/t/how-to-handle-multiarch-headers/8529>\
**Category:** Code\
**Tags:** os:linux\
**Created:** [July 16, 2023, 6:09pm UTC](https://discourse.cmake.org/t/how-to-handle-multiarch-headers/8529 "2023-07-16T18:09:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![szhorvat](https://discourse.cmake.org/user_avatar/discourse.cmake.org/szhorvat/32/1906_2.png) [@szhorvat](https://discourse.cmake.org/u/szhorvat)\
**Post date:** [July 16, 2023, 6:09pm UTC](https://discourse.cmake.org/t/how-to-handle-multiarch-headers/8529/1 "2023-07-16T18:09:53Z")

</div>

`GNUInstallDirs` can automatically set up `CMAKE_INSTALL_LIBDIR` to point to an architecture-specific directory, e.g. `/usr/lib/x86_64-linux-gnu`. It does this based on `CMAKE_LIBRARY_ARCHITECTURE` as well as other factors.

**In some cases, not only libraries, but headers are architecture-specific as well. What is the recommended way to handle this case?**

See [multiarch support: config headers in a per-architecture location by jgmbenoit · Pull Request #2372 · igraph/igraph · GitHub](https://github.com/igraph/igraph/pull/2372) for the motivation.

While we can adjust the value of `CMAKE_INSTALL_INCLUDEDIR` ourselves, this would need to be done in a way that mirrors `GNUInstallDirs`’s behaviour with `CMAKE_INSTALL_LIBDIR`, and that behaviour is complex and not well documented. See [https://gitlab.kitware.com/cmake/cmake/-/issues/20565](https://gitlab.kitware.com/cmake/cmake/-/issues/20565) It is also unclear to me whether there are differences between Linux distros in where they install arch-specific headers. Therefore I was hoping that `GNUInstallDirs` already has features that can help us here.

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [July 18, 2023, 12:48am UTC](https://discourse.cmake.org/t/how-to-handle-multiarch-headers/8529/2 "2023-07-18T00:48:36Z")

</div>

I can see a few ways of doing this:

- install headers with archful names and include them based on the architecture.
- use `DESTINATION "${CMAKE_INSTALL_LIBDIR}/${CMAKE_PROJECT_NAME}/${CMAKE_INSTALL_INCLUDEDIR}"`

I suspect that `FILE_SET` source listings would make it easy to install the archful bits into the `LIBDIR` and the arch-independent headers into `INCLUDEDIR`. I don’t think that `GNUInstallDirs` has anything for this.
