# Why was globbing added to CMake?

**URL:** https://discourse.cmake.org/t/why-was-globbing-added-to-cmake/4579
**Category:** Development
**Created:** [December 1, 2021, 12:57pm UTC](https://discourse.cmake.org/t/why-was-globbing-added-to-cmake/4579 "2021-12-01T12:57:43Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![buildSystemPerson](https://discourse.cmake.org/user_avatar/discourse.cmake.org/buildsystemperson/32/2851_2.png) [@buildSystemPerson](https://discourse.cmake.org/u/buildSystemPerson)
#### Post date: [December 1, 2021, 12:57pm UTC](https://discourse.cmake.org/t/why-was-globbing-added-to-cmake/4579/1 "2021-12-01T12:57:43Z")

</div>

It’s [bad practice](https://discourse.cmake.org/t/is-glob-still-considered-harmful-with-configure-depends/808) to use globbing for adding source files. Even so I still decided to learn the [hard way](https://discourse.cmake.org/t/add-globbing-support-to-target-sources/3749/1).

Even other build systems seem to agree when I read [their docs](https://mesonbuild.com/FAQ.html#why-cant-i-specify-target-files-with-a-wildcard).

So why was it added?

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [December 1, 2021, 3:30pm UTC](https://discourse.cmake.org/t/why-was-globbing-added-to-cmake/4579/2 "2021-12-01T15:30:52Z")

</div>

For reference, the `file(GLOB)` option `CONFIGURE_DEPENDS` was added by [CMake MR 1767](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/1767) in CMake 3.12. See issues linked from that MR for details. The [documentation](https://cmake.org/cmake/help/v3.22/command/file.html#glob) specifically recommends against globbing for source files.

It was added by popular demand for those willing to accept the trade-offs.

---

<div class="post-metadata">

### Author: ![buildSystemPerson](https://discourse.cmake.org/user_avatar/discourse.cmake.org/buildsystemperson/32/2851_2.png) [@buildSystemPerson](https://discourse.cmake.org/u/buildSystemPerson)
#### Post date: [December 1, 2021, 11:03pm UTC](https://discourse.cmake.org/t/why-was-globbing-added-to-cmake/4579/3 "2021-12-01T23:03:33Z")

</div>

> [@brad.king](#):
>
> It was added by popular demand for those willing to accept the trade-offs.

Gotcha that makes sense 👍
