[CMake] COMMAND Doesn't Always Return Correct Exit Code

Christopher Piekarski polo1065 at gmail.com
Mon Jan 30 20:27:36 EST 2012


Awesome, works. Thanks.

#works
add_custom_target (anttest
   COMMENT "this is a garbage ANT test target"
   COMMAND "call"
      "ant"
)


On Mon, Jan 30, 2012 at 6:19 PM, David Cole <david.cole at kitware.com> wrote:

> If using nmake, try using "call ant" instead of just "ant". Using call
> will propagate the error return result correctly, I think.
>
>
> On Mon, Jan 30, 2012 at 8:12 PM, Christopher Piekarski
> <polo1065 at gmail.com> wrote:
> > When launching "ant" using the CMake COMMAND in a add_custom_target macro
> > the exit status is always 0. When the same "ant" command is run from the
> > command line with the same arguments from the same working directory the
> > exit codes are correctly reported back to the shell.
> >
> > #Works, returns exit code 2
> > add_custom_target (blah
> >  COMMENT "this is a garbage test target"
> >  COMMAND "dir"
> >  "-l"
> > )
> > #doesn't work, return 0 and should be 1 (like it is when run from command
> > line)
> > add_custom_target (anttest
> >  COMMENT "this is a garbage ANT test target"
> >  COMMAND "ant"
> > )
> >
> > The following is the output from 3 different shell commands. By
> inspecting
> > the command and the result output you can see the discrepancy.
> >
> > C:\Users\Chris\\build\cross-platform>nmake blah
> > Microsoft (R) Program Maintenance Utility Version 9.00.30729.01
> > Copyright (C) Microsoft Corporation.  All rights reserved.
> > [  0%] this is a garbage test target
> >  Volume in drive C has no label.
> >  Volume Serial Number is 72F0-29DB
> >  Directory of C:\Users\Chris\build\cross-platform
> > File Not Found
> > NMAKE : fatal error U1077: 'dir' : return code '0x1'
> > Stop.
> > NMAKE : fatal error U1077:
> > 'T:\HOST__i686-pc-windows\x86_64-pc-windows-msvc2008\
> > bin\nmake.exe' : return code '0x2'
> > Stop.
> > NMAKE : fatal error U1077:
> > 'T:\HOST__i686-pc-windows\x86_64-pc-windows-msvc2008\
> > bin\nmake.exe' : return code '0x2'
> > Stop.
> > NMAKE : fatal error U1077:
> > 'T:\HOST__i686-pc-windows\x86_64-pc-windows-msvc2008\
> > bin\nmake.exe' : return code '0x2'
> > Stop.
> > C:\Users\Chris\build\cross-platform>echo %ERRORLEVEL%
> > 2
> >
> >
> > C:\Users\Chris\rebit_bogus6\build\cross-platform>nmake anttest
> > Microsoft (R) Program Maintenance Utility Version 9.00.30729.01
> > Copyright (C) Microsoft Corporation.  All rights reserved.
> > [  0%] this is a garbage ANT test target
> > Buildfile: build.xml does not exist!
> > Build failed
> > [100%] Built target anttest
> > C:\Users\Chris\build\cross-platform>echo %ERRORLEVEL%
> > 0
> >
> > C:\Users\Chris\build\cross-platform>ant
> > Buildfile: build.xml does not exist!
> > Build failed
> > C:\Users\Chris\build\cross-platform>echo %ERRORLEVEL%
> > 1
> >
> >
> > Any thoughts?
> >
> > Thanks,
> > Chris
> >
> >
> > --
> >
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at
> > http://www.kitware.com/opensource/opensource.html
> >
> > Please keep messages on-topic and check the CMake FAQ at:
> > http://www.cmake.org/Wiki/CMake_FAQ
> >
> > Follow this link to subscribe/unsubscribe:
> > http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120130/790a55e7/attachment.htm>


More information about the CMake mailing list