[CMake] How to guarntee the sequence of build if no target can be used

Tyler Roscoe tyler at cryptio.net
Thu May 28 11:04:43 EDT 2009


On Thu, May 28, 2009 at 10:22:16AM -0400, Dong Tiger wrote:
> The problem I ran into when using add_custom_command is that C files will be
> compiled before foo.h is generated and the compilation will fail.

Sounds like you need to add_dependencies(C_target foo.h_custom_target).

> > If your custom_target() has correct OUTPUT and DEPENDS parameters, this
> > should not happen. Are you specifying ALL in your add_custom_target()?
> 
> The manual doesn't mention OUTPUT can be specified in add_custom_target. And
> it reads that "(The target) is ALWAYS CONSIDERED OUT OF DATE even if the
> commands try to create a file with the name of the target.".

Yes I was mixing custom_command with custom_target. Since you have an
OUTPUT (foo.h) you must have a custom_command, right?

I think what that ALWAYS OUT OF DATE scary warning means is that the
target will always be "visited" by CMake. The OUTPUT is not regenerated
unless one of the DEPENDS changes -- I do this a lot and it works well
for my projects.

tyler


More information about the CMake mailing list