[CMake] don't auto-clean generated files?

Aaron Turner synfinatic at gmail.com
Mon Sep 7 19:01:34 EDT 2009


On Mon, Sep 7, 2009 at 1:00 PM, Alexander
Neundorf<a.neundorf-work at gmx.net> wrote:
> On Monday 07 September 2009, Aaron Turner wrote:
>> I'm look for a way to tell cmake to not automatically remove certain
>> auto-generated files when the 'clean' target is invoked.
>>
>> Basically I have:
>>
>>     add_custom_command(OUTPUT tcpbridge_opts.c tcpbridge_opts.h
>>         COMMAND ${AUTOGEN} -L tcpedit tcpbridge_opts.def
>>         DEPENDS tcpbridge_opts.def
>>     )
>>
>> And of course, other files depend on tcpbridge_opts.[ch]
>>
>> The problem is that I don't want tcpbridge_opts.[ch] deleted when
>> 'make clean' is run.
>
> Why don't you want this file to be deleted ?

Because, counter to my general rule of thumb of never committing
generated code, I've decided to check in some generated code.  These
files also need to be shipped in the source tarballs.  Long story
short: The templates used to generate the files is *very* particular
about what version of autogen is used and I find I get far too many
users checking out the code who have problems when they use the wrong
version.

> Maybe an ADD_CUSTOM_TARGET() would be more suitable ?

I was under the impression that the outputs of targets are always
deleted when 'make clean' is run... at least that's how it seems to
work.

-- 
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