# Is it possible to iterate over generated files in the build output directory?

**URL:** https://discourse.cmake.org/t/is-it-possible-to-iterate-over-generated-files-in-the-build-output-directory/9303
**Category:** Usage
**Created:** [October 30, 2023, 6:22am UTC](https://discourse.cmake.org/t/is-it-possible-to-iterate-over-generated-files-in-the-build-output-directory/9303 "2023-10-30T06:22:48Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![andi\_schacherbauer](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/b5e925/32.png) [@andi\_schacherbauer](https://discourse.cmake.org/u/andi_schacherbauer)
#### Post date: [October 30, 2023, 6:22am UTC](https://discourse.cmake.org/t/is-it-possible-to-iterate-over-generated-files-in-the-build-output-directory/9303/1 "2023-10-30T06:22:48Z")

</div>

Hi, we have a Qt project and the Qt tool ‘rcc’ is generating .cpp files during the build step. We need to specify additional compile flags (change symbol visibility) and I was wondering if we can somehow iterate over those generated files to make these adjustments before the compiler is running.

Thx,  
Andi

---

<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 30, 2023, 12:53pm UTC](https://discourse.cmake.org/t/is-it-possible-to-iterate-over-generated-files-in-the-build-output-directory/9303/2 "2023-10-30T12:53:14Z")

</div>

Certainly not at build time. But if the list of files is known at compile time (as they would certainly with the older `qt5_wrap_rcc` API), you could chain them into other sources with the required processing and add those to the library.

Another possible solution is to use the [`<LANG>_COMPILER_LAUNCHER`](https://cmake.org/cmake/help/latest/prop_tgt/LANG_COMPILER_LAUNCHER.html) property to detect, edit the files into a new path, and then use the new path when launching the actual compiler for the relevant files.

However, it sounds like getting `rcc` to know how to make the files directly would be best. If you just want to expose the symbols, would making a new file that exports its symbols and chains to the “hidden” symbols be sufficient?

---

<div class="post-metadata">

### Author: ![andi\_schacherbauer](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/b5e925/32.png) [@andi\_schacherbauer](https://discourse.cmake.org/u/andi_schacherbauer)
#### Post date: [October 30, 2023, 1:59pm UTC](https://discourse.cmake.org/t/is-it-possible-to-iterate-over-generated-files-in-the-build-output-directory/9303/3 "2023-10-30T13:59:40Z")

</div>

Hi Ben,  
thx for the fast respone. I’m not sure if I understood the last suggestion correctly, could you give an example for it?

A colleague of mine just found the `CMAKE_GLOBAL_AUTORCC_TARGET` variable but unfortunately we can’t use the target to add compile options because CMake complains that the target `autorcc` is not build by this project. What is the purpose of this variable?

---

<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 30, 2023, 2:12pm UTC](https://discourse.cmake.org/t/is-it-possible-to-iterate-over-generated-files-in-the-build-output-directory/9303/4 "2023-10-30T14:12:09Z")

</div>

If you write a shell script that inspects the command line, detects an rcc source and then does the patching and command line rewriting to the patched file, you can use that shell script as a “compiler launcher”. It’s been discussed as a solution for a number of things on Discourse; searching should be able to find them.

```sh
#!/bin/sh

# inspect "$@"
# detect `rcc` sources
# if rcc-compiled
# edit file
# edit args
# endif
# exec compiler and args

```

I’m not familiar with the internals of Autogen, sorry.
