# Explain target dependencies for custom commands

**URL:** <https://discourse.cmake.org/t/explain-target-dependencies-for-custom-commands/639>\
**Category:** Code\
**Created:** [February 15, 2020, 9:30am UTC](https://discourse.cmake.org/t/explain-target-dependencies-for-custom-commands/639 "2020-02-15T09:30:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hex](https://discourse.cmake.org/user_avatar/discourse.cmake.org/hex/32/363_2.png) [@hex](https://discourse.cmake.org/u/hex)\
**Post date:** [February 15, 2020, 9:30am UTC](https://discourse.cmake.org/t/explain-target-dependencies-for-custom-commands/639/1 "2020-02-15T09:30:23Z")

</div>

> If a target is listed, it will be brought up to date any time the custom command’s output files are required to brought up to date.

Can I have an example for this?

What is the difference between this:

```auto
project(MyProj)

add_custom_target( tgt2 ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/object2 )
add_custom_command( OUTPUT object2
	COMMAND ${CMAKE_COMMAND} -E touch object2
	DEPENDS tgt1
)

add_custom_target( tgt1 )

```

and this:

```auto
project(MyProj)

add_custom_target( tgt2 ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/object2 )
add_custom_command( OUTPUT object2
   COMMAND ${CMAKE_COMMAND} -E touch object2
)

add_custom_target( tgt1 )

add_dependencies( tgt2 tgt1 )

```

I am trying to figure out a use case for the former, as I am always using the latter. What is the difference between a week dependency of a target and a strong dependency of a target, since custom targets are always considered out of date?

---

<div class="post-metadata">

**Author:** ![hex](https://discourse.cmake.org/user_avatar/discourse.cmake.org/hex/32/363_2.png) [@hex](https://discourse.cmake.org/u/hex)\
**Post date:** [February 17, 2020, 11:42am UTC](https://discourse.cmake.org/t/explain-target-dependencies-for-custom-commands/639/2 "2020-02-17T11:42:51Z")

</div>

one difference I found is that the 2nd code sets property `MANUALLY_ADDED_DEPENDENCIES`.
