ENH: add enum to IssueMessage

This commit is contained in:
Bill Hoffman 2008-03-11 10:29:56 -04:00
parent 9d4730f441
commit dc9245df6c
5 changed files with 25 additions and 30 deletions

View File

@ -146,7 +146,7 @@ bool cmListFile::ParseFile(const char* filename,
switch (mf->GetPolicyStatus(cmPolicies::CMP_0000))
{
case cmPolicies::WARN:
mf->IssueWarning(
mf->IssueMessage(cmake::AUTHOR_WARNING,
mf->GetPolicies()->GetPolicyWarning(cmPolicies::CMP_0000)
);
@ -155,7 +155,7 @@ bool cmListFile::ParseFile(const char* filename,
case cmPolicies::OLD:
break;
default:
mf->IssueError(
mf->IssueMessage(cmake::FATAL_ERROR,
mf->GetPolicies()->GetRequiredPolicyError(cmPolicies::CMP_0000)
);
return false;

View File

@ -282,26 +282,16 @@ bool cmMakefile::CommandExists(const char* name) const
return this->GetCMakeInstance()->CommandExists(name);
}
//----------------------------------------------------------------------------
void cmMakefile::IssueError(std::string const& msg) const
{
this->IssueMessage(msg, true);
}
//----------------------------------------------------------------------------
void cmMakefile::IssueWarning(std::string const& msg) const
{
this->IssueMessage(msg, false);
}
//----------------------------------------------------------------------------
void cmMakefile::IssueMessage(std::string const& text, bool isError) const
void cmMakefile::IssueMessage(cmake::MessageType t, std::string const& text) const
{
cmOStringStream msg;
bool isError = false;
// Construct the message header.
if(isError)
if(t == cmake::FATAL_ERROR)
{
isError = true;
msg << "CMake Error:";
}
else
@ -439,7 +429,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
if(!status.GetNestedError())
{
// The command invocation requested that we report an error.
this->IssueError(pcmd->GetError());
this->IssueMessage(cmake::FATAL_ERROR, pcmd->GetError());
}
result = false;
if ( this->GetCMakeInstance()->GetScriptMode() )
@ -459,7 +449,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
std::string error = "Command ";
error += pcmd->GetName();
error += "() is not scriptable";
this->IssueError(error);
this->IssueMessage(cmake::FATAL_ERROR, error);
result = false;
cmSystemTools::SetFatalErrorOccured();
}
@ -471,7 +461,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
std::string error = "Unknown CMake command \"";
error += lff.Name;
error += "\".";
this->IssueError(error);
this->IssueMessage(cmake::FATAL_ERROR, error);
result = false;
cmSystemTools::SetFatalErrorOccured();
}
@ -619,7 +609,7 @@ bool cmMakefile::ReadListFile(const char* filename_in,
{
if(endScopeNicely)
{
this->IssueError("cmake_policy PUSH without matching POP");
this->IssueMessage(cmake::FATAL_ERROR, "cmake_policy PUSH without matching POP");
}
this->PopPolicy(false);
}
@ -3260,13 +3250,13 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
switch (this->GetPolicyStatus(cmPolicies::CMP_0002))
{
case cmPolicies::WARN:
this->IssueWarning(this->GetPolicies()->
this->IssueMessage(cmake::AUTHOR_WARNING, this->GetPolicies()->
GetPolicyWarning(cmPolicies::CMP_0002));
case cmPolicies::OLD:
return true;
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
this->IssueError(
this->IssueMessage(cmake::FATAL_ERROR,
this->GetPolicies()->GetRequiredPolicyError(cmPolicies::CMP_0002)
);
return true;

View File

@ -25,6 +25,7 @@
#include "cmPropertyMap.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
#include "cmake.h"
#if defined(CMAKE_BUILD_WITH_CMAKE)
#include "cmSourceGroup.h"
@ -784,9 +785,8 @@ public:
void PopScope();
void RaiseScope(const char *var, const char *value);
/** Issue messages with the given text plus context information. */
void IssueWarning(std::string const& msg) const;
void IssueError(std::string const& msg) const;
void IssueMessage(cmake::MessageType t,
std::string const& text) const;
protected:
// add link libraries and directories to the target
@ -891,8 +891,6 @@ private:
CallStackType CallStack;
friend class cmMakefileCall;
void IssueMessage(std::string const& text, bool isError) const;
cmTarget* FindBasicTarget(const char* name);
std::vector<cmTarget*> ImportedTargetsOwned;
std::map<cmStdString, cmTarget*> ImportedTargets;

View File

@ -202,8 +202,8 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf,
// it is an error if the policy version is less than 2.4
if (majorVer < 2 || majorVer == 2 && minorVer < 4)
{
mf->IssueError(
{
mf->IssueMessage(cmake::FATAL_ERROR,
"An attempt was made to set the policy version of CMake to something "
"earlier than \"2.4\". "
"In CMake 2.4 and below backwards compatibility was handled with the "
@ -213,7 +213,7 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf,
"CMAKE_BACKWARDS_COMPATIBILITY variable. "
"One way to so this is to set the policy version to 2.4 exactly."
);
}
}
// now loop over all the policies and set them as appropriate
std::map<cmPolicies::PolicyID,cmPolicy *>::iterator i

View File

@ -58,6 +58,13 @@ class cmPolicies;
class cmake
{
public:
enum MessageType
{ AUTHOR_WARNING,
FATAL_ERROR,
MESSAGE,
WARNING,
LOG
};
typedef std::map<cmStdString, cmCommand*> RegisteredCommandsMap;
///! construct an instance of cmake