[CMake] Make target dependent on all executables & libraries

Tyler Roscoe tyler at cryptio.net
Tue Mar 31 16:36:40 EDT 2009


On Tue, Mar 31, 2009 at 12:47:33PM -0400, Lezz Giles wrote:
> ADD_EXECUTABLE( hellow hellow.c )
> 
> ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/docs COMMAND cat ${CMAKE_SOURCE_DIR}/hellowdoc.template > ${CMAKE_BINARY_DIR}/docs)
> 
> ADD_CUSTOM_TARGET(documentation DEPENDS ${CMAKE_BINARY_DIR}/docs)
> 
> I want to make my custom_command dependent on the executable.  If I add "DEPENDS hellow" then it works, but as I said before, this is going to be shared across multiple projects.  If I add "DEPENDS ALL" or "DEPENDS all" then it interprets "all" as a filename and looks for "../all"

I'm still not sure how to best solve your original problem, but the
DEPENDS argument to add_custom_target is for depending on files. You
probably want to use add_dependencies(), which lets you set up
dependencies on targets:

add_dependencies(documentation hellow)

hth,
tyler


More information about the CMake mailing list