[CMake] ADD_CUSTOM_COMMAND and Dependencies

Michael Wild themiwi at gmail.com
Mon Jul 25 09:49:37 EDT 2011


On 07/25/2011 03:24 PM, Micha Renner wrote:
> There is following sequence:
> 
> ADD_EXECUTEABLE(generator gen.c)
> 
> ADD_CUSTOM_COMMAND(OUTPUT tlib.h
> 	COMMAND generator > tlib.h)
> 
> ADD_LIBRARY(tlib tlib.c tlib.h)
> 
> The question: Is it sure that ADD_EXECUTEABLE is invoked before the
> library is build or is here an ADD_DEPENDENCIES(tlib generator)
> necessary?
> 
> Greetings
> 
> Micha
> 

Yes, CMake should recognize that "generator" is a target and create the
dependency of tlib.h on "generator" automagically. And since it knows
that tlib.h is GENERATED, it will also add a dependency of tlib on
tlib.h. If you want to make really sure that CMake understands that
"generator" is a target, use generator expressions, like
"$<TARGET_FILE:generator>", but that works only since 2.8.4.

HTH

Michael


More information about the CMake mailing list