Why \$<LINK_ONLY...> genex is escaped?

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 \$<.

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

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.

Yes. Is there a problem with it being escaped?

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. :upside_down_face:

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.

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).

1 Like

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.