ENH: add enum to IssueMessage
This commit is contained in:
parent
9d4730f441
commit
dc9245df6c
|
@ -146,7 +146,7 @@ bool cmListFile::ParseFile(const char* filename,
|
||||||
switch (mf->GetPolicyStatus(cmPolicies::CMP_0000))
|
switch (mf->GetPolicyStatus(cmPolicies::CMP_0000))
|
||||||
{
|
{
|
||||||
case cmPolicies::WARN:
|
case cmPolicies::WARN:
|
||||||
mf->IssueWarning(
|
mf->IssueMessage(cmake::AUTHOR_WARNING,
|
||||||
mf->GetPolicies()->GetPolicyWarning(cmPolicies::CMP_0000)
|
mf->GetPolicies()->GetPolicyWarning(cmPolicies::CMP_0000)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ bool cmListFile::ParseFile(const char* filename,
|
||||||
case cmPolicies::OLD:
|
case cmPolicies::OLD:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
mf->IssueError(
|
mf->IssueMessage(cmake::FATAL_ERROR,
|
||||||
mf->GetPolicies()->GetRequiredPolicyError(cmPolicies::CMP_0000)
|
mf->GetPolicies()->GetRequiredPolicyError(cmPolicies::CMP_0000)
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -282,26 +282,16 @@ bool cmMakefile::CommandExists(const char* name) const
|
||||||
return this->GetCMakeInstance()->CommandExists(name);
|
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
|
void cmMakefile::IssueMessage(cmake::MessageType t, std::string const& text) const
|
||||||
{
|
|
||||||
this->IssueMessage(msg, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void cmMakefile::IssueMessage(std::string const& text, bool isError) const
|
|
||||||
{
|
{
|
||||||
cmOStringStream msg;
|
cmOStringStream msg;
|
||||||
|
bool isError = false;
|
||||||
// Construct the message header.
|
// Construct the message header.
|
||||||
if(isError)
|
if(t == cmake::FATAL_ERROR)
|
||||||
{
|
{
|
||||||
|
isError = true;
|
||||||
msg << "CMake Error:";
|
msg << "CMake Error:";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -439,7 +429,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
|
||||||
if(!status.GetNestedError())
|
if(!status.GetNestedError())
|
||||||
{
|
{
|
||||||
// The command invocation requested that we report an error.
|
// The command invocation requested that we report an error.
|
||||||
this->IssueError(pcmd->GetError());
|
this->IssueMessage(cmake::FATAL_ERROR, pcmd->GetError());
|
||||||
}
|
}
|
||||||
result = false;
|
result = false;
|
||||||
if ( this->GetCMakeInstance()->GetScriptMode() )
|
if ( this->GetCMakeInstance()->GetScriptMode() )
|
||||||
|
@ -459,7 +449,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
|
||||||
std::string error = "Command ";
|
std::string error = "Command ";
|
||||||
error += pcmd->GetName();
|
error += pcmd->GetName();
|
||||||
error += "() is not scriptable";
|
error += "() is not scriptable";
|
||||||
this->IssueError(error);
|
this->IssueMessage(cmake::FATAL_ERROR, error);
|
||||||
result = false;
|
result = false;
|
||||||
cmSystemTools::SetFatalErrorOccured();
|
cmSystemTools::SetFatalErrorOccured();
|
||||||
}
|
}
|
||||||
|
@ -471,7 +461,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
|
||||||
std::string error = "Unknown CMake command \"";
|
std::string error = "Unknown CMake command \"";
|
||||||
error += lff.Name;
|
error += lff.Name;
|
||||||
error += "\".";
|
error += "\".";
|
||||||
this->IssueError(error);
|
this->IssueMessage(cmake::FATAL_ERROR, error);
|
||||||
result = false;
|
result = false;
|
||||||
cmSystemTools::SetFatalErrorOccured();
|
cmSystemTools::SetFatalErrorOccured();
|
||||||
}
|
}
|
||||||
|
@ -619,7 +609,7 @@ bool cmMakefile::ReadListFile(const char* filename_in,
|
||||||
{
|
{
|
||||||
if(endScopeNicely)
|
if(endScopeNicely)
|
||||||
{
|
{
|
||||||
this->IssueError("cmake_policy PUSH without matching POP");
|
this->IssueMessage(cmake::FATAL_ERROR, "cmake_policy PUSH without matching POP");
|
||||||
}
|
}
|
||||||
this->PopPolicy(false);
|
this->PopPolicy(false);
|
||||||
}
|
}
|
||||||
|
@ -3260,13 +3250,13 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
|
||||||
switch (this->GetPolicyStatus(cmPolicies::CMP_0002))
|
switch (this->GetPolicyStatus(cmPolicies::CMP_0002))
|
||||||
{
|
{
|
||||||
case cmPolicies::WARN:
|
case cmPolicies::WARN:
|
||||||
this->IssueWarning(this->GetPolicies()->
|
this->IssueMessage(cmake::AUTHOR_WARNING, this->GetPolicies()->
|
||||||
GetPolicyWarning(cmPolicies::CMP_0002));
|
GetPolicyWarning(cmPolicies::CMP_0002));
|
||||||
case cmPolicies::OLD:
|
case cmPolicies::OLD:
|
||||||
return true;
|
return true;
|
||||||
case cmPolicies::REQUIRED_IF_USED:
|
case cmPolicies::REQUIRED_IF_USED:
|
||||||
case cmPolicies::REQUIRED_ALWAYS:
|
case cmPolicies::REQUIRED_ALWAYS:
|
||||||
this->IssueError(
|
this->IssueMessage(cmake::FATAL_ERROR,
|
||||||
this->GetPolicies()->GetRequiredPolicyError(cmPolicies::CMP_0002)
|
this->GetPolicies()->GetRequiredPolicyError(cmPolicies::CMP_0002)
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "cmPropertyMap.h"
|
#include "cmPropertyMap.h"
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
#include "cmTarget.h"
|
#include "cmTarget.h"
|
||||||
|
#include "cmake.h"
|
||||||
|
|
||||||
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
||||||
#include "cmSourceGroup.h"
|
#include "cmSourceGroup.h"
|
||||||
|
@ -784,9 +785,8 @@ public:
|
||||||
void PopScope();
|
void PopScope();
|
||||||
void RaiseScope(const char *var, const char *value);
|
void RaiseScope(const char *var, const char *value);
|
||||||
|
|
||||||
/** Issue messages with the given text plus context information. */
|
void IssueMessage(cmake::MessageType t,
|
||||||
void IssueWarning(std::string const& msg) const;
|
std::string const& text) const;
|
||||||
void IssueError(std::string const& msg) const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// add link libraries and directories to the target
|
// add link libraries and directories to the target
|
||||||
|
@ -891,8 +891,6 @@ private:
|
||||||
CallStackType CallStack;
|
CallStackType CallStack;
|
||||||
friend class cmMakefileCall;
|
friend class cmMakefileCall;
|
||||||
|
|
||||||
void IssueMessage(std::string const& text, bool isError) const;
|
|
||||||
|
|
||||||
cmTarget* FindBasicTarget(const char* name);
|
cmTarget* FindBasicTarget(const char* name);
|
||||||
std::vector<cmTarget*> ImportedTargetsOwned;
|
std::vector<cmTarget*> ImportedTargetsOwned;
|
||||||
std::map<cmStdString, cmTarget*> ImportedTargets;
|
std::map<cmStdString, cmTarget*> ImportedTargets;
|
||||||
|
|
|
@ -202,8 +202,8 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf,
|
||||||
|
|
||||||
// it is an error if the policy version is less than 2.4
|
// it is an error if the policy version is less than 2.4
|
||||||
if (majorVer < 2 || majorVer == 2 && minorVer < 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 "
|
"An attempt was made to set the policy version of CMake to something "
|
||||||
"earlier than \"2.4\". "
|
"earlier than \"2.4\". "
|
||||||
"In CMake 2.4 and below backwards compatibility was handled with the "
|
"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. "
|
"CMAKE_BACKWARDS_COMPATIBILITY variable. "
|
||||||
"One way to so this is to set the policy version to 2.4 exactly."
|
"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
|
// now loop over all the policies and set them as appropriate
|
||||||
std::map<cmPolicies::PolicyID,cmPolicy *>::iterator i
|
std::map<cmPolicies::PolicyID,cmPolicy *>::iterator i
|
||||||
|
|
|
@ -58,6 +58,13 @@ class cmPolicies;
|
||||||
class cmake
|
class cmake
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
enum MessageType
|
||||||
|
{ AUTHOR_WARNING,
|
||||||
|
FATAL_ERROR,
|
||||||
|
MESSAGE,
|
||||||
|
WARNING,
|
||||||
|
LOG
|
||||||
|
};
|
||||||
typedef std::map<cmStdString, cmCommand*> RegisteredCommandsMap;
|
typedef std::map<cmStdString, cmCommand*> RegisteredCommandsMap;
|
||||||
|
|
||||||
///! construct an instance of cmake
|
///! construct an instance of cmake
|
||||||
|
|
Loading…
Reference in New Issue