<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=http://email.email.llvm.org/c/eJylWF1z2zYQ_DXyC0YahZQs6UEPtmxPNVXSTuK0jxqQBEXUIKECpBT9--4dQH2kbjttZ-xIJonDYfd275jMFqflD8oYO0hWYj1IZgclGtvqXBWirWSLf5QYTB8L7VTeatt4MUjmdF3XSthSHJ1udbOj5YNkMZg-4XbVtns_SB8GyQt-jDnUI-vwyEthc4-P1Uf5pkZVW5tBkqo6U0WBEEN6cKib4cl2brh39jfsiJjCNqLzeEBsNr98FEZnTjqtvNCNkMi1Uk7Ep4VTv3fIlLPuvNxRioPx02D8EP-9H4efvEYK4ZpuctMVahuOaCk0zjBIJoPZI-24XX9abb4-PW-f1p-_DGZPdMzbYNc7_FppQ_trL7aFVX4rjta9ETx8zVe2M0UDoFuRAWqVK--lOw2HQ8rZ6OYNyF8d9CRa6Xaq7ZeKSh5ifN2U1tWSWMFy2RBjyinE9gBGaO87JY66rUShfet01tGjRBpt1UOmS6HbsOayJTGPHWolG1BtKdXOI7HsJG4A97iTS9zikI361p7j4gL4Md7isio8RZFFLCocUxEk6oBnNOdzEoUNsPSYaINraq9wLmRNkIzEDZfTRy4kAQbe4xC8vFONTHwsx1AEyUulzB4fh3T0IaXLtq6BJr69EzaW7YLgkaK2hS418AAT4rfOB73knXOquUDRLz8JIomqgjQm5H6PIwIXWtOznDsl24D0FUsE1rHSecWUeLoFzKVjsdJDe7njZTGabnwrjeHa4NvKtSQZ_BU3Gok1nlGyoNC9VAjKcH_7PqJcFBbbIndEdRqb8qHOhcxI5NbRqnNil7Lz6jqd21VZpw0ZAQfklEbiB3tEkThKEnKHMVwjgso5KuApvK0VJIGlRvey_mvB_80Jk3l9euXb4uevj5s1mdp_84FXUuiZGGZMbGXmrekA2V621bYni9Ve2g6n3hado2MwFNvvWT-SpLBPn2Mk5KzuwH8QaC1zAEJHWvEmlXTFMLcFnqHNb_aOSIgrJEStd1UbytQc5YmEjuOA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ThH6Y9HtyPVsQKe1VtQdSaUiYY_ECgPEpYKdKhEadg4li1tJ71ByXTZCbcU3wPhxea97yYzN8DEfJ7nK5ukklcl9mU5mSZHPFum8wJf5fZonaV4m8kNyidNbBIbvzhCGL0CD3w_inXQzTxfDzXyS3ggJk4YGsB6Y5lVfw9z-PdO1r2TmYAItubtsc0yrTD4AZCIZkkpSo8EclrHXtdR5MRcdtO188HTic42qPL_nObb70HDRQ3lQBeo-UodLApHJuCFBetr3c9L6_FL01qCygvVTSkRisP0bn_oHWz8Xu21uO0_vkekLnF5CG3gFH90Vy7RYpAt5Jzvw75bqTZtaubvOmeW_ZjvgjC_TdHo_v6uWqhwvZpNyMUmn6UTdl3k-y8fjGZheqHv83hmZKeOX1EimT3f_f0u9TMYJfsbph2kyS8ajMpsvFuPFopAf8ul4IgeTscKMYkb9_1jcuSWHzLqdx00DkvzlpsSMtoNU-wxb3Rq1_Ihdz8Oq-FtKbvj4nos7zn7Jqf8BT3kEmw>53568</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Missing CMake INTERFACE_INCLUDE_DIRECTORIES property on exported targets
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ekilmer
      </td>
    </tr>
</table>

<pre>
    Hello, I've noticed that the [directions (at time of writing, )](https://llvm.org/docs/CMake.html#embedding-llvm-in-your-project) on using LLVM libraries in another project require the usage of

```cmake
include_directories(${LLVM_INCLUDE_DIRS})
```

While this _does_ work, this shouldn't be necessary---the linked LLVM library targets should have this information---and there's an issue with distribution of the project if it's a library that is meant to be used by other projects because the next project then also needs to add that line, even if they don't necessarily depend on LLVM. 

[CMake `include_directories`](https://cmake.org/cmake/help/v3.13/command/include_directories.html) is a modifier for just the current project directory and does not apply to the targets created by the project, which means these are not propagated to the installation properties on targets. Instead, usage of `target_include_directories` is more appropriate and necessary for correct propagation of these properties necessary for building and usage. However, in our project, if we do something like

```cmake
target_include_directories(myTarget PUBLIC ${LLVM_INCLUDE_DIRS})
```

This propagates the _absolute path_ to the LLVM found _during build_, which means when `myTarget` is distributed to other machines, the hard-coded path to the LLVM include directories might not always be present, especially if someone built against an LLVM installation that isn't in a traditional installation location. Using CMake's `$<BUILD_INTERFACE:...>` genex also doesn't totally solve the issue if we need `PUBLIC` visibility, which is required if our public headers `#include <llvm/...>`.

I'm sure it's possible for projects to write more CMake and fix up `myTarget` to provide a relocatable way to find the LLVM include directory as it appears on _any_ user's machine, but this is not great for usability or maintenance. This fix would likely appear in the project's CMake configuration file and would be unique to _every_ project that wants to correctly depend on LLVM with a public interface, which is error prone and likely incompatible across projects.

Ideally, the exported LLVM targets themselves would tell us about where their include directories are located via the CMake `INTERFACE_INCLUDE_DIRECTORIES` target property. This can be generated by CMake for us through the [`install` command](https://cmake.org/cmake/help/v3.13/command/install.html?highlight=install#installing-targets) used with each target, specifically by adding the `INCLUDES DESTINATION <location>` option (see documentation on how the location string should look like).

I've only done some light testing, and I'm not very familiar with all of the `install` command calls in LLVM's CMake project, but adding the aforementioned `INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"` option to the `add_llvm_library` macro _should_ cover most, if not all, of the places where I think this property should appear, at least for the `llvm` project---I'm not sure how clang and other projects add their libraries, but it would also need to appear in a similar place. Adding it there may also add it to targets where it might not make sense... I haven't dug into this too much though. Code location reference: https://github.com/llvm/llvm-project/blob/802ceb8343a26f3472dc7938d72d863c23cf2a12/llvm/cmake/modules/AddLLVM.cmake#L839-L843

I tried searching the issues and phabricator patches for whether this had been brought up previously, but I couldn't really find anything. Is there any historical reason that I don't know about for not including the `INTERFACE_INCLUDE_DIRECTORIES` property on the exported targets? Thank you.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJylWF1z2zYQ_DXyC0YambRi6UEPtmxPNVXSTuK0jxyQBEXUIKECpBT9--4dQH2kbjttZxxLJgncYfd275jcls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