# CMake List of all Project Targets

**URL:** https://discourse.cmake.org/t/cmake-list-of-all-project-targets/1077
**Category:** Code
**Created:** [April 22, 2020, 6:36pm UTC](https://discourse.cmake.org/t/cmake-list-of-all-project-targets/1077 "2020-04-22T18:36:28Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![developer](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/bcef8e/32.png) [@developer](https://discourse.cmake.org/u/developer)
#### Post date: [April 22, 2020, 9:23pm UTC](https://discourse.cmake.org/t/cmake-list-of-all-project-targets/1077/5 "2020-04-22T21:23:49Z")

</div>

Does CMake not support recursive functions?

I have something like

```auto
function(getAllSubdirs dir dirs)
    message("called with dir (${dir}) and dirs (${dirs})")
    set(_dirs "")
    # get subdirectories for dir
    get_property(subdirs DIRECTORY ${dir} PROPERTY SUBDIRECTORIES)
    # iterate any found subdirectories
    foreach(subdir ${subdirs})
        # append each sub directory
        list(APPEND _dirs ${subdir})
        set(${dirs} _dirs PARENT_SCOPE)
        getAllSubdirs(${subdir} ${_dirs})
    endforeach()
endfunction()

set(dirs ".")
getAllSubDirs(. ${dirs})
message("all dirs " ${dirs})

```

It seems like any recursive calls to getAllSubdirs doesn’t actually pass the updated \_dirs to that function…

---

_[View the full topic](https://discourse.cmake.org/t/cmake-list-of-all-project-targets/1077)._
