summaryrefslogtreecommitdiffstats
path: root/Source/cmIfCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-01-20 19:35:22 (GMT)
committerBrad King <brad.king@kitware.com>2009-01-20 19:35:22 (GMT)
commita541cac325715cd50f604ede864eba8edfbb2673 (patch)
treee8b4b8b2546c2b492e7442662effe0afdd00a70f /Source/cmIfCommand.cxx
parent03c940aeb38c1456df336262d667b69304de0504 (diff)
downloadCMake-a541cac325715cd50f604ede864eba8edfbb2673.zip
CMake-a541cac325715cd50f604ede864eba8edfbb2673.tar.gz
CMake-a541cac325715cd50f604ede864eba8edfbb2673.tar.bz2
ENH: Improve response to bad if or elseif
Previously bad arguments to an if() or elseif() would cause some subsequent statements in the corresponding block to execute. This teaches CMake to stop processing commands with a fatal error. It also provides context to bad elseif() error messages.
Diffstat (limited to 'Source/cmIfCommand.cxx')
-rw-r--r--Source/cmIfCommand.cxx11
1 files changed, 9 insertions, 2 deletions
diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx
index 508a263..cbba2d3 100644
--- a/Source/cmIfCommand.cxx
+++ b/Source/cmIfCommand.cxx
@@ -76,6 +76,10 @@ IsFunctionBlocked(const cmListFileFunction& lff,
}
else
{
+ // Place this call on the call stack.
+ cmMakefileCall stack_manager(&mf, this->Functions[c], status);
+ static_cast<void>(stack_manager);
+
std::string errorString;
std::vector<std::string> expandedArguments;
@@ -98,8 +102,10 @@ IsFunctionBlocked(const cmListFileFunction& lff,
err += "(";
err += errorString;
err += ").";
- cmSystemTools::Error(err.c_str());
- return false;
+ mf.IssueMessage(cmake::FATAL_ERROR, err);
+ cmSystemTools::SetFatalErrorOccured();
+ mf.RemoveFunctionBlocker(lff);
+ return true;
}
if (isTrue)
@@ -204,6 +210,7 @@ bool cmIfCommand
err += errorString;
err += ").";
this->SetError(err.c_str());
+ cmSystemTools::SetFatalErrorOccured();
return false;
}