Setting compile_options for a AUTORCC generated file

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 ?

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

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.

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 -

[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 ?

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.

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

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 ?

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

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

#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")

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