# Setting compile\_options for a AUTORCC generated file

**URL:** <https://discourse.cmake.org/t/setting-compile-options-for-a-autorcc-generated-file/5886>\
**Category:** Code\
**Tags:** os:windows\
**Created:** [June 17, 2022, 3:35pm UTC](https://discourse.cmake.org/t/setting-compile-options-for-a-autorcc-generated-file/5886 "2022-06-17T15:35:53Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhishek\_Mohata](https://discourse.cmake.org/user_avatar/discourse.cmake.org/abhishek_mohata/32/2512_2.png) [@Abhishek\_Mohata](https://discourse.cmake.org/u/Abhishek_Mohata)\
**Post date:** [June 17, 2022, 3:35pm UTC](https://discourse.cmake.org/t/setting-compile-options-for-a-autorcc-generated-file/5886/1 "2022-06-17T15:35:53Z")

</div>

My Project uses Qt and hence I have set AUTORCC as ON.

Because, AUTORCC is ON, the qrc files in the target sources would be picked and rcc executable would be invoked, resulting in the generation of qrc\_qml\_CMAKE\_.cpp file in the intermediate directory. I would like to set some compile\_options for this generated file but have not been able to do so.

What would be the right way to get the path of this generated file and then set the compile\_options for this file ?

---

<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:** [June 20, 2022, 1:41pm UTC](https://discourse.cmake.org/t/setting-compile-options-for-a-autorcc-generated-file/5886/2 "2022-06-20T13:41:58Z")

</div>

Source file properties don’t need the full path; you can just set them on the last component’s name if needed.

---

<div class="post-metadata">

**Author:** ![Abhishek\_Mohata](https://discourse.cmake.org/user_avatar/discourse.cmake.org/abhishek_mohata/32/2512_2.png) [@Abhishek\_Mohata](https://discourse.cmake.org/u/Abhishek_Mohata)\
**Post date:** [June 21, 2022, 1:23am UTC](https://discourse.cmake.org/t/setting-compile-options-for-a-autorcc-generated-file/5886/3 "2022-06-21T01:23:21Z")

</div>

Thanks Ben.

Below is what I have tried to set in cmake and I still get the warnings which I am trying to suppress using the compile\_options.

```auto
set_source_files_properties(qrc_qml.cpp PROPERTIES COMPILE_OPTIONS "-Wexit-time-destructors;-Wglobal-constructors")        
set_source_files_properties(qrc_qml_CMAKE_.cpp PROPERTIES COMPILE_OPTIONS "-Wexit-time-destructors;-Wglobal-constructors")

```

The warnings that come during compilation -

```auto
[760/762] Building CXX object CMakeFiles\TWKshetrapalQt.dir\Debug\TWKshetrapalQt_autogen\WHDP5WPTFN\qrc_qml.cpp.obj
In file included from D:\TW\Builds\TWInt\Windows-x64\TWKshetrapalQt_autogen\WHDP5WPTFN\qrc_qml.cpp:3:
D:\TW\Builds\TWInt\Windows-x64\TWKshetrapalQt_autogen\include_Debug\WHDP5WPTFN/qrc_qml_CMAKE_.cpp(133,6): warning: declaration requires an exit-time destructor [-Wexit-time-destructors]
   } dummy;
     ^
D:\TW\Builds\TWInt\Windows-x64\TWKshetrapalQt_autogen\include_Debug\WHDP5WPTFN/qrc_qml_CMAKE_.cpp(133,6): warning: declaration requires a global destructor [-Wglobal-constructors]
2 warnings generated.

```

TWInt is where all the intermediate files go like CMakeFiles, \*\_autogen directories, \*.ninja files etc.

Something incorrect in my usage ?

---

<div class="post-metadata">

**Author:** ![Abhishek\_Mohata](https://discourse.cmake.org/user_avatar/discourse.cmake.org/abhishek_mohata/32/2512_2.png) [@Abhishek\_Mohata](https://discourse.cmake.org/u/Abhishek_Mohata)\
**Post date:** [June 21, 2022, 5:28am UTC](https://discourse.cmake.org/t/setting-compile-options-for-a-autorcc-generated-file/5886/4 "2022-06-21T05:28:03Z")

</div>

Just to add to the above and to state the problem better.

the qrc\_qml.cpp and qrc\_qml\_CMAKE\_.cpp gets generated during ‘build-time’. and AUTORCC is ON for the target, these files gets generated when RCC kicks in and the generated files are compiled.

Is there a way to set the compile-options for these generated files that were not part of the target sources during cmake cache generation but came into existence later during build.

---

<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:** [June 21, 2022, 2:56pm UTC](https://discourse.cmake.org/t/setting-compile-options-for-a-autorcc-generated-file/5886/5 "2022-06-21T14:56:44Z")

</div>

> [@Abhishek\_Mohata](#):
>
> Something incorrect in my usage ?

Perhaps you want `-Wno-exit-time-destructors`?

---

<div class="post-metadata">

**Author:** ![Abhishek\_Mohata](https://discourse.cmake.org/user_avatar/discourse.cmake.org/abhishek_mohata/32/2512_2.png) [@Abhishek\_Mohata](https://discourse.cmake.org/u/Abhishek_Mohata)\
**Post date:** [June 22, 2022, 6:44am UTC](https://discourse.cmake.org/t/setting-compile-options-for-a-autorcc-generated-file/5886/6 "2022-06-22T06:44:37Z")

</div>

Yes, sorry, it should have been -Wno-exit-time-destructors.

However the problem persists.

I believe the issue is (as I mentioned in the last comment above) - The source file on which the compile-options need to be set is a generated file that gets created during build time. In such cases, how can we set the compile-options ? Is some kind of generated-expression available for such scenarios ?

---

<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:** [June 22, 2022, 10:34am UTC](https://discourse.cmake.org/t/setting-compile-options-for-a-autorcc-generated-file/5886/7 "2022-06-22T10:34:38Z")

</div>

Source file matching should work just based on the base name. Does it work of you use `SOURCE qrc_qml` (without any extension)?

---

<div class="post-metadata">

**Author:** ![Abhishek\_Mohata](https://discourse.cmake.org/user_avatar/discourse.cmake.org/abhishek_mohata/32/2512_2.png) [@Abhishek\_Mohata](https://discourse.cmake.org/u/Abhishek_Mohata)\
**Post date:** [June 23, 2022, 8:47am UTC](https://discourse.cmake.org/t/setting-compile-options-for-a-autorcc-generated-file/5886/8 "2022-06-23T08:47:04Z")

</div>

I tried the following options and still the warning comes while compilation(ideally should have got suppressed if the property worked).

```auto
#Options 1
set_source_files_properties(qrc_qml PROPERTIES COMPILE_OPTIONS "-Wno-exit-time-destructors;-Wno-global-constructors")        
set_source_files_properties(qrc_qml_CMAKE_ PROPERTIES COMPILE_OPTIONS "-Wno-exit-time-destructors;-Wno-global-constructors")  

#Option 2      
set_property(SOURCE qrc_qml PROPERTY COMPILE_OPTIONS "-Wno-exit-time-destructors;-Wno-global-constructors")
set_property(SOURCE qrc_qml_CMAKE_ PROPERTY COMPILE_OPTIONS "-Wno-exit-time-destructors;-Wno-global-constructors")

```

---

<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:** [June 23, 2022, 11:57am UTC](https://discourse.cmake.org/t/setting-compile-options-for-a-autorcc-generated-file/5886/9 "2022-06-23T11:57:35Z")

</div>

Alright, this sounds like it warrants an issue at this point. Please create a minimal test case which shows the problem.
