[CMake] creating custom make targets
Aaron Turner
synfinatic at gmail.com
Thu Feb 19 11:56:45 EST 2009
On Thu, Feb 19, 2009 at 8:29 AM, Matthew Woehlke
<mw_triad at users.sourceforge.net> wrote:
> 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.
Ok, that just seemed weird since it seemed like add_custom_target()
was always built. After more carefully reading the docs, I see that
it's just always out of date, but that's not the same as automatically
created as a dependency of 'all'.
>> 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).
Whoops, my bad. Typed "add_custom_target" not "add_custom_command".
Thanks everyone, this makes sense now.
--
Aaron Turner
http://synfin.net/
http://tcpreplay.synfin.net/ - Pcap editing and replay tools for Unix & Windows
Those who would give up essential Liberty, to purchase a little
temporary Safety,
deserve neither Liberty nor Safety.
-- Benjamin Franklin
More information about the CMake
mailing list