# Generator expression to evaluate strings given a certain context

**URL:** https://discourse.cmake.org/t/generator-expression-to-evaluate-strings-given-a-certain-context/6475
**Category:** Usage
**Created:** [September 13, 2022, 6:40pm UTC](https://discourse.cmake.org/t/generator-expression-to-evaluate-strings-given-a-certain-context/6475 "2022-09-13T18:40:47Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![decimad](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/ed655f/32.png) [@decimad](https://discourse.cmake.org/u/decimad)
#### Post date: [September 13, 2022, 6:40pm UTC](https://discourse.cmake.org/t/generator-expression-to-evaluate-strings-given-a-certain-context/6475/1 "2022-09-13T18:40:47Z")

</div>

Hello,

I’ve been working on a C project that learns to also use C++ recently. I’ve up to now generated (as in file(GENERATE) a summary file with compilation options of certain targets, which used $\<TARGET\_PROPERTY:xyz,COMPILE\_OPTIONS\> generator expressions. This fails, once I use $\<COMPILE\_LANGUAGE:CXX\> generator expressions to specify different sets of compile options for C or C++ on the same target, because CMake obviously doesn’t know in context of which language the generator expression shall be evaluated. Unfortunately there’s also no way I’m aware of, to manually specify this context. Is there a workaround to extract the compile options/definitions etc. for a specific language?

Here’s a small pastebin summary of the problem: [https://pastebin.com/hBMUqJxv](https://pastebin.com/hBMUqJxv)

---

<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: [October 17, 2022, 8:56pm UTC](https://discourse.cmake.org/t/generator-expression-to-evaluate-strings-given-a-certain-context/6475/2 "2022-10-17T20:56:06Z")

</div>

This would require a new feature that I’m not sure about a mechanism at the moment. Please file [a request](https://gitlab.kitware.com/cmake/cmake/-/issues) to track it.
