# file(GENERATE ...) and Visual Studio 16 2019 generator

**URL:** https://discourse.cmake.org/t/file-generate-and-visual-studio-16-2019-generator/7076
**Category:** Usage
**Tags:** os:windows
**Created:** [December 15, 2022, 6:47am UTC](https://discourse.cmake.org/t/file-generate-and-visual-studio-16-2019-generator/7076 "2022-12-15T06:47:09Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Mauro\_Ziliani](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mauro_ziliani/32/2018_2.png) [@Mauro\_Ziliani](https://discourse.cmake.org/u/Mauro_Ziliani)
#### Post date: [December 15, 2022, 6:47am UTC](https://discourse.cmake.org/t/file-generate-and-visual-studio-16-2019-generator/7076/1 "2022-12-15T06:47:09Z")

</div>

Goodmorning.  
I’m using file(GENERATE …) to test the espansion of generator expressions

I get a list of libraries in MyTargetLibraries with

get\_target\_property(MyTargetLibraries mytarget LINK\_LIBRARIES)

Then I loop on library list with a foreach, and the list is full as I expected.

But when I run

file(GENERATE OUTPUT C:/temp/debug\_generator.txt CONTENT MyTargetLibraries)

the file debug\_generator.txt is not created in C:/Temp

My question is: file(GENERATE …) works with Visual Studio 16 2019 generator?

Best regards,  
MZ

---

<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: [December 15, 2022, 1:05pm UTC](https://discourse.cmake.org/t/file-generate-and-visual-studio-16-2019-generator/7076/2 "2022-12-15T13:05:55Z")

</div>

It does. A lack of error is interesting as I’d expect there to be an error there as you have N configurations all writing to the same file. Of course, if they _are_ the same content, then there’s no problem (or error), but then there’d be the file. Does it start working if you add `$<CONFIG>` to the path somehow?

---

<div class="post-metadata">

### Author: ![Mauro\_Ziliani](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mauro_ziliani/32/2018_2.png) [@Mauro\_Ziliani](https://discourse.cmake.org/u/Mauro_Ziliani)
#### Post date: [December 15, 2022, 2:23pm UTC](https://discourse.cmake.org/t/file-generate-and-visual-studio-16-2019-generator/7076/3 "2022-12-15T14:23:48Z")

</div>

Oh well. I misunderstood the use of the function.  
All works. Thanks
