Invalidate target link info when necessary

In cmTarget we compute the link implementation, link interface, and link
closure structures on-demand and cache the results.  This commit teaches
cmTarget to invalidate results after a LINK_INTERFACE_* property changes
or a new link library is added.  We also clear the results at the end of
the Configure step to ensure the Generate step uses up-to-date results.
This commit is contained in:
Brad King 2009-10-05 09:06:59 -04:00
parent daa2f3aa41
commit 0fb5b2c88c
2 changed files with 21 additions and 0 deletions

View File

@ -1030,10 +1030,24 @@ void cmTarget::SetMakefile(cmMakefile* mf)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmTarget::FinishConfigure() void cmTarget::FinishConfigure()
{ {
// Erase any cached link information that might have been comptued
// on-demand during the configuration. This ensures that build
// system generation uses up-to-date information even if other cache
// invalidation code in this source file is buggy.
this->ClearLinkMaps();
// Do old-style link dependency analysis. // Do old-style link dependency analysis.
this->AnalyzeLibDependencies(*this->Makefile); this->AnalyzeLibDependencies(*this->Makefile);
} }
//----------------------------------------------------------------------------
void cmTarget::ClearLinkMaps()
{
this->Internal->LinkImplMap.clear();
this->Internal->LinkInterfaceMap.clear();
this->Internal->LinkClosureMap.clear();
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmListFileBacktrace const& cmTarget::GetBacktrace() const cmListFileBacktrace const& cmTarget::GetBacktrace() const
{ {
@ -1656,6 +1670,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf,
tmp.second = llt; tmp.second = llt;
this->LinkLibraries.push_back( tmp ); this->LinkLibraries.push_back( tmp );
this->OriginalLinkLibraries.push_back(tmp); this->OriginalLinkLibraries.push_back(tmp);
this->ClearLinkMaps();
// Add the explicit dependency information for this target. This is // Add the explicit dependency information for this target. This is
// simply a set of libraries separated by ";". There should always // simply a set of libraries separated by ";". There should always
@ -2023,6 +2038,10 @@ void cmTarget::MaybeInvalidatePropertyCache(const char* prop)
{ {
this->Internal->ImportInfoMap.clear(); this->Internal->ImportInfoMap.clear();
} }
if(!this->IsImported() && strncmp(prop, "LINK_INTERFACE_", 15) == 0)
{
this->ClearLinkMaps();
}
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -567,6 +567,8 @@ private:
LinkImplementation& impl); LinkImplementation& impl);
void ComputeLinkClosure(const char* config, LinkClosure& lc); void ComputeLinkClosure(const char* config, LinkClosure& lc);
void ClearLinkMaps();
void MaybeInvalidatePropertyCache(const char* prop); void MaybeInvalidatePropertyCache(const char* prop);
// The cmMakefile instance that owns this target. This should // The cmMakefile instance that owns this target. This should