summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalVisualStudioGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2011-04-11 15:48:08 (GMT)
committerBrad King <brad.king@kitware.com>2011-04-11 15:54:01 (GMT)
commit234bae7a204cc23fa0d297d5ab90db7ecc54f6d4 (patch)
tree3a9da5ddced25e998dede2cddb74e4e698b904ae /Source/cmLocalVisualStudioGenerator.cxx
parentb98fdd52848b45f97f8a38eaa7749186f6c8fab3 (diff)
downloadCMake-234bae7a204cc23fa0d297d5ab90db7ecc54f6d4.zip
CMake-234bae7a204cc23fa0d297d5ab90db7ecc54f6d4.tar.gz
CMake-234bae7a204cc23fa0d297d5ab90db7ecc54f6d4.tar.bz2
VS10: Fix exit code of custom commands with setlocal/endlocal (#11938)
Use the pattern setlocal ... endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone :cmErrorLevel exit /b %1 :cmDone if %errorlevel% neq 0 goto :VCEnd in custom commands to preserve the %errorlevel% from inside the setlocal/endlocal block.
Diffstat (limited to 'Source/cmLocalVisualStudioGenerator.cxx')
-rw-r--r--Source/cmLocalVisualStudioGenerator.cxx12
1 files changed, 8 insertions, 4 deletions
diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx
index f3936e1..4390a08 100644
--- a/Source/cmLocalVisualStudioGenerator.cxx
+++ b/Source/cmLocalVisualStudioGenerator.cxx
@@ -201,8 +201,6 @@ cmLocalVisualStudioGenerator
{
script += newline;
newline = newline_text;
- script += "set errlev=";
- script += newline;
script += "setlocal";
}
@@ -267,9 +265,15 @@ cmLocalVisualStudioGenerator
script += newline;
script += ":cmEnd";
script += newline;
- script += "endlocal & set errlev=%errorlevel%";
+ script += "endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone";
+ script += newline;
+ script += ":cmErrorLevel";
+ script += newline;
+ script += "exit /b %1";
+ script += newline;
+ script += ":cmDone";
script += newline;
- script += "if %errlev% neq 0 goto ";
+ script += "if %errorlevel% neq 0 goto ";
script += this->GetReportErrorLabel();
}