# Why \\$\<LINK\_ONLY...\> genex is escaped?

**URL:** https://discourse.cmake.org/t/why-link-only-genex-is-escaped/10674
**Category:** Code
**Created:** [April 16, 2024, 11:07am UTC](https://discourse.cmake.org/t/why-link-only-genex-is-escaped/10674 "2024-04-16T11:07:01Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![silverqx](https://discourse.cmake.org/user_avatar/discourse.cmake.org/silverqx/32/2353_2.png) [@silverqx](https://discourse.cmake.org/u/silverqx)
#### Post date: [April 16, 2024, 11:07am UTC](https://discourse.cmake.org/t/why-link-only-genex-is-escaped/10674/1 "2024-04-16T11:07:01Z")

</div>

I see in package config files that `\$<LINK_ONLY:...>` genex is escaped, why?

I’ve been using cmake ~2 years and I never escaped genex and I don’t even remember that I would read something about it. Genex docs doesn’t even contain `\$<`.

---

<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: [April 27, 2024, 3:33pm UTC](https://discourse.cmake.org/t/why-link-only-genex-is-escaped/10674/2 "2024-04-27T15:33:08Z")

</div>

It’s just an artifact of escaping any `$` at that point of the code.

---

<div class="post-metadata">

### Author: ![silverqx](https://discourse.cmake.org/user_avatar/discourse.cmake.org/silverqx/32/2353_2.png) [@silverqx](https://discourse.cmake.org/u/silverqx)
#### Post date: [April 27, 2024, 3:35pm UTC](https://discourse.cmake.org/t/why-link-only-genex-is-escaped/10674/3 "2024-04-27T15:35:55Z")

</div>

But it would work without this escape as well right? Also not only $\<LINK\_ONLY\> are escaped, all genex in package configs are escaped, to be more accurate.

---

<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: [April 27, 2024, 3:56pm UTC](https://discourse.cmake.org/t/why-link-only-genex-is-escaped/10674/4 "2024-04-27T15:56:11Z")

</div>

Yes. Is there a problem with it being escaped?

---

<div class="post-metadata">

### Author: ![silverqx](https://discourse.cmake.org/user_avatar/discourse.cmake.org/silverqx/32/2353_2.png) [@silverqx](https://discourse.cmake.org/u/silverqx)
#### Post date: [April 27, 2024, 4:08pm UTC](https://discourse.cmake.org/t/why-link-only-genex-is-escaped/10674/5 "2024-04-27T16:08:59Z")

</div>

No, but because of this, that it works with and also without it is confusing. I’m not asking because of there is some problem but I was curious why it’s so.

What means: It’s just an artifact of escaping. It means that it’s from older CMake versions like it was needed in older versions and now it works also without escaping? Or it’s just safer or better for the parser to detect these sequences.

Package config file would look much better without these escaping sequences everywhere.

I think I have to many stupid questions about this and I should shut up. 🙃

Because the question at the end of the day is, when should I also escape genex-es in my code, I explicitly searched this in docs and found nothing.

---

<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: [April 27, 2024, 9:35pm UTC](https://discourse.cmake.org/t/why-link-only-genex-is-escaped/10674/6 "2024-04-27T21:35:33Z")

</div>

I believe the escaping routines were originally for things like `$ORIGIN` or putting deferred variable expansions into the code. The fact that genexes use `$` just rode along the existing behavior and since it didn’t mess anything up was never noticed or fixed (assuming there’s actually anything to fix).

---

<div class="post-metadata">

### Author: ![silverqx](https://discourse.cmake.org/user_avatar/discourse.cmake.org/silverqx/32/2353_2.png) [@silverqx](https://discourse.cmake.org/u/silverqx)
#### Post date: [April 28, 2024, 6:39am UTC](https://discourse.cmake.org/t/why-link-only-genex-is-escaped/10674/7 "2024-04-28T06:39:03Z")

</div>

It looks like if it would be removed in the next cmake version there is high chance that all cmake code written would work normally (maybe some edge cases could occur).

Thx for explanation, I understand it better now.
