When using Qt and AUTOMOC, the relevant directory is automatically added to the included directories, without being declared/used in the CMakeLists.txt. But some of the generated and included files can raise some warnings during compilation.
How to set the generated MOC directory as SYSTEM, as when calling add_subdirectory() ?
Actually, I found the answer not in the CMake documentation about AutoMOC, but in the documentation about the policy CMP0151: in my project, I had to update the required minimal version to 3.27.
Well, I don’t know on which of y project I resolved the problem, but on an other project, it remains even after updating the minmal version of the project to 3.31…
I logged the value of the policy CMP0151, and it is equal to NEW, but the include files for the UI generated by AUTOMOC still generate warnings.
The problem is probably due to the fact I use the VS 2017 toolset with the VS 2022 generator, and the VS option (/external) matching to the CMake SYSTEM option appears only in VS 2019 16.10…