# cmake 4.0.2 gives warning for DEPENDS keyword in add\_custom\_command

**URL:** https://discourse.cmake.org/t/cmake-4-0-2-gives-warning-for-depends-keyword-in-add-custom-command/14077
**Category:** Usage
**Tags:** os:windows
**Created:** [May 10, 2025, 10:14pm UTC](https://discourse.cmake.org/t/cmake-4-0-2-gives-warning-for-depends-keyword-in-add-custom-command/14077 "2025-05-10T22:14:04Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Wim\_Delvaux](https://discourse.cmake.org/user_avatar/discourse.cmake.org/wim_delvaux/32/5558_2.png) [@Wim\_Delvaux](https://discourse.cmake.org/u/Wim_Delvaux)
#### Post date: [May 10, 2025, 10:14pm UTC](https://discourse.cmake.org/t/cmake-4-0-2-gives-warning-for-depends-keyword-in-add-custom-command/14077/1 "2025-05-10T22:14:04Z")

</div>

I get this warning

CMake Warning (dev) at C:/Data/Projects/QtBuildTools/utils.cmake:670 (add\_custom\_command):  
+ CategoryInfo : NotSpecified: (CMake Warning (…ustom\_command)::String) , RemoteException  
+ FullyQualifiedErrorId : NativeCommandError  
+ PSComputerName : localhost

The following keywords are not supported when using  
add\_custom\_command(TARGET): DEPENDS.  
NotSpecified: (:String) , RemoteException  
Policy CMP0175 is not set: add\_custom\_command() rejects invalid arguments.  
Run “cmake --help-policy CMP0175” for policy details. Use the cmake\_policy  
command to set the policy and suppress this warning.  
Call Stack (most recent call first):  
C:/Data/Projects/QtBuildTools/build.cmake:371 (UTILSF\_CopyArtefactsToMain)  
CMakeLists.txt:11 (UTILSF\_BuildLibrary)

now according to the docs of 4.0.2 DEPENDS is a valid keyword.

this is the cmake code

```
foreach( a IN LISTS ${_Artefacts} )
	add_custom_command(
		TARGET ${tgt}
		POST_BUILD
		DEPENDS ${OPTS_SOURCEDIR}/${a}
		COMMAND ${CMAKE_COMMAND}
			"-DTO_COPY=${OPTS_SOURCEDIR}/${a}" 
			"-DCOPY_TO=${${_DestDir}}" 
			-P ${QtBuildtoolsDir}/copy_if_exists.cmake
		VERBATIM )
endforeach()

```

---

<div class="post-metadata">

### Author: ![hsattler](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/h/59ef9b/32.png) [@hsattler](https://discourse.cmake.org/u/hsattler)
#### Post date: [May 11, 2025, 7:04am UTC](https://discourse.cmake.org/t/cmake-4-0-2-gives-warning-for-depends-keyword-in-add-custom-command/14077/2 "2025-05-11T07:04:47Z")

</div>

add\_custom\_command(TARGET) does not support DEPENDS, only add\_custom\_command(OUTPUT) does.
