# Support for generator expressions in call to set\_source\_properties() ?

**URL:** <https://discourse.cmake.org/t/support-for-generator-expressions-in-call-to-set-source-properties/13115>\
**Category:** Code\
**Created:** [December 3, 2024, 8:35pm UTC](https://discourse.cmake.org/t/support-for-generator-expressions-in-call-to-set-source-properties/13115 "2024-12-03T20:35:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Timothy\_Madden](https://discourse.cmake.org/user_avatar/discourse.cmake.org/timothy_madden/32/4211_2.png) [@Timothy\_Madden](https://discourse.cmake.org/u/Timothy_Madden)\
**Post date:** [December 3, 2024, 8:35pm UTC](https://discourse.cmake.org/t/support-for-generator-expressions-in-call-to-set-source-properties/13115/1 "2024-12-03T20:35:17Z")

</div>

Hello

When using [file(GENERATE](https://cmake.org/cmake/help/latest/command/file.html#generate)), I normally need to use [$\<CONFIG\>](https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html#id24) as part of the target file name (or path name), because `file(GENERATE)` will generate a file for each configuration.

But when I set source properties on the same generated file, generator expressions like $lt;CONFIG\> are not supported in the file name.

So I wrote a function like [VersionInfo\_Generate(TARGET tgt …)](https://github.com/terminatorul/perl-ODBC/blob/8a539aa2d115be9c85a4b30886fbbaa08786f919/cmake/VersionInfo.cmake#L500), to generate a [VERSIONINFO](https://learn.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource) resource file, lets say a file named "MyParser\_VersionInfo-$\<CONFIG\>.rc ". This is used by the resource compiler on Windows (hence the .rc extension) to embed product name and version strings into a .dll or an .exe file, and they become publicly visible in the Windows explorer Properties dialog for the binary.

Then I also added an [ICON](https://learn.microsoft.com/en-us/windows/win32/menurc/icon-resource) resource to the same resource file. An ICON resource simply names another .ico file from my project (by path) as the icon file for my executable.

So the icon file should now be included in the [OBJECT\_DEPENDS](https://cmake.org/cmake/help/latest/prop_sf/OBJECT_DEPENDS.html) source property for the VersionInfo-\*.rc source file.This allows the resource compiler to be invoked again when there are changes to the icon file.

Now I need to use

```cmake
set_property(SOURCE "MyParser_VersionInfo_$<CONFIG>.rc" 
      APPEND PROPERTY OBJECT_DEPENDS "${MyParser_SOURCE_DIR}/my_exe_icon.ico")

```

But now the source file name includes the generator expression $\<CONFIG\>, and so the call to `set_property(SOURCE)` will not work.

I do not see any way around this problem, is just a limitation in CMake ?

Can anyone help me with this ? Is it possible for CMake to add support for generator expressions in this case ?

---

<div class="post-metadata">

**Author:** ![Masoudahg1](https://discourse.cmake.org/user_avatar/discourse.cmake.org/masoudahg1/32/4980_2.png) [@Masoudahg1](https://discourse.cmake.org/u/Masoudahg1)\
**Post date:** [December 5, 2024, 9:28pm UTC](https://discourse.cmake.org/t/support-for-generator-expressions-in-call-to-set-source-properties/13115/2 "2024-12-05T21:28:27Z")

</div>

Like very good
