[CMake] creating custom make targets
Leo Breebaart
leo at lspace.org
Mon Feb 23 11:03:23 EST 2009
Brad King <brad.king at kitware.com> writes:
> To answer the original question, the best way to generate a
> bunch of things only when the users asks is to use
> add_custom_command to create the rules and then associate them
> with a top-level target using add_custom_target:
>
> add_custom_command(
> OUTPUT myfile.txt
> COMMAND ... # command to generate myfile.txt here
> DEPENDS ... # file-level depends here
> )
>
> add_custom_target(test_standard DEPENDS myfile.txt)
>
> When add_custom_target is not given the ALL option, it will not
> build unless the user explicitly requests it with "make
> test_standard". Then the custom commands it drives will still
> have normal dependencies to only rebuild when necessary.
A related problem I am currently experiencing is the following: I
have a custom target that should only ever be invoked manually,
but I *do* want it to be dependent on *all* the other top-level
targets. (It's a packaging target, so my "make bdist" should
always be preceded by a "make all".)
In Makefile terms that would be a very easy dependency to add,
because you can literally just say:
bdist: all
<actions>
Is there a way to tell CMake to generate such a dependency? The
project is rather large, so I'd rather not add all the top-level
dependencies manually via add_dependencies(), but something like
"add_dependencies(bdist ALL)" would be nice.
--
Leo Breebaart <leo at lspace.org>
More information about the CMake
mailing list