# Feature request: Get targets list from configured buildsystem from command line, not file api

**URL:** https://discourse.cmake.org/t/feature-request-get-targets-list-from-configured-buildsystem-from-command-line-not-file-api/7537
**Category:** Development
**Created:** [February 24, 2023, 2:22pm UTC](https://discourse.cmake.org/t/feature-request-get-targets-list-from-configured-buildsystem-from-command-line-not-file-api/7537 "2023-02-24T14:22:40Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![leha-bot](https://discourse.cmake.org/user_avatar/discourse.cmake.org/leha-bot/32/921_2.png) [@leha-bot](https://discourse.cmake.org/u/leha-bot)
#### Post date: [February 24, 2023, 2:22pm UTC](https://discourse.cmake.org/t/feature-request-get-targets-list-from-configured-buildsystem-from-command-line-not-file-api/7537/1 "2023-02-24T14:22:40Z")

</div>

It would be very convenient to add flag like `--list-targets` into the `cmake --build <build-dir>` to get the human-readable (and possibly machine-readable in JSON/another format) list of targets.  
Currently it’s very difficult to get the actual targets list, one possible way is the cmake-file(7) api (parsing the codemodel-v2 query’s ‘targets’ dictionary in JSON) which is intended to use in IDEs’ integrations.

I also think that this parameter may have the same name as the `ctest`’s way to print info about tests: `cmake --build <build-dir> -N`.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [February 24, 2023, 7:43pm UTC](https://discourse.cmake.org/t/feature-request-get-targets-list-from-configured-buildsystem-from-command-line-not-file-api/7537/2 "2023-02-24T19:43:58Z")

</div>

This can only be retrieved by rerunning the configure. Why is the file-api not suitable here?

---

<div class="post-metadata">

### Author: ![leha-bot](https://discourse.cmake.org/user_avatar/discourse.cmake.org/leha-bot/32/921_2.png) [@leha-bot](https://discourse.cmake.org/u/leha-bot)
#### Post date: [February 24, 2023, 8:35pm UTC](https://discourse.cmake.org/t/feature-request-get-targets-list-from-configured-buildsystem-from-command-line-not-file-api/7537/3 "2023-02-24T20:35:50Z")

</div>

Ok, we may add this flag into configure mode 😊
