# Add hint about INTERFACE\_INCLUDE\_DIRECTORIES and $\<BUILD\_INTERFACE\>/$\<INSTALL\_INTERFACE\> generator expressions

**URL:** https://discourse.cmake.org/t/add-hint-about-interface-include-directories-and-build-interface-install-interface-generator-expressions/2739
**Category:** Development
**Created:** [February 11, 2021, 12:01pm UTC](https://discourse.cmake.org/t/add-hint-about-interface-include-directories-and-build-interface-install-interface-generator-expressions/2739 "2021-02-11T12:01:03Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![leha-bot](https://discourse.cmake.org/user_avatar/discourse.cmake.org/leha-bot/32/921_2.png) [@leha-bot](https://discourse.cmake.org/u/leha-bot)
#### Post date: [February 11, 2021, 12:01pm UTC](https://discourse.cmake.org/t/add-hint-about-interface-include-directories-and-build-interface-install-interface-generator-expressions/2739/1 "2021-02-11T12:01:03Z")

</div>

Hello! I would like to propose the small UX addition about CMake hints then the user has an error like this:

```auto
CMake Error in src/library/utils/CMakeLists.txt:
  Target "lib_utils" INTERFACE_INCLUDE_DIRECTORIES property contains
  path:

    "/home/user/proj/library/src/utils/include"

  which is prefixed in the source directory.

```

This error means that user exports that target and forget to add the $\<INSTALL\_INTERFACE\> generator expression to the target\_include\_directories(). We could add a hint how to fix this error, and it could helps users to fix this error:

```auto
CMake Error in src/library/utils/CMakeLists.txt:
  Target "lib_utils" INTERFACE_INCLUDE_DIRECTORIES property contains
  path:

    "/home/user/proj/library/src/utils/include"

  which is prefixed in the source directory.

Hint: Replace the relative path "include" to $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
Hint: Add the $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDE_DIR}> generator expression to adjust the includes path on install stage.

```

I also think that hint could accurately trim off the similar parts of include dirs (e.g. include/libname should be replaced by ${CMAKE\_INSTALL\_INCLUDE\_DIR}/libname), and this hint could mention the GNUInstallDirs CMake module.

Thanks for your attention!

---

<div class="post-metadata">

### Author: ![leha-bot](https://discourse.cmake.org/user_avatar/discourse.cmake.org/leha-bot/32/921_2.png) [@leha-bot](https://discourse.cmake.org/u/leha-bot)
#### Post date: [February 11, 2021, 12:05pm UTC](https://discourse.cmake.org/t/add-hint-about-interface-include-directories-and-build-interface-install-interface-generator-expressions/2739/2 "2021-02-11T12:05:23Z")

</div>

I could also make a PoC patch to CMake upstream, if you like this idea 😊

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [February 11, 2021, 12:40pm UTC](https://discourse.cmake.org/t/add-hint-about-interface-include-directories-and-build-interface-install-interface-generator-expressions/2739/3 "2021-02-11T12:40:34Z")

</div>

The proposed error message LGTM, though the hints should still be indented and wrapped like the rest of the message. Please see [CONTRIBUTING.rst](https://gitlab.kitware.com/cmake/cmake/-/blob/master/CONTRIBUTING.rst) for instructions to propose a change in a merge request.
