Port to static cmPolicies API.

This commit is contained in:
Stephen Kelly 2015-05-03 10:12:10 +02:00
parent 13981f2068
commit de21168612
26 changed files with 83 additions and 157 deletions

View File

@ -380,8 +380,7 @@ bool cmAddCustomCommandCommand
switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0050)) switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0050))
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
e << (this->Makefile->GetPolicies() e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0050) << "\n";
->GetPolicyWarning(cmPolicies::CMP0050)) << "\n";
break; break;
case cmPolicies::OLD: case cmPolicies::OLD:
issueMessage = false; issueMessage = false;

View File

@ -194,8 +194,7 @@ bool cmAddCustomTargetCommand
switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0037)) switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0037))
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
e << (this->Makefile->GetPolicies() e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0037) << "\n";
->GetPolicyWarning(cmPolicies::CMP0037)) << "\n";
issueMessage = true; issueMessage = true;
case cmPolicies::OLD: case cmPolicies::OLD:
break; break;

View File

@ -84,8 +84,7 @@ bool cmAddExecutableCommand
switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0037)) switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0037))
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
e << (this->Makefile->GetPolicies() e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0037) << "\n";
->GetPolicyWarning(cmPolicies::CMP0037)) << "\n";
issueMessage = true; issueMessage = true;
case cmPolicies::OLD: case cmPolicies::OLD:
break; break;

View File

@ -222,8 +222,7 @@ bool cmAddLibraryCommand
case cmPolicies::WARN: case cmPolicies::WARN:
if(type != cmTarget::INTERFACE_LIBRARY) if(type != cmTarget::INTERFACE_LIBRARY)
{ {
e << (this->Makefile->GetPolicies() e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0037) << "\n";
->GetPolicyWarning(cmPolicies::CMP0037)) << "\n";
issueMessage = true; issueMessage = true;
} }
case cmPolicies::OLD: case cmPolicies::OLD:

View File

@ -23,8 +23,7 @@ bool cmBreakCommand::InitialPass(std::vector<std::string> const &args,
switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0055)) switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0055))
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
e << (this->Makefile->GetPolicies() e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0055) << "\n";
->GetPolicyWarning(cmPolicies::CMP0055)) << "\n";
break; break;
case cmPolicies::OLD: case cmPolicies::OLD:
issueMessage = false; issueMessage = false;
@ -58,8 +57,7 @@ bool cmBreakCommand::InitialPass(std::vector<std::string> const &args,
switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0055)) switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0055))
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
e << (this->Makefile->GetPolicies() e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0055) << "\n";
->GetPolicyWarning(cmPolicies::CMP0055)) << "\n";
break; break;
case cmPolicies::OLD: case cmPolicies::OLD:
issueMessage = false; issueMessage = false;

View File

@ -111,7 +111,7 @@ bool cmCMakePolicyCommand::HandleGetMode(std::vector<std::string> const& args)
// Lookup the policy number. // Lookup the policy number.
cmPolicies::PolicyID pid; cmPolicies::PolicyID pid;
if(!this->Makefile->GetPolicies()->GetPolicyID(id.c_str(), pid)) if(!cmPolicies::GetPolicyID(id.c_str(), pid))
{ {
std::ostringstream e; std::ostringstream e;
e << "GET given policy \"" << id << "\" which is not known to this " e << "GET given policy \"" << id << "\" which is not known to this "
@ -141,7 +141,7 @@ bool cmCMakePolicyCommand::HandleGetMode(std::vector<std::string> const& args)
// The policy is required to be set before anything needs it. // The policy is required to be set before anything needs it.
{ {
std::ostringstream e; std::ostringstream e;
e << this->Makefile->GetPolicies()->GetRequiredPolicyError(pid) e << cmPolicies::GetRequiredPolicyError(pid)
<< "\n" << "\n"
<< "The call to cmake_policy(GET " << id << " ...) at which this " << "The call to cmake_policy(GET " << id << " ...) at which this "
<< "error appears requests the policy, and this version of CMake " << "error appears requests the policy, and this version of CMake "

View File

@ -180,7 +180,7 @@ public:
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, this->Makefile->IssueMessage(cmake::AUTHOR_WARNING,
this->Makefile->GetPolicies()->GetPolicyWarning(pol)); cmPolicies::GetPolicyWarning(pol));
case cmPolicies::OLD: case cmPolicies::OLD:
return false; return false;
case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_IF_USED:

View File

@ -556,8 +556,7 @@ bool cmComputeLinkInformation::Compute()
if (!this->CMP0060WarnItems.empty()) if (!this->CMP0060WarnItems.empty())
{ {
std::ostringstream w; std::ostringstream w;
w << (this->Makefile->GetCMakeInstance()->GetPolicies() w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0060) << "\n"
->GetPolicyWarning(cmPolicies::CMP0060)) << "\n"
"Some library files are in directories implicitly searched by " "Some library files are in directories implicitly searched by "
"the linker when invoked for " << this->LinkLanguage << ":\n" "the linker when invoked for " << this->LinkLanguage << ":\n"
" " << cmJoin(this->CMP0060WarnItems, "\n ") << "\n" " " << cmJoin(this->CMP0060WarnItems, "\n ") << "\n"
@ -1534,8 +1533,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item,
{ {
this->CMakeInstance->GetState()->SetGlobalProperty(wid, "1"); this->CMakeInstance->GetState()->SetGlobalProperty(wid, "1");
std::ostringstream w; std::ostringstream w;
w << (this->Makefile->GetPolicies() w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0008) << "\n"
->GetPolicyWarning(cmPolicies::CMP0008)) << "\n"
<< "Target \"" << this->Target->GetName() << "\" links to item\n" << "Target \"" << this->Target->GetName() << "\" links to item\n"
<< " " << item << "\n" << " " << item << "\n"
<< "which is a full-path but not a valid library file name."; << "which is a full-path but not a valid library file name.";
@ -1553,8 +1551,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item,
case cmPolicies::REQUIRED_ALWAYS: case cmPolicies::REQUIRED_ALWAYS:
{ {
std::ostringstream e; std::ostringstream e;
e << (this->Makefile->GetPolicies()-> e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0008) << "\n"
GetRequiredPolicyError(cmPolicies::CMP0008)) << "\n"
<< "Target \"" << this->Target->GetName() << "\" links to item\n" << "Target \"" << this->Target->GetName() << "\" links to item\n"
<< " " << item << "\n" << " " << item << "\n"
<< "which is a full-path but not a valid library file name."; << "which is a full-path but not a valid library file name.";
@ -1600,8 +1597,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories()
case cmPolicies::REQUIRED_ALWAYS: case cmPolicies::REQUIRED_ALWAYS:
{ {
std::ostringstream e; std::ostringstream e;
e << (this->Makefile->GetPolicies()-> e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0003) << "\n";
GetRequiredPolicyError(cmPolicies::CMP0003)) << "\n";
this->PrintLinkPolicyDiagnosis(e); this->PrintLinkPolicyDiagnosis(e);
this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(), this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(),
this->Target->GetBacktrace()); this->Target->GetBacktrace());

View File

@ -361,15 +361,13 @@ void cmComputeTargetDepends::AddTargetDepend(
if(!dependee && !linking && if(!dependee && !linking &&
(depender->GetType() != cmTarget::GLOBAL_TARGET)) (depender->GetType() != cmTarget::GLOBAL_TARGET))
{ {
cmMakefile *makefile = depender->GetMakefile();
cmake::MessageType messageType = cmake::AUTHOR_WARNING; cmake::MessageType messageType = cmake::AUTHOR_WARNING;
bool issueMessage = false; bool issueMessage = false;
std::ostringstream e; std::ostringstream e;
switch(depender->GetPolicyStatusCMP0046()) switch(depender->GetPolicyStatusCMP0046())
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
e << (makefile->GetPolicies() e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0046) << "\n";
->GetPolicyWarning(cmPolicies::CMP0046)) << "\n";
issueMessage = true; issueMessage = true;
case cmPolicies::OLD: case cmPolicies::OLD:
break; break;

View File

@ -118,8 +118,7 @@ const char* cmConditionEvaluator::GetDefinitionIfUnquoted(
if(!hasBeenReported) if(!hasBeenReported)
{ {
std::ostringstream e; std::ostringstream e;
e << (this->Makefile.GetPolicies()->GetPolicyWarning( e << (cmPolicies::GetPolicyWarning(cmPolicies::CMP0054)) << "\n";
cmPolicies::CMP0054)) << "\n";
e << "Quoted variables like \"" << argument.GetValue() << e << "Quoted variables like \"" << argument.GetValue() <<
"\" will no longer be dereferenced " "\" will no longer be dereferenced "
"when the policy is set to NEW. " "when the policy is set to NEW. "
@ -168,8 +167,7 @@ bool cmConditionEvaluator::IsKeyword(std::string const& keyword,
if(!hasBeenReported) if(!hasBeenReported)
{ {
std::ostringstream e; std::ostringstream e;
e << (this->Makefile.GetPolicies()->GetPolicyWarning( e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0054) << "\n";
cmPolicies::CMP0054)) << "\n";
e << "Quoted keywords like \"" << argument.GetValue() << e << "Quoted keywords like \"" << argument.GetValue() <<
"\" will no longer be interpreted as keywords " "\" will no longer be interpreted as keywords "
"when the policy is set to NEW. " "when the policy is set to NEW. "
@ -280,10 +278,9 @@ bool cmConditionEvaluator::GetBooleanValueWithAutoDereference(
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
{ {
cmPolicies* policies = this->Makefile.GetPolicies();
errorString = "An argument named \"" + newArg.GetValue() errorString = "An argument named \"" + newArg.GetValue()
+ "\" appears in a conditional statement. " + "\" appears in a conditional statement. "
+ policies->GetPolicyWarning(cmPolicies::CMP0012); + cmPolicies::GetPolicyWarning(cmPolicies::CMP0012);
status = cmake::AUTHOR_WARNING; status = cmake::AUTHOR_WARNING;
} }
case cmPolicies::OLD: case cmPolicies::OLD:
@ -291,10 +288,9 @@ bool cmConditionEvaluator::GetBooleanValueWithAutoDereference(
case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS: case cmPolicies::REQUIRED_ALWAYS:
{ {
cmPolicies* policies = this->Makefile.GetPolicies();
errorString = "An argument named \"" + newArg.GetValue() errorString = "An argument named \"" + newArg.GetValue()
+ "\" appears in a conditional statement. " + "\" appears in a conditional statement. "
+ policies->GetRequiredPolicyError(cmPolicies::CMP0012); + cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0012);
status = cmake::FATAL_ERROR; status = cmake::FATAL_ERROR;
} }
case cmPolicies::NEW: case cmPolicies::NEW:
@ -493,8 +489,7 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList &newArgs,
{ {
cmPolicies::PolicyID pid; cmPolicies::PolicyID pid;
this->HandlePredicate( this->HandlePredicate(
this->Makefile.GetPolicies()->GetPolicyID( cmPolicies::GetPolicyID(argP1->c_str(), pid),
argP1->c_str(), pid),
reducible, arg, newArgs, argP1, argP2); reducible, arg, newArgs, argP1, argP2);
} }
// does a target exist // does a target exist
@ -702,8 +697,7 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList &newArgs,
else if(this->Policy57Status == cmPolicies::WARN) else if(this->Policy57Status == cmPolicies::WARN)
{ {
std::ostringstream e; std::ostringstream e;
e << (this->Makefile.GetPolicies()->GetPolicyWarning( e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0057) << "\n";
cmPolicies::CMP0057)) << "\n";
e << "IN_LIST will be interpreted as an operator " e << "IN_LIST will be interpreted as an operator "
"when the policy is set to NEW. " "when the policy is set to NEW. "
"Since the policy is not set the OLD behavior will be used."; "Since the policy is not set the OLD behavior will be used.";

View File

@ -334,8 +334,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
"CMAKE_POLICY_WARNING_CMP0056")) "CMAKE_POLICY_WARNING_CMP0056"))
{ {
std::ostringstream w; std::ostringstream w;
w << (this->Makefile->GetCMakeInstance()->GetPolicies() w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0056) << "\n"
->GetPolicyWarning(cmPolicies::CMP0056)) << "\n"
"For compatibility with older versions of CMake, try_compile " "For compatibility with older versions of CMake, try_compile "
"is not honoring caller link flags (e.g. CMAKE_EXE_LINKER_FLAGS) " "is not honoring caller link flags (e.g. CMAKE_EXE_LINKER_FLAGS) "
"in the test project." "in the test project."
@ -349,8 +348,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
case cmPolicies::REQUIRED_ALWAYS: case cmPolicies::REQUIRED_ALWAYS:
this->Makefile->IssueMessage( this->Makefile->IssueMessage(
cmake::FATAL_ERROR, cmake::FATAL_ERROR,
this->Makefile->GetCMakeInstance()->GetPolicies() cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0056)
->GetRequiredPolicyError(cmPolicies::CMP0056)
); );
case cmPolicies::NEW: case cmPolicies::NEW:
// NEW behavior is to pass linker flags. // NEW behavior is to pass linker flags.

View File

@ -257,8 +257,7 @@ static bool checkInterfaceDirs(const std::string &prepro,
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
messageType = cmake::WARNING; messageType = cmake::WARNING;
e << target->GetMakefile()->GetPolicies() e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0041) << "\n";
->GetPolicyWarning(cmPolicies::CMP0041) << "\n";
break; break;
case cmPolicies::OLD: case cmPolicies::OLD:
continue; continue;
@ -306,8 +305,7 @@ static bool checkInterfaceDirs(const std::string &prepro,
case cmPolicies::WARN: case cmPolicies::WARN:
{ {
std::ostringstream s; std::ostringstream s;
s << target->GetMakefile()->GetPolicies() s << cmPolicies::GetPolicyWarning(cmPolicies::CMP0052) << "\n";
->GetPolicyWarning(cmPolicies::CMP0052) << "\n";
s << "Directory:\n \"" << *li << "\"\nin " s << "Directory:\n \"" << *li << "\"\nin "
"INTERFACE_INCLUDE_DIRECTORIES of target \"" "INTERFACE_INCLUDE_DIRECTORIES of target \""
<< target->GetName() << "\" is a subdirectory of the install " << target->GetName() << "\" is a subdirectory of the install "

View File

@ -1056,16 +1056,14 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
if(g.GetFollowedSymlinkCount() != 0) if(g.GetFollowedSymlinkCount() != 0)
{ {
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, this->Makefile->IssueMessage(cmake::AUTHOR_WARNING,
this->Makefile->GetPolicies()-> cmPolicies::GetPolicyWarning(cmPolicies::CMP0009));
GetPolicyWarning(cmPolicies::CMP0009));
} }
break; break;
case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS: case cmPolicies::REQUIRED_ALWAYS:
this->SetError("policy CMP0009 error"); this->SetError("policy CMP0009 error");
this->Makefile->IssueMessage(cmake::FATAL_ERROR, this->Makefile->IssueMessage(cmake::FATAL_ERROR,
this->Makefile->GetPolicies()-> cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0009));
GetRequiredPolicyError(cmPolicies::CMP0009));
return false; return false;
} }
} }

View File

@ -395,8 +395,7 @@ struct CompilerIdNode : public cmGeneratorExpressionNode
case cmPolicies::WARN: case cmPolicies::WARN:
{ {
std::ostringstream e; std::ostringstream e;
e << context->Makefile->GetPolicies() e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0044);
->GetPolicyWarning(cmPolicies::CMP0044);
context->Makefile->GetCMakeInstance() context->Makefile->GetCMakeInstance()
->IssueMessage(cmake::AUTHOR_WARNING, ->IssueMessage(cmake::AUTHOR_WARNING,
e.str(), context->Backtrace); e.str(), context->Backtrace);
@ -1495,8 +1494,7 @@ static const struct TargetPolicyNode : public cmGeneratorExpressionNode
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
mf->IssueMessage(cmake::AUTHOR_WARNING, mf->IssueMessage(cmake::AUTHOR_WARNING,
mf->GetPolicies()-> cmPolicies::GetPolicyWarning(policyForString(policy)));
GetPolicyWarning(policyForString(policy)));
case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS: case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::OLD: case cmPolicies::OLD:

View File

@ -56,8 +56,7 @@ bool cmGetTargetPropertyCommand
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
issueMessage = true; issueMessage = true;
e << this->Makefile->GetPolicies() e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0045) << "\n";
->GetPolicyWarning(cmPolicies::CMP0045) << "\n";
case cmPolicies::OLD: case cmPolicies::OLD:
break; break;
case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_IF_USED:

View File

@ -826,7 +826,6 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf,
if(strcmp(compilerId, "AppleClang") == 0) if(strcmp(compilerId, "AppleClang") == 0)
{ {
cmPolicies* policies = this->CMakeInstance->GetPolicies();
switch(mf->GetPolicyStatus(cmPolicies::CMP0025)) switch(mf->GetPolicyStatus(cmPolicies::CMP0025))
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
@ -834,7 +833,7 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf,
mf->PolicyOptionalWarningEnabled("CMAKE_POLICY_WARNING_CMP0025")) mf->PolicyOptionalWarningEnabled("CMAKE_POLICY_WARNING_CMP0025"))
{ {
std::ostringstream w; std::ostringstream w;
w << policies->GetPolicyWarning(cmPolicies::CMP0025) << "\n" w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0025) << "\n"
"Converting " << lang << "Converting " << lang <<
" compiler id \"AppleClang\" to \"Clang\" for compatibility." " compiler id \"AppleClang\" to \"Clang\" for compatibility."
; ;
@ -848,7 +847,7 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf,
case cmPolicies::REQUIRED_ALWAYS: case cmPolicies::REQUIRED_ALWAYS:
mf->IssueMessage( mf->IssueMessage(
cmake::FATAL_ERROR, cmake::FATAL_ERROR,
policies->GetRequiredPolicyError(cmPolicies::CMP0025) cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0025)
); );
case cmPolicies::NEW: case cmPolicies::NEW:
// NEW behavior is to keep AppleClang. // NEW behavior is to keep AppleClang.
@ -858,7 +857,6 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf,
if(strcmp(compilerId, "QCC") == 0) if(strcmp(compilerId, "QCC") == 0)
{ {
cmPolicies* policies = this->CMakeInstance->GetPolicies();
switch(mf->GetPolicyStatus(cmPolicies::CMP0047)) switch(mf->GetPolicyStatus(cmPolicies::CMP0047))
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
@ -866,7 +864,7 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf,
mf->PolicyOptionalWarningEnabled("CMAKE_POLICY_WARNING_CMP0047")) mf->PolicyOptionalWarningEnabled("CMAKE_POLICY_WARNING_CMP0047"))
{ {
std::ostringstream w; std::ostringstream w;
w << policies->GetPolicyWarning(cmPolicies::CMP0047) << "\n" w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0047) << "\n"
"Converting " << lang << "Converting " << lang <<
" compiler id \"QCC\" to \"GNU\" for compatibility." " compiler id \"QCC\" to \"GNU\" for compatibility."
; ;
@ -888,7 +886,7 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf,
case cmPolicies::REQUIRED_ALWAYS: case cmPolicies::REQUIRED_ALWAYS:
mf->IssueMessage( mf->IssueMessage(
cmake::FATAL_ERROR, cmake::FATAL_ERROR,
policies->GetRequiredPolicyError(cmPolicies::CMP0047) cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0047)
); );
case cmPolicies::NEW: case cmPolicies::NEW:
// NEW behavior is to keep QCC. // NEW behavior is to keep QCC.
@ -1327,9 +1325,7 @@ void cmGlobalGenerator::Generate()
if(!this->CMP0042WarnTargets.empty()) if(!this->CMP0042WarnTargets.empty())
{ {
std::ostringstream w; std::ostringstream w;
w << w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0042) << "\n";
(this->GetCMakeInstance()->GetPolicies()->
GetPolicyWarning(cmPolicies::CMP0042)) << "\n";
w << "MACOSX_RPATH is not specified for" w << "MACOSX_RPATH is not specified for"
" the following targets:\n"; " the following targets:\n";
for(std::set<std::string>::iterator for(std::set<std::string>::iterator

View File

@ -1103,9 +1103,7 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os)
if (!warnExplicitDepends.empty()) if (!warnExplicitDepends.empty())
{ {
std::ostringstream w; std::ostringstream w;
w << w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0058) << "\n"
(this->GetCMakeInstance()->GetPolicies()->
GetPolicyWarning(cmPolicies::CMP0058)) << "\n"
"This project specifies custom command DEPENDS on files " "This project specifies custom command DEPENDS on files "
"in the build tree that are not specified as the OUTPUT or " "in the build tree that are not specified as the OUTPUT or "
"BYPRODUCTS of any add_custom_command or add_custom_target:\n" "BYPRODUCTS of any add_custom_command or add_custom_target:\n"

View File

@ -104,8 +104,7 @@ bool cmIncludeCommand
switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0024)) switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0024))
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
e << (this->Makefile->GetPolicies() e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0024) << "\n";
->GetPolicyWarning(cmPolicies::CMP0024)) << "\n";
modal = "should"; modal = "should";
case cmPolicies::OLD: case cmPolicies::OLD:
break; break;

View File

@ -1404,7 +1404,7 @@ bool cmInstallCommand::CheckCMP0006(bool& failure)
{ {
this->Makefile->IssueMessage( this->Makefile->IssueMessage(
cmake::AUTHOR_WARNING, cmake::AUTHOR_WARNING,
this->Makefile->GetPolicies()->GetPolicyWarning(cmPolicies::CMP0006) cmPolicies::GetPolicyWarning(cmPolicies::CMP0006)
); );
} }
case cmPolicies::OLD: case cmPolicies::OLD:
@ -1418,8 +1418,7 @@ bool cmInstallCommand::CheckCMP0006(bool& failure)
failure = true; failure = true;
this->Makefile->IssueMessage( this->Makefile->IssueMessage(
cmake::FATAL_ERROR, cmake::FATAL_ERROR,
this->Makefile->GetPolicies() cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0006)
->GetRequiredPolicyError(cmPolicies::CMP0006)
); );
break; break;
} }

View File

@ -40,18 +40,17 @@ void cmLinkDirectoriesCommand::AddLinkDir(std::string const& dir)
e << "This command specifies the relative path\n" e << "This command specifies the relative path\n"
<< " " << unixPath << "\n" << " " << unixPath << "\n"
<< "as a link directory.\n"; << "as a link directory.\n";
cmPolicies* policies = this->Makefile->GetPolicies();
switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0015)) switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0015))
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
e << policies->GetPolicyWarning(cmPolicies::CMP0015); e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0015);
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, e.str()); this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, e.str());
case cmPolicies::OLD: case cmPolicies::OLD:
// OLD behavior does not convert // OLD behavior does not convert
break; break;
case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS: case cmPolicies::REQUIRED_ALWAYS:
e << policies->GetRequiredPolicyError(cmPolicies::CMP0015); e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0015);
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
case cmPolicies::NEW: case cmPolicies::NEW:
// NEW behavior converts // NEW behavior converts

View File

@ -121,8 +121,7 @@ bool cmListCommand::GetList(std::vector<std::string>& list,
// empty values // empty values
list.clear(); list.clear();
cmSystemTools::ExpandListArgument(listString, list); cmSystemTools::ExpandListArgument(listString, list);
std::string warn = this->Makefile->GetPolicies()-> std::string warn = cmPolicies::GetPolicyWarning(cmPolicies::CMP0007);
GetPolicyWarning(cmPolicies::CMP0007);
warn += " List has value = ["; warn += " List has value = [";
warn += listString; warn += listString;
warn += "]."; warn += "].";
@ -143,8 +142,7 @@ bool cmListCommand::GetList(std::vector<std::string>& list,
case cmPolicies::REQUIRED_ALWAYS: case cmPolicies::REQUIRED_ALWAYS:
this->Makefile->IssueMessage( this->Makefile->IssueMessage(
cmake::FATAL_ERROR, cmake::FATAL_ERROR,
this->Makefile->GetPolicies() cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0007)
->GetRequiredPolicyError(cmPolicies::CMP0007)
); );
return false; return false;
} }

View File

@ -209,7 +209,7 @@ void cmLocalGenerator::ReadInputFile()
<< "to work accidentally and is being allowed for " << "to work accidentally and is being allowed for "
<< "compatibility." << "compatibility."
<< "\n" << "\n"
<< mf->GetPolicies()->GetPolicyWarning(cmPolicies::CMP0014); << cmPolicies::GetPolicyWarning(cmPolicies::CMP0014);
mf->IssueMessage(cmake::AUTHOR_WARNING, e.str()); mf->IssueMessage(cmake::AUTHOR_WARNING, e.str());
case cmPolicies::OLD: case cmPolicies::OLD:
// OLD behavior does not warn. // OLD behavior does not warn.
@ -217,7 +217,7 @@ void cmLocalGenerator::ReadInputFile()
case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS: case cmPolicies::REQUIRED_ALWAYS:
e << "\n" e << "\n"
<< mf->GetPolicies()->GetRequiredPolicyError(cmPolicies::CMP0014); << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0014);
case cmPolicies::NEW: case cmPolicies::NEW:
// NEW behavior prints the error. // NEW behavior prints the error.
mf->IssueMessage(cmake::FATAL_ERROR, e.str()); mf->IssueMessage(cmake::FATAL_ERROR, e.str());
@ -2458,8 +2458,7 @@ bool cmLocalGenerator::GetShouldUseOldFlags(bool shared,
"shared libraries and will use the " << flagsVar << " variable " "shared libraries and will use the " << flagsVar << " variable "
"instead. This may cause errors if the original content of " "instead. This may cause errors if the original content of "
<< flagsVar << " was removed.\n" << flagsVar << " was removed.\n"
<< this->Makefile->GetPolicies()->GetPolicyWarning( << cmPolicies::GetPolicyWarning(cmPolicies::CMP0018);
cmPolicies::CMP0018);
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, e.str()); this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, e.str());
// fall through to OLD behaviour // fall through to OLD behaviour

View File

@ -591,14 +591,13 @@ void cmMakefile::IncludeScope::EnforceCMP0011()
{ {
// We check the setting of this policy again because the included // We check the setting of this policy again because the included
// script might actually set this policy for its includer. // script might actually set this policy for its includer.
cmPolicies* policies = this->Makefile->GetPolicies();
switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0011)) switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0011))
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
// Warn because the user did not set this policy. // Warn because the user did not set this policy.
{ {
std::ostringstream w; std::ostringstream w;
w << policies->GetPolicyWarning(cmPolicies::CMP0011) << "\n" w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0011) << "\n"
<< "The included script\n " << this->File << "\n" << "The included script\n " << this->File << "\n"
<< "affects policy settings. " << "affects policy settings. "
<< "CMake is implying the NO_POLICY_SCOPE option for compatibility, " << "CMake is implying the NO_POLICY_SCOPE option for compatibility, "
@ -610,7 +609,7 @@ void cmMakefile::IncludeScope::EnforceCMP0011()
case cmPolicies::REQUIRED_ALWAYS: case cmPolicies::REQUIRED_ALWAYS:
{ {
std::ostringstream e; std::ostringstream e;
e << policies->GetRequiredPolicyError(cmPolicies::CMP0011) << "\n" e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0011) << "\n"
<< "The included script\n " << this->File << "\n" << "The included script\n " << this->File << "\n"
<< "affects policy settings, so it requires this policy to be set."; << "affects policy settings, so it requires this policy to be set.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
@ -879,8 +878,7 @@ cmMakefile::AddCustomCommandToTarget(const std::string& target,
switch(this->GetPolicyStatus(cmPolicies::CMP0040)) switch(this->GetPolicyStatus(cmPolicies::CMP0040))
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
e << (this->GetPolicies() e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0040) << "\n";
->GetPolicyWarning(cmPolicies::CMP0040)) << "\n";
issueMessage = true; issueMessage = true;
case cmPolicies::OLD: case cmPolicies::OLD:
break; break;
@ -1438,7 +1436,7 @@ bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove)
case cmPolicies::WARN: case cmPolicies::WARN:
this->IssueMessage( this->IssueMessage(
cmake::AUTHOR_WARNING, cmake::AUTHOR_WARNING,
this->GetPolicies()->GetPolicyWarning(cmPolicies::CMP0005) cmPolicies::GetPolicyWarning(cmPolicies::CMP0005)
); );
case cmPolicies::OLD: case cmPolicies::OLD:
// OLD behavior is to not escape the value. We should not // OLD behavior is to not escape the value. We should not
@ -1448,7 +1446,7 @@ bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove)
case cmPolicies::REQUIRED_ALWAYS: case cmPolicies::REQUIRED_ALWAYS:
this->IssueMessage( this->IssueMessage(
cmake::FATAL_ERROR, cmake::FATAL_ERROR,
this->GetPolicies()->GetRequiredPolicyError(cmPolicies::CMP0005) cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0005)
); );
return false; return false;
case cmPolicies::NEW: case cmPolicies::NEW:
@ -2335,7 +2333,7 @@ void cmMakefile::ExpandVariablesCMP0019()
if(!w.str().empty()) if(!w.str().empty())
{ {
std::ostringstream m; std::ostringstream m;
m << this->GetPolicies()->GetPolicyWarning(cmPolicies::CMP0019) m << cmPolicies::GetPolicyWarning(cmPolicies::CMP0019)
<< "\n" << "\n"
<< "The following variable evaluations were encountered:\n" << "The following variable evaluations were encountered:\n"
<< w.str(); << w.str();
@ -2593,7 +2591,7 @@ const char *cmMakefile::ExpandVariablesInString(std::string& source,
else if(compareResults && (newResult != source || newError != mtype)) else if(compareResults && (newResult != source || newError != mtype))
{ {
std::string msg = std::string msg =
this->GetPolicies()->GetPolicyWarning(cmPolicies::CMP0053); cmPolicies::GetPolicyWarning(cmPolicies::CMP0053);
msg += "\n"; msg += "\n";
std::string msg_input = original; std::string msg_input = original;
@ -2745,9 +2743,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringOld(
switch(this->GetPolicyStatus(cmPolicies::CMP0010)) switch(this->GetPolicyStatus(cmPolicies::CMP0010))
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
error << "\n" error << "\n" << cmPolicies::GetPolicyWarning(cmPolicies::CMP0010);
<< (this->GetPolicies()
->GetPolicyWarning(cmPolicies::CMP0010));
case cmPolicies::OLD: case cmPolicies::OLD:
// OLD behavior is to just warn and continue. // OLD behavior is to just warn and continue.
mtype = cmake::AUTHOR_WARNING; mtype = cmake::AUTHOR_WARNING;
@ -2755,8 +2751,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringOld(
case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS: case cmPolicies::REQUIRED_ALWAYS:
error << "\n" error << "\n"
<< (this->GetPolicies() << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0010);
->GetRequiredPolicyError(cmPolicies::CMP0010));
case cmPolicies::NEW: case cmPolicies::NEW:
// NEW behavior is to report the error. // NEW behavior is to report the error.
break; break;
@ -3820,7 +3815,7 @@ std::string cmMakefile::GetModulesFile(const char* filename) const
<< moduleInCMakeModulePath << moduleInCMakeModulePath
<< " (found via CMAKE_MODULE_PATH) which shadows " << " (found via CMAKE_MODULE_PATH) which shadows "
<< moduleInCMakeRoot << ". This may cause errors later on .\n" << moduleInCMakeRoot << ". This may cause errors later on .\n"
<< this->GetPolicies()->GetPolicyWarning(cmPolicies::CMP0017); << cmPolicies::GetPolicyWarning(cmPolicies::CMP0017);
this->IssueMessage(cmake::AUTHOR_WARNING, e.str()); this->IssueMessage(cmake::AUTHOR_WARNING, e.str());
// break; // fall through to OLD behaviour // break; // fall through to OLD behaviour
@ -4188,7 +4183,7 @@ const char *cmMakefile::GetProperty(const std::string& prop,
switch(this->GetPolicyStatus(cmPolicies::CMP0059)) switch(this->GetPolicyStatus(cmPolicies::CMP0059))
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
this->IssueMessage(cmake::AUTHOR_WARNING, this->GetPolicies()-> this->IssueMessage(cmake::AUTHOR_WARNING, cmPolicies::
GetPolicyWarning(cmPolicies::CMP0059)); GetPolicyWarning(cmPolicies::CMP0059));
case cmPolicies::OLD: case cmPolicies::OLD:
output += this->DefineFlagsOrig; output += this->DefineFlagsOrig;
@ -4558,14 +4553,14 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
switch (this->GetPolicyStatus(cmPolicies::CMP0002)) switch (this->GetPolicyStatus(cmPolicies::CMP0002))
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
this->IssueMessage(cmake::AUTHOR_WARNING, this->GetPolicies()-> this->IssueMessage(cmake::AUTHOR_WARNING, cmPolicies::
GetPolicyWarning(cmPolicies::CMP0002)); GetPolicyWarning(cmPolicies::CMP0002));
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->IssueMessage(cmake::FATAL_ERROR, this->IssueMessage(cmake::FATAL_ERROR,
this->GetPolicies()->GetRequiredPolicyError(cmPolicies::CMP0002) cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0002)
); );
return true; return true;
case cmPolicies::NEW: case cmPolicies::NEW:
@ -4637,7 +4632,7 @@ bool cmMakefile::EnforceUniqueDir(const std::string& srcPath,
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
// Print the warning. // Print the warning.
e << this->GetPolicies()->GetPolicyWarning(cmPolicies::CMP0013) e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0013)
<< "\n" << "\n"
<< "The binary directory\n" << "The binary directory\n"
<< " " << binPath << "\n" << " " << binPath << "\n"
@ -4654,7 +4649,7 @@ bool cmMakefile::EnforceUniqueDir(const std::string& srcPath,
return true; return true;
case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS: case cmPolicies::REQUIRED_ALWAYS:
e << this->GetPolicies()->GetRequiredPolicyError(cmPolicies::CMP0013) e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0013)
<< "\n"; << "\n";
case cmPolicies::NEW: case cmPolicies::NEW:
// NEW behavior prints the error. // NEW behavior prints the error.
@ -4757,7 +4752,7 @@ cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) const
{ {
return cur; return cur;
} }
cmPolicies::PolicyStatus def = this->GetPolicies()->GetPolicyStatus(id); cmPolicies::PolicyStatus def = cmPolicies::GetPolicyStatus(id);
if(def == cmPolicies::REQUIRED_ALWAYS || if(def == cmPolicies::REQUIRED_ALWAYS ||
def == cmPolicies::REQUIRED_IF_USED) def == cmPolicies::REQUIRED_IF_USED)
{ {
@ -4792,7 +4787,7 @@ cmMakefile::GetPolicyStatusInternal(cmPolicies::PolicyID id) const
} }
// The policy is not set. Use the default for this CMake version. // The policy is not set. Use the default for this CMake version.
return this->GetPolicies()->GetPolicyStatus(id); return cmPolicies::GetPolicyStatus(id);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -4815,7 +4810,7 @@ bool cmMakefile::SetPolicy(const char *id,
cmPolicies::PolicyStatus status) cmPolicies::PolicyStatus status)
{ {
cmPolicies::PolicyID pid; cmPolicies::PolicyID pid;
if (!this->GetPolicies()->GetPolicyID(id, /* out */ pid)) if (!cmPolicies::GetPolicyID(id, /* out */ pid))
{ {
std::ostringstream e; std::ostringstream e;
e << "Policy \"" << id << "\" is not known to this version of CMake."; e << "Policy \"" << id << "\" is not known to this version of CMake.";
@ -4831,11 +4826,11 @@ bool cmMakefile::SetPolicy(cmPolicies::PolicyID id,
{ {
// A REQUIRED_ALWAYS policy may be set only to NEW. // A REQUIRED_ALWAYS policy may be set only to NEW.
if(status != cmPolicies::NEW && if(status != cmPolicies::NEW &&
this->GetPolicies()->GetPolicyStatus(id) == cmPolicies::GetPolicyStatus(id) ==
cmPolicies::REQUIRED_ALWAYS) cmPolicies::REQUIRED_ALWAYS)
{ {
std::string msg = std::string msg =
this->GetPolicies()->GetRequiredAlwaysPolicyError(id); cmPolicies::GetRequiredAlwaysPolicyError(id);
this->IssueMessage(cmake::FATAL_ERROR, msg); this->IssueMessage(cmake::FATAL_ERROR, msg);
return false; return false;
} }
@ -4937,18 +4932,7 @@ void cmMakefile::PopPolicyBarrier(bool reportError)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmMakefile::SetPolicyVersion(const char *version) bool cmMakefile::SetPolicyVersion(const char *version)
{ {
return this->GetCMakeInstance()->GetPolicies()-> return cmPolicies::ApplyPolicyVersion(this,version);
ApplyPolicyVersion(this,version);
}
//----------------------------------------------------------------------------
cmPolicies *cmMakefile::GetPolicies() const
{
if (!this->GetCMakeInstance())
{
return 0;
}
return this->GetCMakeInstance()->GetPolicies();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -216,8 +216,7 @@ bool cmProjectCommand
if(!vw.empty()) if(!vw.empty())
{ {
std::ostringstream w; std::ostringstream w;
w << (this->Makefile->GetPolicies() w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0048)
->GetPolicyWarning(cmPolicies::CMP0048))
<< "\nThe following variable(s) would be set to empty:" << vw; << "\nThe following variable(s) would be set to empty:" << vw;
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
} }

View File

@ -974,8 +974,7 @@ std::string cmTarget::ProcessSourceItemCMP0049(const std::string& s)
switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0049)) switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0049))
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
e << (this->Makefile->GetPolicies() e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0049) << "\n";
->GetPolicyWarning(cmPolicies::CMP0049)) << "\n";
break; break;
case cmPolicies::OLD: case cmPolicies::OLD:
noMessage = true; noMessage = true;
@ -2008,8 +2007,7 @@ static void processIncludeDirectories(cmTarget const* tgt,
switch(tgt->GetPolicyStatusCMP0027()) switch(tgt->GetPolicyStatusCMP0027())
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
e << (mf->GetPolicies() e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0027) << "\n";
->GetPolicyWarning(cmPolicies::CMP0027)) << "\n";
case cmPolicies::OLD: case cmPolicies::OLD:
messageType = cmake::AUTHOR_WARNING; messageType = cmake::AUTHOR_WARNING;
break; break;
@ -2049,8 +2047,7 @@ static void processIncludeDirectories(cmTarget const* tgt,
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
{ {
e << (mf->GetPolicies() e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0021) << "\n";
->GetPolicyWarning(cmPolicies::CMP0021)) << "\n";
messageType = cmake::AUTHOR_WARNING; messageType = cmake::AUTHOR_WARNING;
} }
break; break;
@ -2398,8 +2395,7 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list,
case cmPolicies::WARN: case cmPolicies::WARN:
{ {
std::ostringstream e; std::ostringstream e;
e << this->Makefile->GetCMakeInstance()->GetPolicies() e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0043);
->GetPolicyWarning(cmPolicies::CMP0043);
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, this->Makefile->IssueMessage(cmake::AUTHOR_WARNING,
e.str()); e.str());
} }
@ -2874,8 +2870,7 @@ bool cmTarget::HandleLocationPropertyPolicy(cmMakefile* context) const
switch (context->GetPolicyStatus(cmPolicies::CMP0026)) switch (context->GetPolicyStatus(cmPolicies::CMP0026))
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
e << (this->Makefile->GetPolicies() e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0026) << "\n";
->GetPolicyWarning(cmPolicies::CMP0026)) << "\n";
modal = "should"; modal = "should";
case cmPolicies::OLD: case cmPolicies::OLD:
break; break;
@ -3138,8 +3133,7 @@ const char *cmTarget::GetProperty(const std::string& prop,
switch(context->GetPolicyStatus(cmPolicies::CMP0051)) switch(context->GetPolicyStatus(cmPolicies::CMP0051))
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
e << (this->Makefile->GetPolicies() e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0051) << "\n";
->GetPolicyWarning(cmPolicies::CMP0051)) << "\n";
noMessage = false; noMessage = false;
case cmPolicies::OLD: case cmPolicies::OLD:
break; break;
@ -3236,8 +3230,7 @@ public:
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
{ {
e << (this->Makefile->GetPolicies() e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0028) << "\n";
->GetPolicyWarning(cmPolicies::CMP0028)) << "\n";
messageType = cmake::AUTHOR_WARNING; messageType = cmake::AUTHOR_WARNING;
} }
break; break;
@ -5993,9 +5986,7 @@ cmTargetInternals::ComputeLinkInterfaceLibraries(
&& strcmp(newExplicitLibraries, explicitLibraries) != 0) && strcmp(newExplicitLibraries, explicitLibraries) != 0)
{ {
std::ostringstream w; std::ostringstream w;
w << w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n"
(thisTarget->Makefile->GetPolicies()
->GetPolicyWarning(cmPolicies::CMP0022)) << "\n"
"Target \"" << thisTarget->GetName() << "\" has an " "Target \"" << thisTarget->GetName() << "\" has an "
"INTERFACE_LINK_LIBRARIES property which differs from its " << "INTERFACE_LINK_LIBRARIES property which differs from its " <<
linkIfaceProp << " properties." linkIfaceProp << " properties."
@ -6064,9 +6055,7 @@ cmTargetInternals::ComputeLinkInterfaceLibraries(
{ newLibraries = "(empty)"; } { newLibraries = "(empty)"; }
std::ostringstream w; std::ostringstream w;
w << w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n"
(thisTarget->Makefile->GetPolicies()
->GetPolicyWarning(cmPolicies::CMP0022)) << "\n"
"Target \"" << thisTarget->GetName() << "\" has an " "Target \"" << thisTarget->GetName() << "\" has an "
"INTERFACE_LINK_LIBRARIES property. " "INTERFACE_LINK_LIBRARIES property. "
"This should be preferred as the source of the link interface " "This should be preferred as the source of the link interface "
@ -6323,8 +6312,7 @@ cmTargetInternals::ComputeLinkImplementationLibraries(
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
{ {
e << (thisTarget->Makefile->GetPolicies() e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0038) << "\n";
->GetPolicyWarning(cmPolicies::CMP0038)) << "\n";
messageType = cmake::AUTHOR_WARNING; messageType = cmake::AUTHOR_WARNING;
} }
break; break;
@ -6461,8 +6449,7 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const
case cmPolicies::WARN: case cmPolicies::WARN:
{ {
std::ostringstream w; std::ostringstream w;
w << (this->Makefile->GetPolicies() w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0004) << "\n"
->GetPolicyWarning(cmPolicies::CMP0004)) << "\n"
<< "Target \"" << this->GetName() << "\" links to item \"" << "Target \"" << this->GetName() << "\" links to item \""
<< item << "\" which has leading or trailing whitespace."; << item << "\" which has leading or trailing whitespace.";
cm->IssueMessage(cmake::AUTHOR_WARNING, w.str(), cm->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
@ -6483,8 +6470,7 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const
case cmPolicies::REQUIRED_ALWAYS: case cmPolicies::REQUIRED_ALWAYS:
{ {
std::ostringstream e; std::ostringstream e;
e << (this->Makefile->GetPolicies() e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0004) << "\n"
->GetRequiredPolicyError(cmPolicies::CMP0004)) << "\n"
<< "Target \"" << this->GetName() << "\" links to item \"" << "Target \"" << this->GetName() << "\" links to item \""
<< item << "\" which has leading or trailing whitespace."; << item << "\" which has leading or trailing whitespace.";
cm->IssueMessage(cmake::FATAL_ERROR, e.str(), this->GetBacktrace()); cm->IssueMessage(cmake::FATAL_ERROR, e.str(), this->GetBacktrace());

View File

@ -58,16 +58,14 @@ bool cmTargetLinkLibrariesCommand
e << "\n" e << "\n"
<< "CMake does not support this but it used to work accidentally " << "CMake does not support this but it used to work accidentally "
<< "and is being allowed for compatibility." << "and is being allowed for compatibility."
<< "\n" << this->Makefile->GetPolicies()-> << "\n" << cmPolicies::GetPolicyWarning(cmPolicies::CMP0016);
GetPolicyWarning(cmPolicies::CMP0016);
break; break;
case cmPolicies::OLD: // OLD behavior does not warn. case cmPolicies::OLD: // OLD behavior does not warn.
t = cmake::MESSAGE; t = cmake::MESSAGE;
break; break;
case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS: case cmPolicies::REQUIRED_ALWAYS:
e << "\n" << this->Makefile->GetPolicies()-> e << "\n" << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0016);
GetRequiredPolicyError(cmPolicies::CMP0016);
break; break;
case cmPolicies::NEW: // NEW behavior prints the error. case cmPolicies::NEW: // NEW behavior prints the error.
break; break;
@ -108,8 +106,7 @@ bool cmTargetLinkLibrariesCommand
switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0039)) switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0039))
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
e << this->Makefile->GetPolicies() e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0039) << "\n";
->GetPolicyWarning(cmPolicies::CMP0039) << "\n";
modal = "should"; modal = "should";
case cmPolicies::OLD: case cmPolicies::OLD:
break; break;
@ -379,8 +376,7 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib,
switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0023)) switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0023))
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
e << this->Makefile->GetPolicies() e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0023) << "\n";
->GetPolicyWarning(cmPolicies::CMP0023) << "\n";
modal = "should"; modal = "should";
case cmPolicies::OLD: case cmPolicies::OLD:
break; break;