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

**URL:** <https://discourse.cmake.org/t/how-to-set-system-property-to-included-directories-coming-from-automoc/14922>\
**Category:** Code\
**Created:** [August 6, 2025, 1:40pm UTC](https://discourse.cmake.org/t/how-to-set-system-property-to-included-directories-coming-from-automoc/14922 "2025-08-06T13:40:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oodini](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/o/db5fbb/32.png) [@Oodini](https://discourse.cmake.org/u/Oodini)\
**Post date:** [August 6, 2025, 1:40pm UTC](https://discourse.cmake.org/t/how-to-set-system-property-to-included-directories-coming-from-automoc/14922/1 "2025-08-06T13:40:54Z")

</div>

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()` ?

---

<div class="post-metadata">

**Author:** ![Oodini](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/o/db5fbb/32.png) [@Oodini](https://discourse.cmake.org/u/Oodini)\
**Post date:** [August 6, 2025, 3:20pm UTC](https://discourse.cmake.org/t/how-to-set-system-property-to-included-directories-coming-from-automoc/14922/2 "2025-08-06T15:20:03Z")

</div>

Actually, I found the answer not in the CMake documentation about AutoMOC, but in the documentation about the policy [CMP0151](https://cmake.org/cmake/help/latest/policy/CMP0151.html): in my project, I had to update the required minimal version to 3.27.

---

<div class="post-metadata">

**Author:** ![Oodini](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/o/db5fbb/32.png) [@Oodini](https://discourse.cmake.org/u/Oodini)\
**Post date:** [September 25, 2025, 3:39pm UTC](https://discourse.cmake.org/t/how-to-set-system-property-to-included-directories-coming-from-automoc/14922/3 "2025-09-25T15:39:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Oodini](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/o/db5fbb/32.png) [@Oodini](https://discourse.cmake.org/u/Oodini)\
**Post date:** [September 26, 2025, 8:23am UTC](https://discourse.cmake.org/t/how-to-set-system-property-to-included-directories-coming-from-automoc/14922/4 "2025-09-26T08:23:15Z")

</div>

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…
