[CMake] creating custom make targets

Matthew Woehlke mw_triad at users.sourceforge.net
Thu Feb 19 11:29:18 EST 2009


Aaron Turner wrote:
> From the docs, it sounded like this only worked when adding commands
> to existing targets, not for creating new ones.

Correct, as Eric already pointed out. You need to create the target 
first with add_custom_target.

> My testing though seems to show that the correct usage is actually:
> add_custom_command(foo ...)
> 
> if you use:
> add_custom_command(TARGET foo ...)
> 
> then the target name (verified by 'make help') is called "TARGET", not "foo"

That's... interesting. The doc says:

     add_custom_command(TARGET target
                        PRE_BUILD | PRE_LINK | POST_BUILD
                        COMMAND command1 [ARGS] [args1...]
                        [COMMAND command2 [ARGS] [args2...] ...]
                        [WORKING_DIRECTORY dir]
                        [COMMENT comment] [VERBATIM])

...but that's creating a target named "TARGET"? If so it would seem to 
be a bug (either in cmake or in the doc; either way it would be good if 
you could confirm this, and if it isn't working according to the doc, 
file a bug report).

-- 
Matthew
Please do not quote my e-mail address unobfuscated in message bodies.
-- 
We are Microsoft. What you are experiencing is not a problem; it is an 
undocumented feature. -- Unknown (from fortune's bofh-excuses)



More information about the CMake mailing list