BUG: Fix bug 6605 more completely
- CMake 2.4 added link directories for targets linked in the optimized configuration even when building debug - Old behavior for policy CMP0003 must account for this
This commit is contained in:
parent
8605551920
commit
3652a8e913
|
@ -169,6 +169,9 @@ cmComputeLinkDepends
|
||||||
|
|
||||||
// Enable debug mode if requested.
|
// Enable debug mode if requested.
|
||||||
this->DebugMode = this->Makefile->IsOn("CMAKE_LINK_DEPENDS_DEBUG_MODE");
|
this->DebugMode = this->Makefile->IsOn("CMAKE_LINK_DEPENDS_DEBUG_MODE");
|
||||||
|
|
||||||
|
// Assume no compatibility until set.
|
||||||
|
this->OldLinkDirMode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -182,6 +185,12 @@ cmComputeLinkDepends::~cmComputeLinkDepends()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void cmComputeLinkDepends::SetOldLinkDirMode(bool b)
|
||||||
|
{
|
||||||
|
this->OldLinkDirMode = b;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
std::vector<cmComputeLinkDepends::LinkEntry> const&
|
std::vector<cmComputeLinkDepends::LinkEntry> const&
|
||||||
cmComputeLinkDepends::Compute()
|
cmComputeLinkDepends::Compute()
|
||||||
|
@ -460,6 +469,10 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index,
|
||||||
{
|
{
|
||||||
actual_libs.push_back(*di);
|
actual_libs.push_back(*di);
|
||||||
}
|
}
|
||||||
|
else if(this->OldLinkDirMode)
|
||||||
|
{
|
||||||
|
this->CheckWrongConfigItem(*di);
|
||||||
|
}
|
||||||
|
|
||||||
// Reset the link type until another explicit type is given.
|
// Reset the link type until another explicit type is given.
|
||||||
llt = cmTarget::GENERAL;
|
llt = cmTarget::GENERAL;
|
||||||
|
@ -492,6 +505,10 @@ cmComputeLinkDepends::AddTargetLinkEntries(int depender_index,
|
||||||
{
|
{
|
||||||
actual_libs.push_back(li->first);
|
actual_libs.push_back(li->first);
|
||||||
}
|
}
|
||||||
|
else if(this->OldLinkDirMode)
|
||||||
|
{
|
||||||
|
this->CheckWrongConfigItem(li->first);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add these entries.
|
// Add these entries.
|
||||||
|
@ -809,3 +826,23 @@ void cmComputeLinkDepends::DisplayFinalEntries()
|
||||||
}
|
}
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void cmComputeLinkDepends::CheckWrongConfigItem(std::string const& item)
|
||||||
|
{
|
||||||
|
if(!this->OldLinkDirMode)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// For CMake 2.4 bug-compatibility we need to consider the output
|
||||||
|
// directories of targets linked in another configuration as link
|
||||||
|
// directories.
|
||||||
|
if(cmTarget* tgt = this->Makefile->FindTargetToUse(item.c_str()))
|
||||||
|
{
|
||||||
|
if(!tgt->IsImported())
|
||||||
|
{
|
||||||
|
this->OldWrongConfigItems.insert(tgt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -54,6 +54,10 @@ public:
|
||||||
typedef std::vector<LinkEntry> EntryVector;
|
typedef std::vector<LinkEntry> EntryVector;
|
||||||
EntryVector const& Compute();
|
EntryVector const& Compute();
|
||||||
|
|
||||||
|
void SetOldLinkDirMode(bool b);
|
||||||
|
std::set<cmTarget*> const& GetOldWrongConfigItems() const
|
||||||
|
{ return this->OldWrongConfigItems; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// Context information.
|
// Context information.
|
||||||
|
@ -128,6 +132,11 @@ private:
|
||||||
void VisitComponent(cmComputeComponentGraph const& ccg, unsigned int i);
|
void VisitComponent(cmComputeComponentGraph const& ccg, unsigned int i);
|
||||||
void EmitComponent(NodeList const& nl);
|
void EmitComponent(NodeList const& nl);
|
||||||
void DisplayFinalEntries();
|
void DisplayFinalEntries();
|
||||||
|
|
||||||
|
// Compatibility help.
|
||||||
|
bool OldLinkDirMode;
|
||||||
|
void CheckWrongConfigItem(std::string const& item);
|
||||||
|
std::set<cmTarget*> OldWrongConfigItems;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -510,6 +510,7 @@ bool cmComputeLinkInformation::Compute()
|
||||||
|
|
||||||
// Compute the ordered link line items.
|
// Compute the ordered link line items.
|
||||||
cmComputeLinkDepends cld(this->Target, this->Config);
|
cmComputeLinkDepends cld(this->Target, this->Config);
|
||||||
|
cld.SetOldLinkDirMode(this->OldLinkDirMode);
|
||||||
cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute();
|
cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute();
|
||||||
|
|
||||||
// Add the link line items.
|
// Add the link line items.
|
||||||
|
@ -539,6 +540,25 @@ bool cmComputeLinkInformation::Compute()
|
||||||
this->SetCurrentLinkType(this->StartLinkType);
|
this->SetCurrentLinkType(this->StartLinkType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Finish listing compatibility paths.
|
||||||
|
if(this->OldLinkDirMode)
|
||||||
|
{
|
||||||
|
// For CMake 2.4 bug-compatibility we need to consider the output
|
||||||
|
// directories of targets linked in another configuration as link
|
||||||
|
// directories.
|
||||||
|
std::set<cmTarget*> const& wrongItems = cld.GetOldWrongConfigItems();
|
||||||
|
for(std::set<cmTarget*>::const_iterator i = wrongItems.begin();
|
||||||
|
i != wrongItems.end(); ++i)
|
||||||
|
{
|
||||||
|
cmTarget* tgt = *i;
|
||||||
|
bool implib =
|
||||||
|
(this->UseImportLibrary &&
|
||||||
|
(tgt->GetType() == cmTarget::SHARED_LIBRARY));
|
||||||
|
std::string lib = tgt->GetFullPath(this->Config , implib, true);
|
||||||
|
this->OldLinkDirItems.push_back(lib);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Finish setting up linker search directories.
|
// Finish setting up linker search directories.
|
||||||
if(!this->FinishLinkerSearchDirectories())
|
if(!this->FinishLinkerSearchDirectories())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue