# We would like to learn how to generate documentation for targets

**URL:** https://discourse.cmake.org/t/we-would-like-to-learn-how-to-generate-documentation-for-targets/5880
**Category:** Code
**Created:** [June 16, 2022, 8:09pm UTC](https://discourse.cmake.org/t/we-would-like-to-learn-how-to-generate-documentation-for-targets/5880 "2022-06-16T20:09:50Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![kz7000](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/ba9def/32.png) [@kz7000](https://discourse.cmake.org/u/kz7000)
#### Post date: [June 16, 2022, 8:09pm UTC](https://discourse.cmake.org/t/we-would-like-to-learn-how-to-generate-documentation-for-targets/5880/1 "2022-06-16T20:09:51Z")

</div>

Hello,  
We would like to document selected targets in our cmake file.  
For example, the envisioned usage might look something like this:

```auto
mkdir build
cd build
cmake ..
make doc

```

This will then print out nicely formatted documentation, for example:

```auto
all Make everything
clean Clean up
foo Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod 
bar Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod 
blah Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod 
etc etc

```

Is there a way to do this, or something similar?  
There are numerous targets, and we would like to make it easier for the user, without having to maintain a separate document describing all the targets.  
We understand that `make help` lists all of the targets, but this is not what we are looking for.  
Thank you for your time.

---

<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: [June 16, 2022, 8:55pm UTC](https://discourse.cmake.org/t/we-would-like-to-learn-how-to-generate-documentation-for-targets/5880/2 "2022-06-16T20:55:11Z")

</div>

Not really, no. The best possible is to have a target that outputs the content you want. It may need to adapt for different generator behavior too. I would recommend just writing docs in `README.md` or other build documentation.

---

<div class="post-metadata">

### Author: ![kz7000](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/ba9def/32.png) [@kz7000](https://discourse.cmake.org/u/kz7000)
#### Post date: [June 16, 2022, 9:08pm UTC](https://discourse.cmake.org/t/we-would-like-to-learn-how-to-generate-documentation-for-targets/5880/3 "2022-06-16T21:08:45Z")

</div>

Thanks for the response Ben.

---

<div class="post-metadata">

### Author: ![benthevining](https://discourse.cmake.org/user_avatar/discourse.cmake.org/benthevining/32/1924_2.png) [@benthevining](https://discourse.cmake.org/u/benthevining)
#### Post date: [June 16, 2022, 10:06pm UTC](https://discourse.cmake.org/t/we-would-like-to-learn-how-to-generate-documentation-for-targets/5880/4 "2022-06-16T22:06:14Z")

</div>

FWIW, my development workflow is usually to use CMake as the build system, and I like to also create a makefile to use just as a task manager (it will invoke CMake configure & build). I usually create a `help` goal that lists all the Make goals (and there’s usually one per major CMake target), and the output looks a lot like what you posted in your example.

[Here is an example of such a Makefile](https://github.com/benthevining/Oranges/blob/main/Makefile).
