# Add GLOBBING support to target\_sources?

**URL:** https://discourse.cmake.org/t/add-globbing-support-to-target-sources/3749
**Category:** Development
**Created:** [July 13, 2021, 10:17pm UTC](https://discourse.cmake.org/t/add-globbing-support-to-target-sources/3749 "2021-07-13T22:17:47Z")
**Posts on this page:** 1
**Showing post:** 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: [July 13, 2021, 10:17pm UTC](https://discourse.cmake.org/t/add-globbing-support-to-target-sources/3749/1 "2021-07-13T22:17:47Z")

</div>

Currently here are 2 common patterns in our CMake codebase. Since we really like the safe globbing functionality added in 3.13.

# What is already possible

```auto
# SAFE GLOBBING! :D
file(GLOB_RECURSE sources CONFIGURE_DEPENDS *.cpp *.h)
target_sources(foobar PRIVATE ${sources})

# or

# SAFE GLOBBING! :D
file(GLOB sources CONFIGURE_DEPENDS *.cpp *.h)
target_sources(foobar PRIVATE ${sources})

```

# Proposal

I think it would be great to add this support inside target\_sources

```auto
# To get recursive behavior specify the keyword RECURSIVE
target_sources(foobar RECURSE PRIVATE *.cpp *.h)

# Default is NON-RECURSIVE
target_sources(foobar PRIVATE *.cpp *.h)

```

Thoughts?

---

_[View the full topic](https://discourse.cmake.org/t/add-globbing-support-to-target-sources/3749)._
