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

View File

@ -196,11 +196,9 @@ public:
public:
TargetPropertyEntry(cmsys::auto_ptr<cmCompiledGeneratorExpression> cge,
cmLinkImplItem const& item = NoLinkImplItem)
: ge(cge), Cached(false), LinkImplItem(item)
: ge(cge), LinkImplItem(item)
{}
const cmsys::auto_ptr<cmCompiledGeneratorExpression> ge;
std::vector<std::string> CachedEntries;
bool Cached;
cmLinkImplItem const& LinkImplItem;
};
std::vector<TargetPropertyEntry*> IncludeDirectoriesEntries;
@ -213,23 +211,6 @@ public:
void AddInterfaceEntries(
cmTarget const* thisTarget, std::string const& config,
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;
@ -248,27 +229,9 @@ static void deleteAndClear(
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()
{
deleteAndClear(this->CachedLinkInterfaceIncludeDirectoriesEntries);
deleteAndClear(this->CachedLinkInterfaceCompileOptionsEntries);
deleteAndClear(this->CachedLinkInterfaceCompileFeaturesEntries);
deleteAndClear(this->CachedLinkInterfaceCompileDefinitionsEntries);
deleteAndClear(this->CachedLinkInterfaceSourcesEntries);
}
//----------------------------------------------------------------------------
@ -670,10 +633,7 @@ static bool processSources(cmTarget const* tgt,
for (std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator
it = entries.begin(), end = entries.end(); it != end; ++it)
{
bool cacheSources = false;
std::vector<std::string> entrySources = (*it)->CachedEntries;
if(entrySources.empty())
{
std::vector<std::string> entrySources;
cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf,
config,
false,
@ -686,10 +646,6 @@ static bool processSources(cmTarget const* tgt,
{
contextDependent = true;
}
else if (mf->IsGeneratingBuildSystem())
{
cacheSources = true;
}
for(std::vector<std::string>::iterator i = entrySources.begin();
i != entrySources.end(); ++i)
@ -710,11 +666,6 @@ static bool processSources(cmTarget const* tgt,
return contextDependent;
}
}
if (cacheSources)
{
(*it)->CachedEntries = entrySources;
}
}
std::string usedSources;
for(std::vector<std::string>::iterator
li = entrySources.begin(); li != entrySources.end(); ++li)
@ -810,16 +761,16 @@ void cmTarget::GetSourceFiles(std::vector<std::string> &files,
config,
debugSources);
if (!this->Internal->CacheLinkInterfaceSourcesDone[config])
{
std::vector<cmTargetInternals::TargetPropertyEntry*>
linkInterfaceSourcesEntries;
this->Internal->AddInterfaceEntries(
this, config, "INTERFACE_SOURCES",
this->Internal->CachedLinkInterfaceSourcesEntries[config]);
}
linkInterfaceSourcesEntries);
std::vector<std::string>::size_type numFilesBefore = files.size();
bool contextDependentInterfaceSources = processSources(this,
this->Internal->CachedLinkInterfaceSourcesEntries[config],
linkInterfaceSourcesEntries,
files,
uniqueSrcs,
&dagChecker,
@ -832,14 +783,7 @@ void cmTarget::GetSourceFiles(std::vector<std::string> &files,
this->LinkImplementationLanguageIsContextDependent = false;
}
if (!this->Makefile->IsGeneratingBuildSystem())
{
deleteAndClear(this->Internal->CachedLinkInterfaceSourcesEntries);
}
else
{
this->Internal->CacheLinkInterfaceSourcesDone[config] = true;
}
deleteAndClear(linkInterfaceSourcesEntries);
}
//----------------------------------------------------------------------------
@ -2045,27 +1989,14 @@ static void processIncludeDirectories(cmTarget const* tgt,
std::string const& targetName = item;
bool const fromImported = item.Target && item.Target->IsImported();
bool const checkCMP0027 = item.FromGenex;
bool testIsOff = true;
bool cacheIncludes = false;
std::vector<std::string>& entryIncludes = (*it)->CachedEntries;
if(!entryIncludes.empty())
{
testIsOff = false;
}
else
{
std::vector<std::string> entryIncludes;
cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf,
config,
false,
tgt,
dagChecker),
entryIncludes);
if (mf->IsGeneratingBuildSystem()
&& !(*it)->ge->GetHadContextSensitiveCondition())
{
cacheIncludes = true;
}
}
std::string usedIncludes;
for(std::vector<std::string>::iterator
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);
}
@ -2162,10 +2093,6 @@ static void processIncludeDirectories(cmTarget const* tgt,
}
}
}
if (cacheIncludes)
{
(*it)->CachedEntries = entryIncludes;
}
if (!usedIncludes.empty())
{
mf->GetCMakeInstance()->IssueMessage(cmake::LOG,
@ -2213,11 +2140,11 @@ cmTarget::GetIncludeDirectories(const std::string& config) const
config,
debugIncludes);
if (!this->Internal->CacheLinkInterfaceIncludeDirectoriesDone[config])
{
std::vector<cmTargetInternals::TargetPropertyEntry*>
linkInterfaceIncludeDirectoriesEntries;
this->Internal->AddInterfaceEntries(
this, config, "INTERFACE_INCLUDE_DIRECTORIES",
this->Internal->CachedLinkInterfaceIncludeDirectoriesEntries[config]);
linkInterfaceIncludeDirectoriesEntries);
if(this->Makefile->IsOn("APPLE"))
{
@ -2240,31 +2167,20 @@ cmTarget::GetIncludeDirectories(const std::string& config) const
cmGeneratorExpression ge;
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(libDir.c_str());
this->Internal
->CachedLinkInterfaceIncludeDirectoriesEntries[config]
linkInterfaceIncludeDirectoriesEntries
.push_back(new cmTargetInternals::TargetPropertyEntry(cge));
}
}
}
processIncludeDirectories(this,
this->Internal->CachedLinkInterfaceIncludeDirectoriesEntries[config],
linkInterfaceIncludeDirectoriesEntries,
includes,
uniqueIncludes,
&dagChecker,
config,
debugIncludes);
if (!this->Makefile->IsGeneratingBuildSystem())
{
deleteAndClear(
this->Internal->CachedLinkInterfaceIncludeDirectoriesEntries);
}
else
{
this->Internal->CacheLinkInterfaceIncludeDirectoriesDone[config]
= true;
}
deleteAndClear(linkInterfaceIncludeDirectoriesEntries);
return includes;
}
@ -2282,33 +2198,16 @@ static void processCompileOptionsInternal(cmTarget const* tgt,
for (std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator
it = entries.begin(), end = entries.end(); it != end; ++it)
{
std::vector<std::string>& entriesRef = (*it)->CachedEntries;
std::vector<std::string> localEntries;
std::vector<std::string>* entryOptions = &entriesRef;
if(!(*it)->Cached)
{
std::vector<std::string> entryOptions;
cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf,
config,
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;
}
}
entryOptions);
std::string usedOptions;
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;
@ -2405,29 +2304,22 @@ void cmTarget::GetCompileOptions(std::vector<std::string> &result,
config,
debugOptions);
if (!this->Internal->CacheLinkInterfaceCompileOptionsDone[config])
{
std::vector<cmTargetInternals::TargetPropertyEntry*>
linkInterfaceCompileOptionsEntries;
this->Internal->AddInterfaceEntries(
this, config, "INTERFACE_COMPILE_OPTIONS",
this->Internal->CachedLinkInterfaceCompileOptionsEntries[config]);
}
linkInterfaceCompileOptionsEntries);
processCompileOptions(this,
this->Internal->CachedLinkInterfaceCompileOptionsEntries[config],
linkInterfaceCompileOptionsEntries,
result,
uniqueOptions,
&dagChecker,
config,
debugOptions);
if (!this->Makefile->IsGeneratingBuildSystem())
{
deleteAndClear(this->Internal->CachedLinkInterfaceCompileOptionsEntries);
}
else
{
this->Internal->CacheLinkInterfaceCompileOptionsDone[config] = true;
}
deleteAndClear(linkInterfaceCompileOptionsEntries);
}
//----------------------------------------------------------------------------
@ -2479,11 +2371,11 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list,
config,
debugDefines);
if (!this->Internal->CacheLinkInterfaceCompileDefinitionsDone[config])
{
std::vector<cmTargetInternals::TargetPropertyEntry*>
linkInterfaceCompileDefinitionsEntries;
this->Internal->AddInterfaceEntries(
this, config, "INTERFACE_COMPILE_DEFINITIONS",
this->Internal->CachedLinkInterfaceCompileDefinitionsEntries[config]);
linkInterfaceCompileDefinitionsEntries);
if (!config.empty())
{
std::string configPropName = "COMPILE_DEFINITIONS_"
@ -2506,8 +2398,7 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list,
cmGeneratorExpression ge;
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(configProp);
this->Internal
->CachedLinkInterfaceCompileDefinitionsEntries[config]
linkInterfaceCompileDefinitionsEntries
.push_back(new cmTargetInternals::TargetPropertyEntry(cge));
}
break;
@ -2519,26 +2410,15 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list,
}
}
}
processCompileDefinitions(this,
this->Internal->CachedLinkInterfaceCompileDefinitionsEntries[config],
linkInterfaceCompileDefinitionsEntries,
list,
uniqueOptions,
&dagChecker,
config,
debugDefines);
if (!this->Makefile->IsGeneratingBuildSystem())
{
deleteAndClear(this->Internal
->CachedLinkInterfaceCompileDefinitionsEntries);
}
else
{
this->Internal->CacheLinkInterfaceCompileDefinitionsDone[config]
= true;
}
deleteAndClear(linkInterfaceCompileDefinitionsEntries);
}
//----------------------------------------------------------------------------
@ -2590,29 +2470,21 @@ void cmTarget::GetCompileFeatures(std::vector<std::string> &result,
config,
debugFeatures);
if (!this->Internal->CacheLinkInterfaceCompileFeaturesDone[config])
{
std::vector<cmTargetInternals::TargetPropertyEntry*>
linkInterfaceCompileFeaturesEntries;
this->Internal->AddInterfaceEntries(
this, config, "INTERFACE_COMPILE_FEATURES",
this->Internal->CachedLinkInterfaceCompileFeaturesEntries[config]);
}
linkInterfaceCompileFeaturesEntries);
processCompileFeatures(this,
this->Internal->CachedLinkInterfaceCompileFeaturesEntries[config],
linkInterfaceCompileFeaturesEntries,
result,
uniqueFeatures,
&dagChecker,
config,
debugFeatures);
if (!this->Makefile->IsGeneratingBuildSystem())
{
deleteAndClear(this->Internal->CachedLinkInterfaceCompileFeaturesEntries);
}
else
{
this->Internal->CacheLinkInterfaceCompileFeaturesDone[config] = true;
}
deleteAndClear(linkInterfaceCompileFeaturesEntries);
}
//----------------------------------------------------------------------------