how to remove substring/suffix using generator expressions

Assume that I have the expression “/home/user/” as the result of a generator-expression and I would like to remove the suffix “.bar”. In practice, the first expression is the full path to an object file and the second is the suffix, that I need to remove in order to obtain the expression “/home/user/foo” which I can then write to file using

file(GENERATE OUTPUT filename CONTENT “$<…>”)

Is it possible to remove substrings within generator expressions?

Many thanks in advance and kind regards,

No. You’ll have to put it in a variable and use STRING( REGEX
REPLACE …) to strip out the .bar extension.

Thanks! In my understanding, generator expressions are evaluated AFTER the CMakeLists.txt file(s) have been processed. How can I “put” the result of a generator expression into a variable that I can then further process using STRING? Thanks in advance.

You are of course correct. Disregard my suggestion. You can
probably use thegenerator expressions to do what you want.

The email discourse client swallowed these in the previous answer.

Thanks but it’s not that easy I guess. I need the base name of a particular object file of a target. It’s the attempt to solve my problem with precompiled headers described in a previous post.

I suggested other solutions over there, but I think that more path manipulation/extraction genexes are likely useful anyways. A feature request for them would be useful.