[CMake] Bug in EXECUTE_PROCESS?

Josef Karthauser joe.karthauser at geomerics.com
Tue Dec 4 09:39:27 EST 2007


> -----Original Message-----
> From: Jesper Eskilson [mailto:jesper.eskilson at gmail.com] On Behalf Of
> Jesper Eskilson
> Sent: 04 December 2007 13:41
> To: Josef Karthauser
> Cc: cmake at cmake.org
> Subject: Re: [CMake] Bug in EXECUTE_PROCESS?
> 
> Josef Karthauser wrote:
> > Is this a bug?
> >
> >  EXECUTE_PROCESS(
> > COMMAND badcmd_that_doesnt_exist
> >                                 ERROR_VARIABLE ERROR
> > )
> > IF(ERROR)
> > MESSAGE(FATAL_ERROR "Error! Command doesn’t exist.")
> > ENDIF(ERROR)
> >
> > as the fatal_error is never raised.
> >
> > If not, what’s the canonical way of reliably determining whether the
> > process succeeded or failed?
> 
> Without actually checking the docs, I would guess that ERROR contains
> the exit code of the process, i.e. non-zero on failure. Try comparing
> ERROR against 0 instead.

My bad!  I didn't read the docs carefully enough.  ERROR_VARIABLE actually indicates the variable which should take the output of the stderr channel.  What I should have been using was RESULT_VARIABLE.

Joe


More information about the CMake mailing list