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

Christopher Piekarski polo1065 at gmail.com
Mon Jan 30 20:12:21 EST 2012


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120130/afea3076/attachment-0001.htm>


More information about the CMake mailing list