Merge topic 'target-drop-build-setting-cache'

133cd996 cmTarget: Drop internal cache of build properties
a4d58722 cmTarget: Drop internal cache of link interface usage requirements
This commit is contained in:
Brad King 2014-07-28 10:35:40 -04:00 committed by CMake Topic Stage
commit d128c6c9b3
1 changed files with 127 additions and 255 deletions

View File

@ -196,11 +196,9 @@ public:
public: public:
TargetPropertyEntry(cmsys::auto_ptr<cmCompiledGeneratorExpression> cge, TargetPropertyEntry(cmsys::auto_ptr<cmCompiledGeneratorExpression> cge,
cmLinkImplItem const& item = NoLinkImplItem) cmLinkImplItem const& item = NoLinkImplItem)
: ge(cge), Cached(false), LinkImplItem(item) : ge(cge), LinkImplItem(item)
{} {}
const cmsys::auto_ptr<cmCompiledGeneratorExpression> ge; const cmsys::auto_ptr<cmCompiledGeneratorExpression> ge;
std::vector<std::string> CachedEntries;
bool Cached;
cmLinkImplItem const& LinkImplItem; cmLinkImplItem const& LinkImplItem;
}; };
std::vector<TargetPropertyEntry*> IncludeDirectoriesEntries; std::vector<TargetPropertyEntry*> IncludeDirectoriesEntries;
@ -213,23 +211,6 @@ public:
void AddInterfaceEntries( void AddInterfaceEntries(
cmTarget const* thisTarget, std::string const& config, cmTarget const* thisTarget, std::string const& config,
std::string const& prop, std::vector<TargetPropertyEntry*>& entries); std::string const& prop, std::vector<TargetPropertyEntry*>& entries);
std::map<std::string, std::vector<TargetPropertyEntry*> >
CachedLinkInterfaceIncludeDirectoriesEntries;
std::map<std::string, std::vector<TargetPropertyEntry*> >
CachedLinkInterfaceCompileOptionsEntries;
std::map<std::string, std::vector<TargetPropertyEntry*> >
CachedLinkInterfaceCompileDefinitionsEntries;
std::map<std::string, std::vector<TargetPropertyEntry*> >
CachedLinkInterfaceSourcesEntries;
std::map<std::string, std::vector<TargetPropertyEntry*> >
CachedLinkInterfaceCompileFeaturesEntries;
std::map<std::string, bool> CacheLinkInterfaceIncludeDirectoriesDone;
std::map<std::string, bool> CacheLinkInterfaceCompileDefinitionsDone;
std::map<std::string, bool> CacheLinkInterfaceCompileOptionsDone;
std::map<std::string, bool> CacheLinkInterfaceSourcesDone;
std::map<std::string, bool> CacheLinkInterfaceCompileFeaturesDone;
}; };
cmLinkImplItem cmTargetInternals::TargetPropertyEntry::NoLinkImplItem; cmLinkImplItem cmTargetInternals::TargetPropertyEntry::NoLinkImplItem;
@ -248,27 +229,9 @@ static void deleteAndClear(
entries.clear(); entries.clear();
} }
//----------------------------------------------------------------------------
static void deleteAndClear(
std::map<std::string,
std::vector<cmTargetInternals::TargetPropertyEntry*> > &entries)
{
for (std::map<std::string,
std::vector<cmTargetInternals::TargetPropertyEntry*> >::iterator
it = entries.begin(), end = entries.end(); it != end; ++it)
{
deleteAndClear(it->second);
}
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmTargetInternals::~cmTargetInternals() cmTargetInternals::~cmTargetInternals()
{ {
deleteAndClear(this->CachedLinkInterfaceIncludeDirectoriesEntries);
deleteAndClear(this->CachedLinkInterfaceCompileOptionsEntries);
deleteAndClear(this->CachedLinkInterfaceCompileFeaturesEntries);
deleteAndClear(this->CachedLinkInterfaceCompileDefinitionsEntries);
deleteAndClear(this->CachedLinkInterfaceSourcesEntries);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -670,49 +633,37 @@ static bool processSources(cmTarget const* tgt,
for (std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator for (std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator
it = entries.begin(), end = entries.end(); it != end; ++it) it = entries.begin(), end = entries.end(); it != end; ++it)
{ {
bool cacheSources = false; std::vector<std::string> entrySources;
std::vector<std::string> entrySources = (*it)->CachedEntries; cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf,
if(entrySources.empty()) config,
false,
tgt,
tgt,
dagChecker),
entrySources);
if ((*it)->ge->GetHadContextSensitiveCondition())
{ {
cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, contextDependent = true;
config, }
false,
tgt,
tgt,
dagChecker),
entrySources);
if ((*it)->ge->GetHadContextSensitiveCondition()) for(std::vector<std::string>::iterator i = entrySources.begin();
{ i != entrySources.end(); ++i)
contextDependent = true; {
} std::string& src = *i;
else if (mf->IsGeneratingBuildSystem())
{
cacheSources = true;
}
for(std::vector<std::string>::iterator i = entrySources.begin(); cmSourceFile* sf = mf->GetOrCreateSource(src);
i != entrySources.end(); ++i) std::string e;
src = sf->GetFullPath(&e);
if(src.empty())
{ {
std::string& src = *i; if(!e.empty())
cmSourceFile* sf = mf->GetOrCreateSource(src);
std::string e;
src = sf->GetFullPath(&e);
if(src.empty())
{ {
if(!e.empty()) cmake* cm = mf->GetCMakeInstance();
{ cm->IssueMessage(cmake::FATAL_ERROR, e,
cmake* cm = mf->GetCMakeInstance(); tgt->GetBacktrace());
cm->IssueMessage(cmake::FATAL_ERROR, e,
tgt->GetBacktrace());
}
return contextDependent;
} }
} return contextDependent;
if (cacheSources)
{
(*it)->CachedEntries = entrySources;
} }
} }
std::string usedSources; std::string usedSources;
@ -810,16 +761,16 @@ void cmTarget::GetSourceFiles(std::vector<std::string> &files,
config, config,
debugSources); debugSources);
if (!this->Internal->CacheLinkInterfaceSourcesDone[config]) std::vector<cmTargetInternals::TargetPropertyEntry*>
{ linkInterfaceSourcesEntries;
this->Internal->AddInterfaceEntries(
this, config, "INTERFACE_SOURCES",
this->Internal->CachedLinkInterfaceSourcesEntries[config]);
}
std::vector<std::string>::size_type numFilesBefore = files.size(); this->Internal->AddInterfaceEntries(
bool contextDependentInterfaceSources = processSources(this, this, config, "INTERFACE_SOURCES",
this->Internal->CachedLinkInterfaceSourcesEntries[config], linkInterfaceSourcesEntries);
std::vector<std::string>::size_type numFilesBefore = files.size();
bool contextDependentInterfaceSources = processSources(this,
linkInterfaceSourcesEntries,
files, files,
uniqueSrcs, uniqueSrcs,
&dagChecker, &dagChecker,
@ -832,14 +783,7 @@ void cmTarget::GetSourceFiles(std::vector<std::string> &files,
this->LinkImplementationLanguageIsContextDependent = false; this->LinkImplementationLanguageIsContextDependent = false;
} }
if (!this->Makefile->IsGeneratingBuildSystem()) deleteAndClear(linkInterfaceSourcesEntries);
{
deleteAndClear(this->Internal->CachedLinkInterfaceSourcesEntries);
}
else
{
this->Internal->CacheLinkInterfaceSourcesDone[config] = true;
}
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -2045,27 +1989,14 @@ static void processIncludeDirectories(cmTarget const* tgt,
std::string const& targetName = item; std::string const& targetName = item;
bool const fromImported = item.Target && item.Target->IsImported(); bool const fromImported = item.Target && item.Target->IsImported();
bool const checkCMP0027 = item.FromGenex; bool const checkCMP0027 = item.FromGenex;
bool testIsOff = true; std::vector<std::string> entryIncludes;
bool cacheIncludes = false; cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf,
std::vector<std::string>& entryIncludes = (*it)->CachedEntries; config,
if(!entryIncludes.empty()) false,
{ tgt,
testIsOff = false; dagChecker),
} entryIncludes);
else
{
cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf,
config,
false,
tgt,
dagChecker),
entryIncludes);
if (mf->IsGeneratingBuildSystem()
&& !(*it)->ge->GetHadContextSensitiveCondition())
{
cacheIncludes = true;
}
}
std::string usedIncludes; std::string usedIncludes;
for(std::vector<std::string>::iterator for(std::vector<std::string>::iterator
li = entryIncludes.begin(); li != entryIncludes.end(); ++li) li = entryIncludes.begin(); li != entryIncludes.end(); ++li)
@ -2147,7 +2078,7 @@ static void processIncludeDirectories(cmTarget const* tgt,
} }
} }
if (testIsOff && !cmSystemTools::IsOff(li->c_str())) if (!cmSystemTools::IsOff(li->c_str()))
{ {
cmSystemTools::ConvertToUnixSlashes(*li); cmSystemTools::ConvertToUnixSlashes(*li);
} }
@ -2162,10 +2093,6 @@ static void processIncludeDirectories(cmTarget const* tgt,
} }
} }
} }
if (cacheIncludes)
{
(*it)->CachedEntries = entryIncludes;
}
if (!usedIncludes.empty()) if (!usedIncludes.empty())
{ {
mf->GetCMakeInstance()->IssueMessage(cmake::LOG, mf->GetCMakeInstance()->IssueMessage(cmake::LOG,
@ -2213,58 +2140,47 @@ cmTarget::GetIncludeDirectories(const std::string& config) const
config, config,
debugIncludes); debugIncludes);
if (!this->Internal->CacheLinkInterfaceIncludeDirectoriesDone[config]) std::vector<cmTargetInternals::TargetPropertyEntry*>
linkInterfaceIncludeDirectoriesEntries;
this->Internal->AddInterfaceEntries(
this, config, "INTERFACE_INCLUDE_DIRECTORIES",
linkInterfaceIncludeDirectoriesEntries);
if(this->Makefile->IsOn("APPLE"))
{ {
this->Internal->AddInterfaceEntries( LinkImplementation const* impl = this->GetLinkImplementation(config);
this, config, "INTERFACE_INCLUDE_DIRECTORIES", for(std::vector<cmLinkImplItem>::const_iterator
this->Internal->CachedLinkInterfaceIncludeDirectoriesEntries[config]); it = impl->Libraries.begin();
it != impl->Libraries.end(); ++it)
if(this->Makefile->IsOn("APPLE"))
{ {
LinkImplementation const* impl = this->GetLinkImplementation(config); std::string libDir = cmSystemTools::CollapseFullPath(it->c_str());
for(std::vector<cmLinkImplItem>::const_iterator
it = impl->Libraries.begin(); static cmsys::RegularExpression
it != impl->Libraries.end(); ++it) frameworkCheck("(.*\\.framework)(/Versions/[^/]+)?/[^/]+$");
if(!frameworkCheck.find(libDir))
{ {
std::string libDir = cmSystemTools::CollapseFullPath(it->c_str()); continue;
static cmsys::RegularExpression
frameworkCheck("(.*\\.framework)(/Versions/[^/]+)?/[^/]+$");
if(!frameworkCheck.find(libDir))
{
continue;
}
libDir = frameworkCheck.match(1);
cmGeneratorExpression ge;
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(libDir.c_str());
this->Internal
->CachedLinkInterfaceIncludeDirectoriesEntries[config]
.push_back(new cmTargetInternals::TargetPropertyEntry(cge));
} }
libDir = frameworkCheck.match(1);
cmGeneratorExpression ge;
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(libDir.c_str());
linkInterfaceIncludeDirectoriesEntries
.push_back(new cmTargetInternals::TargetPropertyEntry(cge));
} }
} }
processIncludeDirectories(this, processIncludeDirectories(this,
this->Internal->CachedLinkInterfaceIncludeDirectoriesEntries[config], linkInterfaceIncludeDirectoriesEntries,
includes, includes,
uniqueIncludes, uniqueIncludes,
&dagChecker, &dagChecker,
config, config,
debugIncludes); debugIncludes);
if (!this->Makefile->IsGeneratingBuildSystem()) deleteAndClear(linkInterfaceIncludeDirectoriesEntries);
{
deleteAndClear(
this->Internal->CachedLinkInterfaceIncludeDirectoriesEntries);
}
else
{
this->Internal->CacheLinkInterfaceIncludeDirectoriesDone[config]
= true;
}
return includes; return includes;
} }
@ -2282,33 +2198,16 @@ static void processCompileOptionsInternal(cmTarget const* tgt,
for (std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator for (std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator
it = entries.begin(), end = entries.end(); it != end; ++it) it = entries.begin(), end = entries.end(); it != end; ++it)
{ {
std::vector<std::string>& entriesRef = (*it)->CachedEntries; std::vector<std::string> entryOptions;
std::vector<std::string> localEntries; cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf,
std::vector<std::string>* entryOptions = &entriesRef; config,
if(!(*it)->Cached) false,
{ tgt,
cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, dagChecker),
config, entryOptions);
false,
tgt,
dagChecker),
localEntries);
if (mf->IsGeneratingBuildSystem()
&& !(*it)->ge->GetHadContextSensitiveCondition())
{
// Cache the result.
*entryOptions = localEntries;
(*it)->Cached = true;
}
else
{
// Use the context-sensitive results here.
entryOptions = &localEntries;
}
}
std::string usedOptions; std::string usedOptions;
for(std::vector<std::string>::iterator for(std::vector<std::string>::iterator
li = entryOptions->begin(); li != entryOptions->end(); ++li) li = entryOptions.begin(); li != entryOptions.end(); ++li)
{ {
std::string const& opt = *li; std::string const& opt = *li;
@ -2405,29 +2304,22 @@ void cmTarget::GetCompileOptions(std::vector<std::string> &result,
config, config,
debugOptions); debugOptions);
if (!this->Internal->CacheLinkInterfaceCompileOptionsDone[config]) std::vector<cmTargetInternals::TargetPropertyEntry*>
{ linkInterfaceCompileOptionsEntries;
this->Internal->AddInterfaceEntries(
this, config, "INTERFACE_COMPILE_OPTIONS", this->Internal->AddInterfaceEntries(
this->Internal->CachedLinkInterfaceCompileOptionsEntries[config]); this, config, "INTERFACE_COMPILE_OPTIONS",
} linkInterfaceCompileOptionsEntries);
processCompileOptions(this, processCompileOptions(this,
this->Internal->CachedLinkInterfaceCompileOptionsEntries[config], linkInterfaceCompileOptionsEntries,
result, result,
uniqueOptions, uniqueOptions,
&dagChecker, &dagChecker,
config, config,
debugOptions); debugOptions);
if (!this->Makefile->IsGeneratingBuildSystem()) deleteAndClear(linkInterfaceCompileOptionsEntries);
{
deleteAndClear(this->Internal->CachedLinkInterfaceCompileOptionsEntries);
}
else
{
this->Internal->CacheLinkInterfaceCompileOptionsDone[config] = true;
}
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -2479,66 +2371,54 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list,
config, config,
debugDefines); debugDefines);
if (!this->Internal->CacheLinkInterfaceCompileDefinitionsDone[config]) std::vector<cmTargetInternals::TargetPropertyEntry*>
linkInterfaceCompileDefinitionsEntries;
this->Internal->AddInterfaceEntries(
this, config, "INTERFACE_COMPILE_DEFINITIONS",
linkInterfaceCompileDefinitionsEntries);
if (!config.empty())
{ {
this->Internal->AddInterfaceEntries( std::string configPropName = "COMPILE_DEFINITIONS_"
this, config, "INTERFACE_COMPILE_DEFINITIONS", + cmSystemTools::UpperCase(config);
this->Internal->CachedLinkInterfaceCompileDefinitionsEntries[config]); const char *configProp = this->GetProperty(configPropName);
if (!config.empty()) if (configProp)
{ {
std::string configPropName = "COMPILE_DEFINITIONS_" switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0043))
+ cmSystemTools::UpperCase(config);
const char *configProp = this->GetProperty(configPropName);
if (configProp)
{ {
switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0043)) case cmPolicies::WARN:
{ {
case cmPolicies::WARN: cmOStringStream e;
{ e << this->Makefile->GetCMakeInstance()->GetPolicies()
cmOStringStream e; ->GetPolicyWarning(cmPolicies::CMP0043);
e << this->Makefile->GetCMakeInstance()->GetPolicies() this->Makefile->IssueMessage(cmake::AUTHOR_WARNING,
->GetPolicyWarning(cmPolicies::CMP0043); e.str());
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING,
e.str());
}
case cmPolicies::OLD:
{
cmGeneratorExpression ge;
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(configProp);
this->Internal
->CachedLinkInterfaceCompileDefinitionsEntries[config]
.push_back(new cmTargetInternals::TargetPropertyEntry(cge));
}
break;
case cmPolicies::NEW:
case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::REQUIRED_IF_USED:
break;
} }
case cmPolicies::OLD:
{
cmGeneratorExpression ge;
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(configProp);
linkInterfaceCompileDefinitionsEntries
.push_back(new cmTargetInternals::TargetPropertyEntry(cge));
}
break;
case cmPolicies::NEW:
case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::REQUIRED_IF_USED:
break;
} }
} }
} }
processCompileDefinitions(this, processCompileDefinitions(this,
this->Internal->CachedLinkInterfaceCompileDefinitionsEntries[config], linkInterfaceCompileDefinitionsEntries,
list, list,
uniqueOptions, uniqueOptions,
&dagChecker, &dagChecker,
config, config,
debugDefines); debugDefines);
if (!this->Makefile->IsGeneratingBuildSystem()) deleteAndClear(linkInterfaceCompileDefinitionsEntries);
{
deleteAndClear(this->Internal
->CachedLinkInterfaceCompileDefinitionsEntries);
}
else
{
this->Internal->CacheLinkInterfaceCompileDefinitionsDone[config]
= true;
}
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -2590,29 +2470,21 @@ void cmTarget::GetCompileFeatures(std::vector<std::string> &result,
config, config,
debugFeatures); debugFeatures);
if (!this->Internal->CacheLinkInterfaceCompileFeaturesDone[config]) std::vector<cmTargetInternals::TargetPropertyEntry*>
{ linkInterfaceCompileFeaturesEntries;
this->Internal->AddInterfaceEntries( this->Internal->AddInterfaceEntries(
this, config, "INTERFACE_COMPILE_FEATURES", this, config, "INTERFACE_COMPILE_FEATURES",
this->Internal->CachedLinkInterfaceCompileFeaturesEntries[config]); linkInterfaceCompileFeaturesEntries);
}
processCompileFeatures(this, processCompileFeatures(this,
this->Internal->CachedLinkInterfaceCompileFeaturesEntries[config], linkInterfaceCompileFeaturesEntries,
result, result,
uniqueFeatures, uniqueFeatures,
&dagChecker, &dagChecker,
config, config,
debugFeatures); debugFeatures);
if (!this->Makefile->IsGeneratingBuildSystem()) deleteAndClear(linkInterfaceCompileFeaturesEntries);
{
deleteAndClear(this->Internal->CachedLinkInterfaceCompileFeaturesEntries);
}
else
{
this->Internal->CacheLinkInterfaceCompileFeaturesDone[config] = true;
}
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------