# Why do target\_... commands not work with ALIAS?

**URL:** https://discourse.cmake.org/t/why-do-target-commands-not-work-with-alias/8640
**Category:** Usage
**Created:** [July 29, 2023, 11:24pm UTC](https://discourse.cmake.org/t/why-do-target-commands-not-work-with-alias/8640 "2023-07-29T23:24:25Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![nylnx](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/n/e9bcb4/32.png) [@nylnx](https://discourse.cmake.org/u/nylnx)
#### Post date: [July 29, 2023, 11:24pm UTC](https://discourse.cmake.org/t/why-do-target-commands-not-work-with-alias/8640/1 "2023-07-29T23:24:25Z")

</div>

Hello,  
I have the following situation: I build a third-party library as source and it expects to be configured with a header configuration file. To correctly compile, the library needs to find the header and therefore the folder of this header file needs to be in the include directories. Now the library does the correct thing and abstracts away the internal targets with known good namespaced ones with an `ALIAS`. In my opinion, the correct way to make the header file available to the library would be to `target_link_libraries()` an `INTERFACE` library with the header to the third-party library. Or maybe, use `target_include_directories()` with the `ALIAS` of the third-party library.

Obviously this does not work, because CMake disallows using an `ALIAS` with the target commands. But what is the reasoning behind this and what would be the correct way to handle this situation?

Thanks for your help!

---

<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 30, 2023, 3:39am UTC](https://discourse.cmake.org/t/why-do-target-commands-not-work-with-alias/8640/2 "2023-07-30T03:39:11Z")

</div>

> [@nylnx](#):
>
> Obviously this does not work, because CMake disallows using an `ALIAS` with the target commands. But what is the reasoning behind this and what would be the correct way to handle this situation?

It’s disallowed because disallowing things is a better default for things we don’t support rather than accepting it without fully considering the use case. That said, I do wish `ALIAS` targets were more transparent.

You want to follow [this issue](https://gitlab.kitware.com/cmake/cmake/-/issues/19445).

---

<div class="post-metadata">

### Author: ![nylnx](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/n/e9bcb4/32.png) [@nylnx](https://discourse.cmake.org/u/nylnx)
#### Post date: [July 30, 2023, 11:25pm UTC](https://discourse.cmake.org/t/why-do-target-commands-not-work-with-alias/8640/3 "2023-07-30T23:25:18Z")

</div>

Thank you for the link! I made a comment with my take on the problem and will be watching this discussion and hopefully an implementation in the future 🙂
