Merge topic 'refactor-cmPolicies'

013ada80 cmPolicies: Implement PolicyMap in terms of bitset.
be6664c2 cmPolicies: Implement abstraction for PolicyMap.
de211686 Port to static cmPolicies API.
13981f20 cmPolicies: Make all API static.
23e2bcc8 cmPolicies: Remove unused DefinePolicy method.
5641ba4f cmPolicies: Remove unused cmPolicy class.
3de54497 cmPolicies: Loop over all policies using enum constants.
387aff20 cmPolicies: Trivialize GetPolicyStatus method.
dbf680d6 cmPolicies: Use more-direct ID access.
8c204133 cmPolicies: Implement in terms of public API.
e3a8c029 cmPolicies: Make private method file-static.
cb765af0 cmPolicies: Implement short description access with XMacros.
5df267fa cmPolicies: Implement version check with XMacro.
2235cfeb cmPolicies: Implement id to version with XMacro.
05d84388 cmPolicies: Implement id to string conversion with XMacro.
6eaade8a cmPolicies: Introduce XMacro table for policy data.
...
This commit is contained in:
Brad King 2015-05-05 09:35:30 -04:00 committed by CMake Topic Stage
commit 2c5a1bff23
28 changed files with 538 additions and 806 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

@ -359,15 +359,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);
@ -1494,8 +1493,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

@ -103,8 +103,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

@ -1402,7 +1402,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:
@ -1416,8 +1416,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

@ -560,7 +560,7 @@ cmMakefile::IncludeScope::~IncludeScope()
// one we pushed above. If the entry is empty, then the included // one we pushed above. If the entry is empty, then the included
// script did not set any policies that might affect the includer so // script did not set any policies that might affect the includer so
// we do not need to enforce the policy. // we do not need to enforce the policy.
if(this->CheckCMP0011 && this->Makefile->PolicyStack.back().empty()) if(this->CheckCMP0011 && this->Makefile->PolicyStack.back().IsEmpty())
{ {
this->CheckCMP0011 = false; this->CheckCMP0011 = false;
} }
@ -582,14 +582,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, "
@ -601,7 +600,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());
@ -870,8 +869,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;
@ -1428,7 +1426,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
@ -1438,7 +1436,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:
@ -2323,7 +2321,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();
@ -2581,7 +2579,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;
@ -2733,9 +2731,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;
@ -2743,8 +2739,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;
@ -3804,7 +3799,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
@ -4172,7 +4167,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;
@ -4538,14 +4533,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:
@ -4616,7 +4611,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"
@ -4633,7 +4628,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.
@ -4736,7 +4731,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)
{ {
@ -4756,10 +4751,9 @@ cmMakefile::GetPolicyStatusInternal(cmPolicies::PolicyID id) const
for(PolicyStackType::const_reverse_iterator psi = this->PolicyStack.rbegin(); for(PolicyStackType::const_reverse_iterator psi = this->PolicyStack.rbegin();
psi != this->PolicyStack.rend(); ++psi) psi != this->PolicyStack.rend(); ++psi)
{ {
PolicyStackEntry::const_iterator pse = psi->find(id); if(psi->IsDefined(id))
if(pse != psi->end())
{ {
return pse->second; return psi->Get(id);
} }
} }
@ -4771,7 +4765,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);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -4794,7 +4788,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.";
@ -4810,11 +4804,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;
} }
@ -4824,7 +4818,7 @@ bool cmMakefile::SetPolicy(cmPolicies::PolicyID id,
for(PolicyStackType::reverse_iterator psi = this->PolicyStack.rbegin(); for(PolicyStackType::reverse_iterator psi = this->PolicyStack.rbegin();
previous_was_weak && psi != this->PolicyStack.rend(); ++psi) previous_was_weak && psi != this->PolicyStack.rend(); ++psi)
{ {
(*psi)[id] = status; psi->Set(id, status);
previous_was_weak = psi->Weak; previous_was_weak = psi->Weak;
} }
@ -4916,18 +4910,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();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -4955,7 +4938,7 @@ void cmMakefile::RecordPolicies(cmPolicies::PolicyMap& pm)
for(PolicyID pid = cmPolicies::CMP0000; for(PolicyID pid = cmPolicies::CMP0000;
pid != cmPolicies::CMPCOUNT; pid = PolicyID(pid+1)) pid != cmPolicies::CMPCOUNT; pid = PolicyID(pid+1))
{ {
pm[pid] = this->GetPolicyStatus(pid); pm.Set(pid, this->GetPolicyStatus(pid));
} }
} }

View File

@ -1,7 +1,6 @@
#include "cmPolicies.h" #include "cmPolicies.h"
#include "cmake.h" #include "cmake.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmSourceFile.h"
#include "cmVersion.h" #include "cmVersion.h"
#include "cmVersionMacros.h" #include "cmVersionMacros.h"
#include "cmAlgorithms.h" #include "cmAlgorithms.h"
@ -10,421 +9,171 @@
#include <queue> #include <queue>
#include <assert.h> #include <assert.h>
const char* cmPolicies::PolicyStatusNames[] = { static bool stringToId(const char* input, cmPolicies::PolicyID& pid)
"OLD", "WARN", "NEW", "REQUIRED_IF_USED", "REQUIRED_ALWAYS"
};
class cmPolicy
{ {
public: assert(input);
cmPolicy(cmPolicies::PolicyID iD, if (strlen(input) != 7)
const char *idString,
const char *shortDescription,
unsigned int majorVersionIntroduced,
unsigned int minorVersionIntroduced,
unsigned int patchVersionIntroduced,
cmPolicies::PolicyStatus status)
{ {
if (!idString || !shortDescription) return false;
}
if (!cmHasLiteralPrefix(input, "CMP"))
{ {
cmSystemTools::Error("Attempt to define a policy without " return false;
"all parameters being specified!");
return;
} }
this->ID = iD; if (cmHasLiteralSuffix(input, "0000"))
this->IDString = idString; {
this->ShortDescription = shortDescription; pid = cmPolicies::CMP0000;
this->MajorVersionIntroduced = majorVersionIntroduced; return true;
this->MinorVersionIntroduced = minorVersionIntroduced;
this->PatchVersionIntroduced = patchVersionIntroduced;
this->Status = status;
} }
for (int i = 3; i < 7; ++i)
{
if (!isdigit(*(input + i)))
{
return false;
}
}
long id;
if (!cmSystemTools::StringToLong(input + 3, &id))
{
return false;
}
if (id >= cmPolicies::CMPCOUNT)
{
return false;
}
pid = cmPolicies::PolicyID(id);
return true;
}
std::string GetVersionString() #define CM_SELECT_ID_VERSION(F, A1, A2, A3, A4, A5, A6) F(A1, A3, A4, A5)
{ #define CM_FOR_EACH_POLICY_ID_VERSION(POLICY) \
std::ostringstream v; CM_FOR_EACH_POLICY_TABLE(POLICY, CM_SELECT_ID_VERSION)
v << this->MajorVersionIntroduced << "." << this->MinorVersionIntroduced;
if(this->PatchVersionIntroduced > 0)
{
v << "." << this->PatchVersionIntroduced;
}
return v.str();
}
bool IsPolicyNewerThan(unsigned int majorV, #define CM_SELECT_ID_DOC(F, A1, A2, A3, A4, A5, A6) F(A1, A2)
#define CM_FOR_EACH_POLICY_ID_DOC(POLICY) \
CM_FOR_EACH_POLICY_TABLE(POLICY, CM_SELECT_ID_DOC)
static const char* idToString(cmPolicies::PolicyID id)
{
switch(id)
{
#define POLICY_CASE(ID) \
case cmPolicies::ID: \
return #ID;
CM_FOR_EACH_POLICY_ID(POLICY_CASE)
#undef POLICY_CASE
case cmPolicies::CMPCOUNT:
return 0;
}
return 0;
}
static const char* idToVersion(cmPolicies::PolicyID id)
{
switch(id)
{
#define POLICY_CASE(ID, V_MAJOR, V_MINOR, V_PATCH) \
case cmPolicies::ID: \
return #V_MAJOR "." #V_MINOR "." #V_PATCH;
CM_FOR_EACH_POLICY_ID_VERSION(POLICY_CASE)
#undef POLICY_CASE
case cmPolicies::CMPCOUNT:
return 0;
}
return 0;
}
static bool isPolicyNewerThan(cmPolicies::PolicyID id,
unsigned int majorV,
unsigned int minorV, unsigned int minorV,
unsigned int patchV) unsigned int patchV)
{
switch(id)
{ {
if (majorV < this->MajorVersionIntroduced) #define POLICY_CASE(ID, V_MAJOR, V_MINOR, V_PATCH) \
{ case cmPolicies::ID: \
return true; return (majorV < V_MAJOR || \
} (majorV == V_MAJOR && \
if (majorV > this->MajorVersionIntroduced) minorV + 1 < V_MINOR + 1) || \
{ (majorV == V_MAJOR && \
minorV == V_MINOR && \
patchV + 1 < V_PATCH + 1));
CM_FOR_EACH_POLICY_ID_VERSION(POLICY_CASE)
#undef POLICY_CASE
case cmPolicies::CMPCOUNT:
return false; return false;
} }
if (minorV < this->MinorVersionIntroduced) return false;
}
const char* idToShortDescription(cmPolicies::PolicyID id)
{
switch(id)
{ {
return true; #define POLICY_CASE(ID, SHORT_DESCRIPTION) \
case cmPolicies::ID: \
return SHORT_DESCRIPTION;
CM_FOR_EACH_POLICY_ID_DOC(POLICY_CASE)
#undef POLICY_CASE
case cmPolicies::CMPCOUNT:
return 0;
} }
if (minorV > this->MinorVersionIntroduced) return 0;
}
//----------------------------------------------------------------------------
static void DiagnoseAncientPolicies(
std::vector<cmPolicies::PolicyID> const& ancient,
unsigned int majorVer,
unsigned int minorVer,
unsigned int patchVer,
cmMakefile* mf)
{
std::ostringstream e;
e << "The project requests behavior compatible with CMake version \""
<< majorVer << "." << minorVer << "." << patchVer
<< "\", which requires the OLD behavior for some policies:\n";
for(std::vector<cmPolicies::PolicyID>::const_iterator
i = ancient.begin(); i != ancient.end(); ++i)
{ {
e << " " << idToString(*i) << ": " << idToShortDescription(*i) << "\n";
}
e << "However, this version of CMake no longer supports the OLD "
<< "behavior for these policies. "
<< "Please either update your CMakeLists.txt files to conform to "
<< "the new behavior or use an older version of CMake that still "
<< "supports the old behavior.";
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
}
//----------------------------------------------------------------------------
static bool GetPolicyDefault(cmMakefile* mf, std::string const& policy,
cmPolicies::PolicyStatus* defaultSetting)
{
std::string defaultVar = "CMAKE_POLICY_DEFAULT_" + policy;
std::string defaultValue = mf->GetSafeDefinition(defaultVar);
if(defaultValue == "NEW")
{
*defaultSetting = cmPolicies::NEW;
}
else if(defaultValue == "OLD")
{
*defaultSetting = cmPolicies::OLD;
}
else if(defaultValue == "")
{
*defaultSetting = cmPolicies::WARN;
}
else
{
std::ostringstream e;
e << defaultVar << " has value \"" << defaultValue
<< "\" but must be \"OLD\", \"NEW\", or \"\" (empty).";
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
return false; return false;
} }
return (patchV < this->PatchVersionIntroduced);
}
cmPolicies::PolicyID ID; return true;
std::string IDString;
std::string ShortDescription;
unsigned int MajorVersionIntroduced;
unsigned int MinorVersionIntroduced;
unsigned int PatchVersionIntroduced;
cmPolicies::PolicyStatus Status;
};
cmPolicies::cmPolicies()
{
// define all the policies
this->DefinePolicy(
CMP0000, "CMP0000",
"A minimum required CMake version must be specified.",
2,6,0, cmPolicies::WARN
);
this->DefinePolicy(
CMP0001, "CMP0001",
"CMAKE_BACKWARDS_COMPATIBILITY should no longer be used.",
2,6,0, cmPolicies::WARN
);
this->DefinePolicy(
CMP0002, "CMP0002",
"Logical target names must be globally unique.",
2,6,0, cmPolicies::WARN
);
this->DefinePolicy(
CMP0003, "CMP0003",
"Libraries linked via full path no longer produce linker search paths.",
2,6,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0004, "CMP0004",
"Libraries linked may not have leading or trailing whitespace.",
2,6,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0005, "CMP0005",
"Preprocessor definition values are now escaped automatically.",
2,6,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0006, "CMP0006",
"Installing MACOSX_BUNDLE targets requires a BUNDLE DESTINATION.",
2,6,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0007, "CMP0007",
"list command no longer ignores empty elements.",
2,6,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0008, "CMP0008",
"Libraries linked by full-path must have a valid library file name.",
2,6,1, cmPolicies::WARN);
this->DefinePolicy(
CMP0009, "CMP0009",
"FILE GLOB_RECURSE calls should not follow symlinks by default.",
2,6,2, cmPolicies::WARN);
this->DefinePolicy(
CMP0010, "CMP0010",
"Bad variable reference syntax is an error.",
2,6,3, cmPolicies::WARN);
this->DefinePolicy(
CMP0011, "CMP0011",
"Included scripts do automatic cmake_policy PUSH and POP.",
2,6,3, cmPolicies::WARN);
this->DefinePolicy(
CMP0012, "CMP0012",
"if() recognizes numbers and boolean constants.",
2,8,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0013, "CMP0013",
"Duplicate binary directories are not allowed.",
2,8,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0014, "CMP0014",
"Input directories must have CMakeLists.txt.",
2,8,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0015, "CMP0015",
"link_directories() treats paths relative to the source dir.",
2,8,1, cmPolicies::WARN);
this->DefinePolicy(
CMP0016, "CMP0016",
"target_link_libraries() reports error if its only argument "
"is not a target.",
2,8,3, cmPolicies::WARN);
this->DefinePolicy(
CMP0017, "CMP0017",
"Prefer files from the CMake module directory when including from there.",
2,8,4, cmPolicies::WARN);
this->DefinePolicy(
CMP0018, "CMP0018",
"Ignore CMAKE_SHARED_LIBRARY_<Lang>_FLAGS variable.",
2,8,9, cmPolicies::WARN);
this->DefinePolicy(
CMP0019, "CMP0019",
"Do not re-expand variables in include and link information.",
2,8,11, cmPolicies::WARN);
this->DefinePolicy(
CMP0020, "CMP0020",
"Automatically link Qt executables to qtmain target on Windows.",
2,8,11, cmPolicies::WARN);
this->DefinePolicy(
CMP0021, "CMP0021",
"Fatal error on relative paths in INCLUDE_DIRECTORIES target property.",
2,8,12, cmPolicies::WARN);
this->DefinePolicy(
CMP0022, "CMP0022",
"INTERFACE_LINK_LIBRARIES defines the link interface.",
2,8,12, cmPolicies::WARN);
this->DefinePolicy(
CMP0023, "CMP0023",
"Plain and keyword target_link_libraries signatures cannot be mixed.",
2,8,12, cmPolicies::WARN);
this->DefinePolicy(
CMP0024, "CMP0024",
"Disallow include export result.",
3,0,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0025, "CMP0025",
"Compiler id for Apple Clang is now AppleClang.",
3,0,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0026, "CMP0026",
"Disallow use of the LOCATION target property.",
3,0,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0027, "CMP0027",
"Conditionally linked imported targets with missing include directories.",
3,0,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0028, "CMP0028",
"Double colon in target name means ALIAS or IMPORTED target.",
3,0,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0029, "CMP0029",
"The subdir_depends command should not be called.",
3,0,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0030, "CMP0030",
"The use_mangled_mesa command should not be called.",
3,0,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0031, "CMP0031",
"The load_command command should not be called.",
3,0,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0032, "CMP0032",
"The output_required_files command should not be called.",
3,0,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0033, "CMP0033",
"The export_library_dependencies command should not be called.",
3,0,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0034, "CMP0034",
"The utility_source command should not be called.",
3,0,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0035, "CMP0035",
"The variable_requires command should not be called.",
3,0,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0036, "CMP0036",
"The build_name command should not be called.",
3,0,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0037, "CMP0037",
"Target names should not be reserved and should match a validity pattern.",
3,0,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0038, "CMP0038",
"Targets may not link directly to themselves.",
3,0,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0039, "CMP0039",
"Utility targets may not have link dependencies.",
3,0,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0040, "CMP0040",
"The target in the TARGET signature of add_custom_command() must exist.",
3,0,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0041, "CMP0041",
"Error on relative include with generator expression.",
3,0,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0042, "CMP0042",
"MACOSX_RPATH is enabled by default.",
3,0,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0043, "CMP0043",
"Ignore COMPILE_DEFINITIONS_<Config> properties.",
3,0,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0044, "CMP0044",
"Case sensitive <LANG>_COMPILER_ID generator expressions.",
3,0,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0045, "CMP0045",
"Error on non-existent target in get_target_property.",
3,0,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0046, "CMP0046",
"Error on non-existent dependency in add_dependencies.",
3,0,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0047, "CMP0047",
"Use QCC compiler id for the qcc drivers on QNX.",
3,0,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0048, "CMP0048",
"project() command manages VERSION variables.",
3,0,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0049, "CMP0049",
"Do not expand variables in target source entries.",
3,0,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0050, "CMP0050",
"Disallow add_custom_command SOURCE signatures.",
3,0,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0051, "CMP0051",
"List TARGET_OBJECTS in SOURCES target property.",
3,1,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0052, "CMP0052",
"Reject source and build dirs in installed "
"INTERFACE_INCLUDE_DIRECTORIES.",
3,1,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0053, "CMP0053",
"Simplify variable reference and escape sequence evaluation.",
3,1,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0054, "CMP0054",
"Only interpret if() arguments as variables or keywords when unquoted.",
3,1,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0055, "CMP0055",
"Strict checking for break() command.",
3,2,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0056, "CMP0056",
"Honor link flags in try_compile() source-file signature.",
3,2,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0058, "CMP0058",
"Ninja requires custom command byproducts to be explicit.",
3,3,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0059, "CMP0059",
"Do no treat DEFINITIONS as a built-in directory property.",
3,3,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0060, "CMP0060",
"Link libraries by full path even in implicit directories.",
3,3,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0057, "CMP0057",
"Support new IN_LIST if() operator.",
3,3,0, cmPolicies::WARN);
}
cmPolicies::~cmPolicies()
{
cmDeleteAll(this->Policies);
}
void cmPolicies::DefinePolicy(cmPolicies::PolicyID iD,
const char *idString,
const char *shortDescription,
unsigned int majorVersionIntroduced,
unsigned int minorVersionIntroduced,
unsigned int patchVersionIntroduced,
cmPolicies::PolicyStatus status)
{
// a policy must be unique and can only be defined once
if (this->Policies.find(iD) != this->Policies.end())
{
cmSystemTools::Error("Attempt to redefine a CMake policy for policy "
"ID ", this->GetPolicyIDString(iD).c_str());
return;
}
this->Policies[iD] = new cmPolicy(iD, idString,
shortDescription,
majorVersionIntroduced,
minorVersionIntroduced,
patchVersionIntroduced,
status);
this->PolicyStringMap[idString] = iD;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -489,20 +238,20 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf,
// now loop over all the policies and set them as appropriate // now loop over all the policies and set them as appropriate
std::vector<cmPolicies::PolicyID> ancientPolicies; std::vector<cmPolicies::PolicyID> ancientPolicies;
for(std::map<cmPolicies::PolicyID,cmPolicy *>::iterator i for(PolicyID pid = cmPolicies::CMP0000;
= this->Policies.begin(); i != this->Policies.end(); ++i) pid != cmPolicies::CMPCOUNT; pid = PolicyID(pid+1))
{ {
if (i->second->IsPolicyNewerThan(majorVer,minorVer,patchVer)) if (isPolicyNewerThan(pid, majorVer, minorVer, patchVer))
{ {
if(i->second->Status == cmPolicies::REQUIRED_ALWAYS) if(cmPolicies::GetPolicyStatus(pid) == cmPolicies::REQUIRED_ALWAYS)
{ {
ancientPolicies.push_back(i->first); ancientPolicies.push_back(pid);
} }
else else
{ {
cmPolicies::PolicyStatus status = cmPolicies::WARN; cmPolicies::PolicyStatus status = cmPolicies::WARN;
if(!this->GetPolicyDefault(mf, i->second->IDString, &status) || if(!GetPolicyDefault(mf, idToString(pid), &status) ||
!mf->SetPolicy(i->second->ID, status)) !mf->SetPolicy(pid, status))
{ {
return false; return false;
} }
@ -510,7 +259,7 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf,
} }
else else
{ {
if (!mf->SetPolicy(i->second->ID, cmPolicies::NEW)) if (!mf->SetPolicy(pid, cmPolicies::NEW))
{ {
return false; return false;
} }
@ -520,7 +269,7 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf,
// Make sure the project does not use any ancient policies. // Make sure the project does not use any ancient policies.
if(!ancientPolicies.empty()) if(!ancientPolicies.empty())
{ {
this->DiagnoseAncientPolicies(ancientPolicies, DiagnoseAncientPolicies(ancientPolicies,
majorVer, minorVer, patchVer, mf); majorVer, minorVer, patchVer, mf);
cmSystemTools::SetFatalErrorOccured(); cmSystemTools::SetFatalErrorOccured();
return false; return false;
@ -529,81 +278,19 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf,
return true; return true;
} }
//----------------------------------------------------------------------------
bool cmPolicies::GetPolicyDefault(cmMakefile* mf, std::string const& policy,
cmPolicies::PolicyStatus* defaultSetting)
{
std::string defaultVar = "CMAKE_POLICY_DEFAULT_" + policy;
std::string defaultValue = mf->GetSafeDefinition(defaultVar);
if(defaultValue == "NEW")
{
*defaultSetting = cmPolicies::NEW;
}
else if(defaultValue == "OLD")
{
*defaultSetting = cmPolicies::OLD;
}
else if(defaultValue == "")
{
*defaultSetting = cmPolicies::WARN;
}
else
{
std::ostringstream e;
e << defaultVar << " has value \"" << defaultValue
<< "\" but must be \"OLD\", \"NEW\", or \"\" (empty).";
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
return false;
}
return true;
}
bool cmPolicies::GetPolicyID(const char *id, cmPolicies::PolicyID &pid) bool cmPolicies::GetPolicyID(const char *id, cmPolicies::PolicyID &pid)
{ {
if (!id || strlen(id) < 1) return stringToId(id, pid);
{
return false;
}
std::map<std::string,cmPolicies::PolicyID>::iterator pos =
this->PolicyStringMap.find(id);
if (pos == this->PolicyStringMap.end())
{
return false;
}
pid = pos->second;
return true;
} }
std::string cmPolicies::GetPolicyIDString(cmPolicies::PolicyID pid)
{
std::map<cmPolicies::PolicyID,cmPolicy *>::iterator pos =
this->Policies.find(pid);
if (pos == this->Policies.end())
{
return "";
}
return pos->second->IDString;
}
///! return a warning string for a given policy ///! return a warning string for a given policy
std::string cmPolicies::GetPolicyWarning(cmPolicies::PolicyID id) std::string cmPolicies::GetPolicyWarning(cmPolicies::PolicyID id)
{ {
std::map<cmPolicies::PolicyID,cmPolicy *>::iterator pos =
this->Policies.find(id);
if (pos == this->Policies.end())
{
cmSystemTools::Error(
"Request for warning text for undefined policy!");
return "Request for warning text for undefined policy!";
}
std::ostringstream msg; std::ostringstream msg;
msg << msg <<
"Policy " << pos->second->IDString << " is not set: " "Policy " << idToString(id) << " is not set: "
"" << pos->second->ShortDescription << " " "" << idToShortDescription(id) << " "
"Run \"cmake --help-policy " << pos->second->IDString << "\" for " "Run \"cmake --help-policy " << idToString(id) << "\" for "
"policy details. " "policy details. "
"Use the cmake_policy command to set the policy " "Use the cmake_policy command to set the policy "
"and suppress this warning."; "and suppress this warning.";
@ -614,26 +301,17 @@ std::string cmPolicies::GetPolicyWarning(cmPolicies::PolicyID id)
///! return an error string for when a required policy is unspecified ///! return an error string for when a required policy is unspecified
std::string cmPolicies::GetRequiredPolicyError(cmPolicies::PolicyID id) std::string cmPolicies::GetRequiredPolicyError(cmPolicies::PolicyID id)
{ {
std::map<cmPolicies::PolicyID,cmPolicy *>::iterator pos =
this->Policies.find(id);
if (pos == this->Policies.end())
{
cmSystemTools::Error(
"Request for error text for undefined policy!");
return "Request for error text for undefined policy!";
}
std::ostringstream error; std::ostringstream error;
error << error <<
"Policy " << pos->second->IDString << " is not set to NEW: " "Policy " << idToString(id) << " is not set to NEW: "
"" << pos->second->ShortDescription << " " "" << idToShortDescription(id) << " "
"Run \"cmake --help-policy " << pos->second->IDString << "\" for " "Run \"cmake --help-policy " << idToString(id) << "\" for "
"policy details. " "policy details. "
"CMake now requires this policy to be set to NEW by the project. " "CMake now requires this policy to be set to NEW by the project. "
"The policy may be set explicitly using the code\n" "The policy may be set explicitly using the code\n"
" cmake_policy(SET " << pos->second->IDString << " NEW)\n" " cmake_policy(SET " << idToString(id) << " NEW)\n"
"or by upgrading all policies with the code\n" "or by upgrading all policies with the code\n"
" cmake_policy(VERSION " << pos->second->GetVersionString() << " cmake_policy(VERSION " << idToVersion(id) <<
") # or later\n" ") # or later\n"
"Run \"cmake --help-command cmake_policy\" for more information."; "Run \"cmake --help-command cmake_policy\" for more information.";
return error.str(); return error.str();
@ -641,30 +319,21 @@ std::string cmPolicies::GetRequiredPolicyError(cmPolicies::PolicyID id)
///! Get the default status for a policy ///! Get the default status for a policy
cmPolicies::PolicyStatus cmPolicies::PolicyStatus
cmPolicies::GetPolicyStatus(cmPolicies::PolicyID id) cmPolicies::GetPolicyStatus(cmPolicies::PolicyID)
{ {
// if the policy is not know then what?
std::map<cmPolicies::PolicyID,cmPolicy *>::iterator pos =
this->Policies.find(id);
if (pos == this->Policies.end())
{
// TODO is this right?
return cmPolicies::WARN; return cmPolicies::WARN;
}
return pos->second->Status;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string std::string
cmPolicies::GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id) cmPolicies::GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id)
{ {
std::string pid = this->GetPolicyIDString(id); std::string pid = idToString(id);
std::ostringstream e; std::ostringstream e;
e << "Policy " << pid << " may not be set to OLD behavior because this " e << "Policy " << pid << " may not be set to OLD behavior because this "
<< "version of CMake no longer supports it. " << "version of CMake no longer supports it. "
<< "The policy was introduced in " << "The policy was introduced in "
<< "CMake version " << this->Policies[id]->GetVersionString() << "CMake version " << idToVersion(id)
<< ", and use of NEW behavior is now required." << ", and use of NEW behavior is now required."
<< "\n" << "\n"
<< "Please either update your CMakeLists.txt files to conform to " << "Please either update your CMakeLists.txt files to conform to "
@ -674,28 +343,51 @@ cmPolicies::GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id)
return e.str(); return e.str();
} }
//---------------------------------------------------------------------------- cmPolicies::PolicyMap::PolicyMap()
void
cmPolicies::DiagnoseAncientPolicies(std::vector<PolicyID> const& ancient,
unsigned int majorVer,
unsigned int minorVer,
unsigned int patchVer,
cmMakefile* mf)
{ {
std::ostringstream e; this->UNDEFINED.set();
e << "The project requests behavior compatible with CMake version \"" }
<< majorVer << "." << minorVer << "." << patchVer
<< "\", which requires the OLD behavior for some policies:\n"; cmPolicies::PolicyStatus
for(std::vector<PolicyID>::const_iterator cmPolicies::PolicyMap::Get(cmPolicies::PolicyID id) const
i = ancient.begin(); i != ancient.end(); ++i) {
{ PolicyStatus status = cmPolicies::WARN;
cmPolicy const* policy = this->Policies[*i];
e << " " << policy->IDString << ": " << policy->ShortDescription << "\n"; if (this->OLD[id])
} {
e << "However, this version of CMake no longer supports the OLD " status = cmPolicies::OLD;
<< "behavior for these policies. " }
<< "Please either update your CMakeLists.txt files to conform to " else if (this->NEW[id])
<< "the new behavior or use an older version of CMake that still " {
<< "supports the old behavior."; status = cmPolicies::NEW;
mf->IssueMessage(cmake::FATAL_ERROR, e.str()); }
else if (this->REQUIRED_ALWAYS[id])
{
status = cmPolicies::REQUIRED_ALWAYS;
}
else if (this->REQUIRED_IF_USED[id])
{
status = cmPolicies::REQUIRED_IF_USED;
}
return status;
}
void cmPolicies::PolicyMap::Set(cmPolicies::PolicyID id,
cmPolicies::PolicyStatus status)
{
this->UNDEFINED.reset(id);
this->OLD[id] = (status == cmPolicies::OLD);
this->NEW[id] = (status == cmPolicies::NEW);
this->REQUIRED_ALWAYS[id] = (status == cmPolicies::REQUIRED_ALWAYS);
this->REQUIRED_IF_USED[id] = (status == cmPolicies::REQUIRED_IF_USED);
}
bool cmPolicies::PolicyMap::IsDefined(cmPolicies::PolicyID id) const
{
return !this->UNDEFINED[id];
}
bool cmPolicies::PolicyMap::IsEmpty() const
{
return !this->UNDEFINED.none();
} }

View File

@ -14,10 +14,207 @@
#include "cmCustomCommand.h" #include "cmCustomCommand.h"
class cmake; #include <bitset>
class cmMakefile; class cmMakefile;
class cmPolicy; class cmPolicy;
#define CM_FOR_EACH_POLICY_TABLE(POLICY, SELECT) \
SELECT(POLICY, CMP0000, \
"A minimum required CMake version must be specified.", \
2, 6, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0001, \
"CMAKE_BACKWARDS_COMPATIBILITY should no longer be used.", \
2, 6, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0002, \
"Logical target names must be globally unique.", \
2, 6, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0003, \
"Libraries linked via full path no longer produce linker search paths.", \
2, 6, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0004, \
"Libraries linked may not have leading or trailing whitespace.", \
2, 6, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0005, \
"Preprocessor definition values are now escaped automatically.", \
2, 6, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0006, \
"Installing MACOSX_BUNDLE targets requires a BUNDLE DESTINATION.", \
2, 6, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0007, \
"list command no longer ignores empty elements.", \
2, 6, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0008, \
"Libraries linked by full-path must have a valid library file name.", \
2, 6, 1, cmPolicies::WARN) \
SELECT(POLICY, CMP0009, \
"FILE GLOB_RECURSE calls should not follow symlinks by default.", \
2, 6, 2, cmPolicies::WARN) \
SELECT(POLICY, CMP0010, \
"Bad variable reference syntax is an error.", \
2, 6, 3, cmPolicies::WARN) \
SELECT(POLICY, CMP0011, \
"Included scripts do automatic cmake_policy PUSH and POP.", \
2, 6, 3, cmPolicies::WARN) \
SELECT(POLICY, CMP0012, \
"if() recognizes numbers and boolean constants.", \
2, 8, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0013, \
"Duplicate binary directories are not allowed.", \
2, 8, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0014, \
"Input directories must have CMakeLists.txt.", \
2, 8, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0015, \
"link_directories() treats paths relative to the source dir.", \
2, 8, 1, cmPolicies::WARN) \
SELECT(POLICY, CMP0016, \
"target_link_libraries() reports error if its only argument " \
"is not a target.", \
2, 8, 3, cmPolicies::WARN) \
SELECT(POLICY, CMP0017, \
"Prefer files from the CMake module directory when including from " \
"there.", \
2, 8, 4, cmPolicies::WARN) \
SELECT(POLICY, CMP0018, \
"Ignore CMAKE_SHARED_LIBRARY_<Lang>_FLAGS variable.", \
2, 8, 9, cmPolicies::WARN) \
SELECT(POLICY, CMP0019, \
"Do not re-expand variables in include and link information.", \
2, 8, 11, cmPolicies::WARN) \
SELECT(POLICY, CMP0020, \
"Automatically link Qt executables to qtmain target on Windows.", \
2, 8, 11, cmPolicies::WARN) \
SELECT(POLICY, CMP0021, \
"Fatal error on relative paths in INCLUDE_DIRECTORIES target property.", \
2, 8, 12, cmPolicies::WARN) \
SELECT(POLICY, CMP0022, \
"INTERFACE_LINK_LIBRARIES defines the link interface.", \
2, 8, 12, cmPolicies::WARN) \
SELECT(POLICY, CMP0023, \
"Plain and keyword target_link_libraries signatures cannot be mixed.", \
2, 8, 12, cmPolicies::WARN) \
SELECT(POLICY, CMP0024, \
"Disallow include export result.", \
3, 0, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0025, \
"Compiler id for Apple Clang is now AppleClang.", \
3, 0, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0026, \
"Disallow use of the LOCATION target property.", \
3, 0, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0027, \
"Conditionally linked imported targets with missing include " \
"directories.", \
3, 0, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0028, \
"Double colon in target name means ALIAS or IMPORTED target.", \
3, 0, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0029, \
"The subdir_depends command should not be called.", \
3, 0, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0030, \
"The use_mangled_mesa command should not be called.", \
3, 0, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0031, \
"The load_command command should not be called.", \
3, 0, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0032, \
"The output_required_files command should not be called.", \
3, 0, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0033, \
"The export_library_dependencies command should not be called.", \
3, 0, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0034, \
"The utility_source command should not be called.", \
3, 0, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0035, \
"The variable_requires command should not be called.", \
3, 0, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0036, \
"The build_name command should not be called.", \
3, 0, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0037, \
"Target names should not be reserved and should match a validity " \
"pattern.", \
3, 0, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0038, \
"Targets may not link directly to themselves.", \
3, 0, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0039, \
"Utility targets may not have link dependencies.", \
3, 0, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0040, \
"The target in the TARGET signature of add_custom_command() must " \
"exist.", \
3, 0, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0041, \
"Error on relative include with generator expression.", \
3, 0, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0042, \
"MACOSX_RPATH is enabled by default.", \
3, 0, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0043, \
"Ignore COMPILE_DEFINITIONS_<Config> properties.", \
3, 0, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0044, \
"Case sensitive <LANG>_COMPILER_ID generator expressions.", \
3, 0, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0045, \
"Error on non-existent target in get_target_property.", \
3, 0, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0046, \
"Error on non-existent dependency in add_dependencies.", \
3, 0, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0047, \
"Use QCC compiler id for the qcc drivers on QNX.", \
3, 0, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0048, \
"project() command manages VERSION variables.", \
3, 0, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0049, \
"Do not expand variables in target source entries.", \
3, 0, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0050, \
"Disallow add_custom_command SOURCE signatures.", \
3, 0, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0051, \
"List TARGET_OBJECTS in SOURCES target property.", \
3, 1, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0052, \
"Reject source and build dirs in installed " \
"INTERFACE_INCLUDE_DIRECTORIES.", \
3, 1, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0053, \
"Simplify variable reference and escape sequence evaluation.", \
3, 1, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0054, \
"Only interpret if() arguments as variables or keywords when unquoted.", \
3, 1, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0055, \
"Strict checking for break() command.", \
3, 2, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0056, \
"Honor link flags in try_compile() source-file signature.", \
3, 2, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0057, \
"Support new IN_LIST if() operator.", \
3, 3, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0058, \
"Ninja requires custom command byproducts to be explicit.", \
3, 3, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0059, \
"Do no treat DEFINITIONS as a built-in directory property.", \
3, 3, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0060, \
"Link libraries by full path even in implicit directories.", \
3, 3, 0, cmPolicies::WARN)
#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
#define CM_FOR_EACH_POLICY_ID(POLICY) \
CM_FOR_EACH_POLICY_TABLE(POLICY, CM_SELECT_ID)
/** \class cmPolicies /** \class cmPolicies
* \brief Handles changes in CMake behavior and policies * \brief Handles changes in CMake behavior and policies
* *
@ -28,9 +225,6 @@ class cmPolicy;
class cmPolicies class cmPolicies
{ {
public: public:
cmPolicies();
~cmPolicies();
/// Status of a policy /// Status of a policy
enum PolicyStatus { enum PolicyStatus {
OLD, ///< Use old behavior OLD, ///< Use old behavior
@ -41,83 +235,13 @@ public:
REQUIRED_IF_USED, REQUIRED_IF_USED,
REQUIRED_ALWAYS ///< Issue an error unless user sets policy status to NEW. REQUIRED_ALWAYS ///< Issue an error unless user sets policy status to NEW.
}; };
static const char* PolicyStatusNames[];
/// Policy identifiers /// Policy identifiers
enum PolicyID enum PolicyID
{ {
CMP0000, ///< Policy version specification #define POLICY_ENUM(POLICY_ID) POLICY_ID,
CMP0001, ///< Ignore old compatibility variable CM_FOR_EACH_POLICY_ID(POLICY_ENUM)
CMP0002, ///< Target names must be unique #undef POLICY_ENUM
CMP0003, ///< Linking does not include extra -L paths
CMP0004, ///< Libraries linked may not have leading or trailing whitespace
CMP0005, ///< Definition value escaping
CMP0006, ///< BUNDLE install rules needed for MACOSX_BUNDLE targets
CMP0007, ///< list command handling of empty elements
CMP0008, ///< Full-path libraries must be a valid library file name
CMP0009, ///< GLOB_RECURSE should not follow symlinks by default
CMP0010, ///< Bad variable reference syntax is an error
CMP0011, ///< Strong policy scope for include and find_package
CMP0012, ///< Recognize numbers and boolean constants in if()
CMP0013, ///< Duplicate binary directories not allowed
CMP0014, ///< Input directories must have CMakeLists.txt
CMP0015, ///< link_directories() treats paths relative to source dir
/// target_link_libraries() fails if only argument is not a target
CMP0016,
CMP0017, ///< Prefer files in CMAKE_ROOT when including from CMAKE_ROOT
CMP0018, ///< Ignore language flags for shared libs, and adhere to
/// POSITION_INDEPENDENT_CODE property and *_COMPILE_OPTIONS_PI{E,C}
/// instead.
CMP0019, ///< No variable re-expansion in include and link info
CMP0020, ///< Automatically link Qt executables to qtmain target
CMP0021, ///< Fatal error on relative paths in INCLUDE_DIRECTORIES
/// target property
CMP0022, ///< INTERFACE_LINK_LIBRARIES defines the link interface
CMP0023, ///< Disallow mixing keyword and plain tll signatures
CMP0024, ///< Disallow including export() result.
CMP0025, ///< Compiler id for Apple Clang is now AppleClang
CMP0026, ///< Disallow use of the LOCATION target property.
CMP0027, ///< Conditionally linked imported targets with missing include
/// directories.
CMP0028, ///< Double colon in target name means ALIAS or IMPORTED target.
CMP0029, ///< Disallow command: subdir_depends
CMP0030, ///< Disallow command: use_mangled_mesa
CMP0031, ///< Disallow command: load_command
CMP0032, ///< Disallow command: output_required_files
CMP0033, ///< Disallow command: export_library_dependencies
CMP0034, ///< Disallow command: utility_source
CMP0035, ///< Disallow command: variable_requires
CMP0036, ///< Disallow command: build_name
CMP0037, ///< Target names should not be reserved and
/// should match a validity pattern.
CMP0038, ///< Targets may not link directly to themselves
CMP0039, ///< Utility targets may not have link dependencies
CMP0040, ///< The target in the TARGET signature of
/// add_custom_command() must exist.
CMP0041, ///< Error on relative include with generator expression
CMP0042, ///< Enable MACOSX_RPATH by default
CMP0043, ///< Ignore COMPILE_DEFINITIONS_<Config> properties
CMP0044, ///< Case sensitive <LANG>_COMPILER_ID generator expressions
CMP0045, ///< Error on non-existent target in get_target_property
CMP0046, ///< Error on non-existent dependency in add_dependencies
CMP0047, ///< Use QCC compiler id for the qcc drivers on QNX.
CMP0048, ///< project() command manages VERSION variables
CMP0049, ///< Do not expand variables in target source entries
CMP0050, ///< Disallow add_custom_command SOURCE signatures
CMP0051, ///< List TARGET_OBJECTS in SOURCES target property
CMP0052, ///< Reject source and build dirs in installed
/// INTERFACE_INCLUDE_DIRECTORIES
CMP0053, ///< Simplify variable reference and escape sequence evaluation
CMP0054, ///< Only interpret if() arguments as variables
/// or keywords when unquoted.
CMP0055, ///< Strict checking for break() command.
CMP0056, ///< Honor link flags in try_compile() source-file signature.
CMP0058, ///< Ninja requires custom command byproducts to be explicit
CMP0059, ///< Do not treat ``DEFINITIONS`` as a built-in directory
/// property.
CMP0060, ///< Link libraries by full path even in implicit directories.
CMP0057, ///< Support new IN_LIST if() operator.
/** \brief Always the last entry. /** \brief Always the last entry.
* *
@ -128,48 +252,39 @@ public:
}; };
///! convert a string policy ID into a number ///! convert a string policy ID into a number
bool GetPolicyID(const char *id, /* out */ cmPolicies::PolicyID &pid); static bool GetPolicyID(const char *id, /* out */ cmPolicies::PolicyID &pid);
std::string GetPolicyIDString(cmPolicies::PolicyID pid);
///! Get the default status for a policy ///! Get the default status for a policy
cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id); static cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id);
///! Define a Policy for CMake
void DefinePolicy(cmPolicies::PolicyID id,
const char *stringID,
const char *shortDescription,
unsigned int majorVersionIntroduced,
unsigned int minorVersionIntroduced,
unsigned int patchVersionIntroduced,
cmPolicies::PolicyStatus status);
///! Set a policy level for this listfile ///! Set a policy level for this listfile
bool ApplyPolicyVersion(cmMakefile *mf, const char *version); static bool ApplyPolicyVersion(cmMakefile *mf, const char *version);
///! return a warning string for a given policy ///! return a warning string for a given policy
std::string GetPolicyWarning(cmPolicies::PolicyID id); static std::string GetPolicyWarning(cmPolicies::PolicyID id);
///! return an error string for when a required policy is unspecified ///! return an error string for when a required policy is unspecified
std::string GetRequiredPolicyError(cmPolicies::PolicyID id); static std::string GetRequiredPolicyError(cmPolicies::PolicyID id);
///! return an error string for when a required policy is unspecified ///! return an error string for when a required policy is unspecified
std::string GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id); static std::string GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id);
/** Represent a set of policy values. */ /** Represent a set of policy values. */
typedef std::map<PolicyID, PolicyStatus> PolicyMap; struct PolicyMap
{
PolicyMap();
PolicyStatus Get(PolicyID id) const;
void Set(PolicyID id, PolicyStatus status);
bool IsDefined(PolicyID id) const;
bool IsEmpty() const;
private: private:
// might have to make these internal for VS6 not sure yet std::bitset<cmPolicies::CMPCOUNT> UNDEFINED;
std::map<PolicyID,cmPolicy *> Policies; std::bitset<cmPolicies::CMPCOUNT> OLD;
std::map<std::string,PolicyID> PolicyStringMap; std::bitset<cmPolicies::CMPCOUNT> NEW;
std::bitset<cmPolicies::CMPCOUNT> REQUIRED_IF_USED;
void DiagnoseAncientPolicies(std::vector<PolicyID> const& ancient, std::bitset<cmPolicies::CMPCOUNT> REQUIRED_ALWAYS;
unsigned int majorVer, unsigned int minorVer, };
unsigned int patchVer, cmMakefile* mf);
bool GetPolicyDefault(cmMakefile* mf, std::string const& policy,
cmPolicies::PolicyStatus* defaultStatus);
}; };
#endif #endif

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

@ -973,8 +973,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;
@ -2007,8 +2006,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;
@ -2048,8 +2046,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;
@ -2397,8 +2394,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());
} }
@ -2873,8 +2869,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;
@ -3137,8 +3132,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;
@ -3235,8 +3229,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;
@ -5991,9 +5984,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."
@ -6062,9 +6053,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 "
@ -6321,8 +6310,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;
@ -6459,8 +6447,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(),
@ -6481,8 +6468,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;