cmGeneratorTarget: Provide direct access to the backtrace.

This commit is contained in:
Stephen Kelly 2015-10-19 22:39:08 +02:00
parent 1df8bd3ab0
commit 215cd21a02
6 changed files with 29 additions and 22 deletions

View File

@ -571,7 +571,7 @@ bool cmComputeLinkInformation::Compute()
"name." "name."
; ;
this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
this->Target->Target->GetBacktrace()); this->Target->GetBacktrace());
} }
return true; return true;
@ -1548,7 +1548,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item,
<< " " << 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.";
this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
this->Target->Target->GetBacktrace()); this->Target->GetBacktrace());
} }
} }
case cmPolicies::OLD: case cmPolicies::OLD:
@ -1566,7 +1566,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item,
<< " " << 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.";
this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(), this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(),
this->Target->Target->GetBacktrace()); this->Target->GetBacktrace());
} }
break; break;
} }
@ -1594,7 +1594,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories()
std::ostringstream w; std::ostringstream w;
this->PrintLinkPolicyDiagnosis(w); this->PrintLinkPolicyDiagnosis(w);
this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
this->Target->Target->GetBacktrace()); this->Target->GetBacktrace());
} }
case cmPolicies::OLD: case cmPolicies::OLD:
// OLD behavior is to add the paths containing libraries with // OLD behavior is to add the paths containing libraries with
@ -1610,7 +1610,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories()
e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0003) << "\n"; e << cmPolicies::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->Target->GetBacktrace()); this->Target->GetBacktrace());
return false; return false;
} }
} }

View File

@ -245,7 +245,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
->IssueMessage(cmake::FATAL_ERROR, ->IssueMessage(cmake::FATAL_ERROR,
"Only executables and non-OBJECT libraries may " "Only executables and non-OBJECT libraries may "
"reference target objects.", "reference target objects.",
depender->Target->GetBacktrace()); depender->GetBacktrace());
return; return;
} }
const_cast<cmGeneratorTarget*>(depender)->Target->AddUtility(objLib); const_cast<cmGeneratorTarget*>(depender)->Target->AddUtility(objLib);

View File

@ -62,7 +62,7 @@ void reportBadObjLib(std::vector<cmSourceFile*> const& badObjLib,
e << "but may contain only sources that compile, header files, and " e << "but may contain only sources that compile, header files, and "
"other files that would not affect linking of a normal library."; "other files that would not affect linking of a normal library.";
cm->IssueMessage(cmake::FATAL_ERROR, e.str(), cm->IssueMessage(cmake::FATAL_ERROR, e.str(),
target->Target->GetBacktrace()); target->GetBacktrace());
} }
} }
@ -483,7 +483,7 @@ std::string cmGeneratorTarget::GetOutputName(const std::string& config,
->IssueMessage( ->IssueMessage(
cmake::FATAL_ERROR, cmake::FATAL_ERROR,
"Target '" + this->GetName() + "' OUTPUT_NAME depends on itself.", "Target '" + this->GetName() + "' OUTPUT_NAME depends on itself.",
this->Target->GetBacktrace()); this->GetBacktrace());
} }
return i->second; return i->second;
} }
@ -1007,7 +1007,7 @@ static bool processSources(cmGeneratorTarget const* tgt,
{ {
cmake* cm = tgt->GetLocalGenerator()->GetCMakeInstance(); cmake* cm = tgt->GetLocalGenerator()->GetCMakeInstance();
cm->IssueMessage(cmake::FATAL_ERROR, e, cm->IssueMessage(cmake::FATAL_ERROR, e,
tgt->Target->GetBacktrace()); tgt->GetBacktrace());
} }
return contextDependent; return contextDependent;
} }
@ -1471,7 +1471,7 @@ bool cmGeneratorTarget::HasMacOSXRpathInstallNameDir(
w << " corrupt."; w << " corrupt.";
cmake* cm = this->LocalGenerator->GetCMakeInstance(); cmake* cm = this->LocalGenerator->GetCMakeInstance();
cm->IssueMessage(cmake::FATAL_ERROR, w.str(), cm->IssueMessage(cmake::FATAL_ERROR, w.str(),
this->Target->GetBacktrace()); this->GetBacktrace());
} }
return true; return true;
@ -1703,6 +1703,11 @@ std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const
} }
} }
cmListFileBacktrace cmGeneratorTarget::GetBacktrace() const
{
return this->Target->GetBacktrace();
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
class cmTargetCollectLinkLanguages class cmTargetCollectLinkLanguages
{ {
@ -1749,7 +1754,7 @@ public:
"call is missing for an IMPORTED target, or an ALIAS target is " "call is missing for an IMPORTED target, or an ALIAS target is "
"missing?"; "missing?";
this->Target->GetLocalGenerator()->GetCMakeInstance()->IssueMessage( this->Target->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(
messageType, e.str(), this->Target->Target->GetBacktrace()); messageType, e.str(), this->Target->GetBacktrace());
} }
} }
return; return;
@ -1846,7 +1851,7 @@ public:
e << "Set the LINKER_LANGUAGE property for this target."; e << "Set the LINKER_LANGUAGE property for this target.";
cmake* cm = this->Target->GetLocalGenerator()->GetCMakeInstance(); cmake* cm = this->Target->GetLocalGenerator()->GetCMakeInstance();
cm->IssueMessage(cmake::FATAL_ERROR, e.str(), cm->IssueMessage(cmake::FATAL_ERROR, e.str(),
this->Target->Target->GetBacktrace()); this->Target->GetBacktrace());
} }
return *this->Preferred.begin(); return *this->Preferred.begin();
} }
@ -4831,7 +4836,7 @@ cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo(
this->LocalGenerator->GetCMakeInstance()->IssueMessage( this->LocalGenerator->GetCMakeInstance()->IssueMessage(
cmake::FATAL_ERROR, cmake::FATAL_ERROR,
"Target '" + this->GetName() + "' OUTPUT_DIRECTORY depends on itself.", "Target '" + this->GetName() + "' OUTPUT_DIRECTORY depends on itself.",
this->Target->GetBacktrace()); this->GetBacktrace());
return 0; return 0;
} }
return &i->second; return &i->second;
@ -5578,7 +5583,7 @@ std::string cmGeneratorTarget::CheckCMP0004(std::string const& item) const
<< "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(),
this->Target->GetBacktrace()); this->GetBacktrace());
} }
case cmPolicies::OLD: case cmPolicies::OLD:
break; break;
@ -5589,7 +5594,7 @@ std::string cmGeneratorTarget::CheckCMP0004(std::string const& item) const
<< item << "\" which has leading or trailing whitespace. " << item << "\" which has leading or trailing whitespace. "
<< "This is now an error according to policy CMP0004."; << "This is now an error according to policy CMP0004.";
cm->IssueMessage(cmake::FATAL_ERROR, e.str(), cm->IssueMessage(cmake::FATAL_ERROR, e.str(),
this->Target->GetBacktrace()); this->GetBacktrace());
} }
break; break;
case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_IF_USED:
@ -5600,7 +5605,7 @@ std::string cmGeneratorTarget::CheckCMP0004(std::string const& item) const
<< "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(), cm->IssueMessage(cmake::FATAL_ERROR, e.str(),
this->Target->GetBacktrace()); this->GetBacktrace());
} }
break; break;
} }
@ -5798,7 +5803,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
{ {
e << "Target \"" << this->GetName() << "\" links to itself."; e << "Target \"" << this->GetName() << "\" links to itself.";
this->LocalGenerator->GetCMakeInstance()->IssueMessage( this->LocalGenerator->GetCMakeInstance()->IssueMessage(
messageType, e.str(), this->Target->GetBacktrace()); messageType, e.str(), this->GetBacktrace());
if (messageType == cmake::FATAL_ERROR) if (messageType == cmake::FATAL_ERROR)
{ {
return; return;
@ -5873,7 +5878,7 @@ cmGeneratorTarget::FindTargetToLink(std::string const& name) const
"with the ENABLE_EXPORTS property set."; "with the ENABLE_EXPORTS property set.";
cmake* cm = this->LocalGenerator->GetCMakeInstance(); cmake* cm = this->LocalGenerator->GetCMakeInstance();
cm->IssueMessage(cmake::FATAL_ERROR, e.str(), cm->IssueMessage(cmake::FATAL_ERROR, e.str(),
this->Target->GetBacktrace()); this->GetBacktrace());
tgt = 0; tgt = 0;
} }

View File

@ -166,6 +166,8 @@ public:
* install tree. For example: "\@rpath/" or "\@loader_path/". */ * install tree. For example: "\@rpath/" or "\@loader_path/". */
std::string GetInstallNameDirForInstallTree() const; std::string GetInstallNameDirForInstallTree() const;
cmListFileBacktrace GetBacktrace() const;
/** Get the soname of the target. Allowed only for a shared library. */ /** Get the soname of the target. Allowed only for a shared library. */
std::string GetSOName(const std::string& config) const; std::string GetSOName(const std::string& config) const;

View File

@ -1982,7 +1982,7 @@ AddCompilerRequirementFlag(std::string &flags,
std::string e = std::string e =
lang + "_STANDARD is set to invalid value '" + standard + "'"; lang + "_STANDARD is set to invalid value '" + standard + "'";
this->GetGlobalGenerator()->GetCMakeInstance() this->GetGlobalGenerator()->GetCMakeInstance()
->IssueMessage(cmake::FATAL_ERROR, e, target->Target->GetBacktrace()); ->IssueMessage(cmake::FATAL_ERROR, e, target->GetBacktrace());
return; return;
} }
@ -2141,7 +2141,7 @@ void cmLocalGenerator
"For compatibility CMake is not honoring them for this target."; "For compatibility CMake is not honoring them for this target.";
target->Target->GetMakefile()->GetCMakeInstance() target->Target->GetMakefile()->GetCMakeInstance()
->IssueMessage(cmake::AUTHOR_WARNING, w.str(), ->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
target->Target->GetBacktrace()); target->GetBacktrace());
} }
} }

View File

@ -555,7 +555,7 @@ void cmOrderDirectories::FindImplicitConflicts()
<< "Some of these libraries may not be found correctly."; << "Some of these libraries may not be found correctly.";
this->GlobalGenerator->GetCMakeInstance() this->GlobalGenerator->GetCMakeInstance()
->IssueMessage(cmake::WARNING, w.str(), ->IssueMessage(cmake::WARNING, w.str(),
this->Target->Target->GetBacktrace()); this->Target->GetBacktrace());
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -637,5 +637,5 @@ void cmOrderDirectories::DiagnoseCycle()
e << "Some of these libraries may not be found correctly."; e << "Some of these libraries may not be found correctly.";
this->GlobalGenerator->GetCMakeInstance() this->GlobalGenerator->GetCMakeInstance()
->IssueMessage(cmake::WARNING, e.str(), ->IssueMessage(cmake::WARNING, e.str(),
this->Target->Target->GetBacktrace()); this->Target->GetBacktrace());
} }