with disable_warnings being interface library exposing /W0 flag, but with no luck.
Is there any other approach I could take? That utilizes autogen target, which is quite handy (especially for other, non-advanced in CMake developers).
I wandered whenever generator expression could read GENERATED property of target source file, but AFAIK, generator expression would try to read it from the Library. $<$<TARGET_PROPERTY:GENERATED>:/W0> passed to target_compile_options did not work.
Yes. There’s no GENERATED property on targets. There are on source files. I suppose a $<SOURCE_FILE_PROPERTY> genex might make sense (only in certain contexts though, namely per-object cases).
Other than that, there’s no mechanism other than the tedious per-source file property setting you’ve found.
Could you please file an issue for a $<SOURCE_FILE_PROPERTY> genex? I don’t know how feasible such a genex is. We might also want to consider something like a AUTOGEN_OPTIONS property on targets to add compile options to AUTOMOC-generated sources (though I think adding a property like AUTOMOC 1 to its files for filtering by the new genex would be suitable).
Also, I find this genex as much cleaner API than adding several new properties on targets. What if someone wanted to modify not compile options, but include paths/features/defines? Should we add AUTOGEN_OPTIONS, AUTOGEN_INCLUDES, AUTOGEN_COMPILE_FEATURES etc.?
Maaaaaybe, some day, someone would want to distinguish how the file was generated (MOC / RRC / UI / another tool), but in this case I’d rather add AUTOGEN_LABEL property, which appends its value into source file LABELS property.
We already have $<TARGET_PROPERTY:AUTOMOC>, so which targets have various autogen bits enabled is already there. The issue is adding bits to the source files. Something like this:
In that header file, you can use #pragma statements to disable all warnings (or just the ones you want). That way, you don’t need to change any compiler flag.