Why do target_... commands not work with ALIAS?

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!

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.

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 :slight_smile: