[CMake] what happens when add_custom_command returns non zero

James Bigler jamesbigler at gmail.com
Thu Oct 16 18:03:59 EDT 2008


I'll grant you that I believe the tool should remove the partially
written file, but the tool is out of my hands.

So let's say I do this for a work around.

1. Set the output file as a temporary file.
2. Add a second command that moves the temporary file to the desired
output file.

Questions:

1. Can CMake help me generate a temporary file name by either giving
me one or helping me find the temporary directory I could put a
temporary file into?
2. Will CMake stop processing the commands of a custom target once the
previous command produces an error?  The help page doesn't say one way
or the other.

Obviously #2 is more important than #1.

James

On Thu, Oct 16, 2008 at 3:54 PM, David Cole <david.cole at kitware.com> wrote:
> That depends. Do you want it to be easy or hard to diagnose the failure...
> :-) (I suppose you could concoct a case where leaving the file would make it
> easier to diagnose and another case where deleting it would make it
> easier...)
>
> CMake didn't write the file, why should it delete it?
> Shouldn't the tool that returned the -1 delete the partially written file on
> a failure...?
>
> One reason I can think of why CMake shouldn't be responsible for this is
> that a custom command may generate *many* files, only one of which might be
> reasonable to delete on a tool failure.
>
> So..... I think CMake is correct in *not* deleting custom command output
> files on custom command failure.
>
> Discussion welcome, though.
>
> Cheers,
> David
>
>
> On Thu, Oct 16, 2008 at 5:46 PM, James Bigler <jamesbigler at gmail.com> wrote:
>>
>> So what happens when add_custom_command returns non zero?
>>
>> Is the output file supposed to be removed?
>>
>> I have a command that returns -1, but happens to leave a partially
>> written file.  Should CMake delete the file for me when the command
>> fails?
>>
>> Thanks,
>> James
>> _______________________________________________
>> CMake mailing list
>> CMake at cmake.org
>> http://www.cmake.org/mailman/listinfo/cmake
>
>


More information about the CMake mailing list