# How does cmake configure Header Files folder to configure subfolder Item?

**URL:** <https://discourse.cmake.org/t/how-does-cmake-configure-header-files-folder-to-configure-subfolder-item/1728>\
**Category:** Code\
**Created:** [August 20, 2020, 1:47am UTC](https://discourse.cmake.org/t/how-does-cmake-configure-header-files-folder-to-configure-subfolder-item/1728 "2020-08-20T01:47:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mirro187](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ad7895/32.png) [@mirro187](https://discourse.cmake.org/u/mirro187)\
**Post date:** [August 20, 2020, 1:47am UTC](https://discourse.cmake.org/t/how-does-cmake-configure-header-files-folder-to-configure-subfolder-item/1728/1 "2020-08-20T01:47:13Z")

</div>

The red line has been identified in the screenshot below

 ![QQ图片20200820094240](https://discourse.cmake.org/uploads/default/original/1X/d80797836f46895a0dae6a8818177457547fd752.jpeg)

---

<div class="post-metadata">

**Author:** ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)\
**Post date:** [August 20, 2020, 10:20pm UTC](https://discourse.cmake.org/t/how-does-cmake-configure-header-files-folder-to-configure-subfolder-item/1728/2 "2020-08-20T22:20:18Z")

</div>

You can achieve results like that using the [`source_group()`](https://cmake.org/cmake/help/latest/command/source_group.html) command. Note that for headers, you will likely need to use the `FILES` option to that command, not `REGULAR_EXPRESSION` (see [this issue](https://gitlab.kitware.com/cmake/cmake/-/issues/13598#note_814001) for background)

---

<div class="post-metadata">

**Author:** ![mirro187](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ad7895/32.png) [@mirro187](https://discourse.cmake.org/u/mirro187)\
**Post date:** [August 21, 2020, 7:37am UTC](https://discourse.cmake.org/t/how-does-cmake-configure-header-files-folder-to-configure-subfolder-item/1728/4 "2020-08-21T07:37:16Z")

</div>

Thank you for your q&A, I’m a green hand.Can you provide a sample code?

---

<div class="post-metadata">

**Author:** ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)\
**Post date:** [August 21, 2020, 8:10am UTC](https://discourse.cmake.org/t/how-does-cmake-configure-header-files-folder-to-configure-subfolder-item/1728/5 "2020-08-21T08:10:37Z")

</div>

Something like the following:

```cmake
source_group("Header Files\\Item" FILES ...)

```

where `...` is where you should list the files you want to appear in that folder. Experiment with it a bit and see the effect so you get what you want. Note the double back-slashes to get the right path separator. There are other ways to specify separators depending on CMake version, but the above will always work.

---

<div class="post-metadata">

**Author:** ![mirro187](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ad7895/32.png) [@mirro187](https://discourse.cmake.org/u/mirro187)\
**Post date:** [August 23, 2020, 1:06am UTC](https://discourse.cmake.org/t/how-does-cmake-configure-header-files-folder-to-configure-subfolder-item/1728/6 "2020-08-23T01:06:04Z")

</div>

thank you.
