[CMake] problem with ADD_CUSTOM_COMMAND - multiple outputs

Brad King brad.king at kitware.com
Thu Mar 23 09:29:19 EST 2006


Alexander Neundorf wrote:
> with ADD_CUSTOM_COMMAND() you can specify exactly one output file. 
> In KDE we have cases (e.g. kconfig_compiler) where one custom command 
> produces more than one file, but e.g. two (source and header). 
>  
> I guess this could lead to missing dependencies, which might hurt when 
> doing parallel builds. I didn't test yet, but this is probably true. What 
> can I do to add the missing dependencies ? 

How would this appear in a makefile?  Perhaps

output2: output1
output1: the_real_depends
   the_real_command

To do this in CMake you can add a second custom command that outputs the 
second output and depends on the first but with no command.

ADD_CUSTOM_COMMAND(
   OUTPUT output1
   COMMAND the_real_command
   DEPENDS the_real_depends
   )

ADD_CUSTOM_COMMAND(
   OUTPUT output2
   COMMAND ${CMAKE_COMMAND} -E echo "output2 is up to date"
   DEPENDS output1
   )

-Brad


More information about the CMake mailing list