How to set SYSTEM property to included directories coming from AUTOMOC ?

Hello,

I use for C++:

  • CMake 3.31.6
  • Qt 5.15
  • Visual Studio 2022

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.