[CMake] bug ? changed behaviour of ADD_CUSTOM_COMMAND

Brad King brad.king at kitware.com
Fri Sep 16 09:22:08 EDT 2005


Alexander Neundorf wrote:
> Hi, 
>  
> since Makefile generator 2 the following cmake code doesn't work anymore: 
>  
> ----------8<-----8<--------8<------------- 
>  
> ADD_CUSTOM_TARGET( world echo "world" DEPENDS hello) 
>  
> ADD_CUSTOM_TARGET( hello echo "hello" ) 
>  
> ----------8<-----8<--------8<------------- 
>  
> Currently "make world" leads to  
> make[3]: *** No rule to make target `hello', needed by `world'.  Stop. 
>  
> although the target "hello" is defined with the next command. 
> With cmake 2.0 this did work and "make world" executed first "hello" and 
> then "world". 
> Is this change intentional ? 

The original behavior was not intentional.  The DEPENDS option of 
ADD_CUSTOM_TARGET is meant for dependencies on the outputs of 
ADD_CUSTOM_COMMAND.  It was just coincidence that the generated makefile 
had the right dependencies, and I don't think it worked in other generators.

The way to add dependencies between top-level targets is with the 
ADD_DEPENDENCIES command:

ADD_CUSTOM_TARGET( world echo "world" )
ADD_CUSTOM_TARGET( hello echo "hello" )
ADD_DEPENDENCIES( world hello )

-Brad


More information about the CMake mailing list