summaryrefslogtreecommitdiffstats
path: root/Source/cmGeneratorTarget.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-11-30 12:27:10 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-11-30 12:28:12 (GMT)
commit3b19541518d96fe803b26d4f20a23b71005af41c (patch)
tree3dbc83a2beeddeea16cf9cb4204e65148f9fd212 /Source/cmGeneratorTarget.cxx
parentd871fad90241df2b58b55c816554a1ef2ccf6a79 (diff)
parentf69d1872dbddb81f73d9f1dac98def9ee153ea9f (diff)
downloadCMake-3b19541518d96fe803b26d4f20a23b71005af41c.zip
CMake-3b19541518d96fe803b26d4f20a23b71005af41c.tar.gz
CMake-3b19541518d96fe803b26d4f20a23b71005af41c.tar.bz2
Merge topic 'add-generator-target-caches'
f69d1872db cmGeneratorTarget: Add caches to some functions Acked-by: Kitware Robot <kwrobot@kitware.com> Tested-by: buildbot <buildbot@kitware.com> Merge-request: !7952
Diffstat (limited to 'Source/cmGeneratorTarget.cxx')
-rw-r--r--Source/cmGeneratorTarget.cxx58
1 files changed, 57 insertions, 1 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 27e31d4..c80cdb9 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -749,6 +749,12 @@ void cmGeneratorTarget::ClearSourcesCache()
this->VisitedConfigsForObjects.clear();
this->LinkImplMap.clear();
this->LinkImplUsageRequirementsOnlyMap.clear();
+ this->IncludeDirectoriesCache.clear();
+ this->CompileOptionsCache.clear();
+ this->CompileDefinitionsCache.clear();
+ this->PrecompileHeadersCache.clear();
+ this->LinkOptionsCache.clear();
+ this->LinkDirectoriesCache.clear();
}
void cmGeneratorTarget::ClearLinkInterfaceCache()
@@ -3829,6 +3835,13 @@ void processIncludeDirectories(cmGeneratorTarget const* tgt,
std::vector<BT<std::string>> cmGeneratorTarget::GetIncludeDirectories(
const std::string& config, const std::string& lang) const
{
+ ConfigAndLanguage cacheKey(config, lang);
+ {
+ auto it = this->IncludeDirectoriesCache.find(cacheKey);
+ if (it != this->IncludeDirectoriesCache.end()) {
+ return it->second;
+ }
+ }
std::vector<BT<std::string>> includes;
std::unordered_set<std::string> uniqueIncludes;
@@ -3903,6 +3916,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetIncludeDirectories(
processIncludeDirectories(this, entries, includes, uniqueIncludes,
debugIncludes);
+ this->IncludeDirectoriesCache.emplace(cacheKey, includes);
return includes;
}
@@ -4080,6 +4094,13 @@ void cmGeneratorTarget::GetCompileOptions(std::vector<std::string>& result,
std::vector<BT<std::string>> cmGeneratorTarget::GetCompileOptions(
std::string const& config, std::string const& language) const
{
+ ConfigAndLanguage cacheKey(config, language);
+ {
+ auto it = this->CompileOptionsCache.find(cacheKey);
+ if (it != this->CompileOptionsCache.end()) {
+ return it->second;
+ }
+ }
std::vector<BT<std::string>> result;
std::unordered_set<std::string> uniqueOptions;
@@ -4106,6 +4127,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileOptions(
processOptions(this, entries, result, uniqueOptions, debugOptions,
"compile options", OptionsParse::Shell);
+ CompileOptionsCache.emplace(cacheKey, result);
return result;
}
@@ -4167,6 +4189,13 @@ void cmGeneratorTarget::GetCompileDefinitions(
std::vector<BT<std::string>> cmGeneratorTarget::GetCompileDefinitions(
std::string const& config, std::string const& language) const
{
+ ConfigAndLanguage cacheKey(config, language);
+ {
+ auto it = this->CompileDefinitionsCache.find(cacheKey);
+ if (it != this->CompileDefinitionsCache.end()) {
+ return it->second;
+ }
+ }
std::vector<BT<std::string>> list;
std::unordered_set<std::string> uniqueOptions;
@@ -4220,12 +4249,20 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileDefinitions(
processOptions(this, entries, list, uniqueOptions, debugDefines,
"compile definitions", OptionsParse::None);
+ this->CompileDefinitionsCache.emplace(cacheKey, list);
return list;
}
std::vector<BT<std::string>> cmGeneratorTarget::GetPrecompileHeaders(
const std::string& config, const std::string& language) const
{
+ ConfigAndLanguage cacheKey(config, language);
+ {
+ auto it = this->PrecompileHeadersCache.find(cacheKey);
+ if (it != this->PrecompileHeadersCache.end()) {
+ return it->second;
+ }
+ }
std::unordered_set<std::string> uniqueOptions;
cmGeneratorExpressionDAGChecker dagChecker(this, "PRECOMPILE_HEADERS",
@@ -4253,6 +4290,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetPrecompileHeaders(
processOptions(this, entries, list, uniqueOptions, debugDefines,
"precompile headers", OptionsParse::None);
+ this->PrecompileHeadersCache.emplace(cacheKey, list);
return list;
}
@@ -4613,6 +4651,13 @@ void cmGeneratorTarget::GetLinkOptions(std::vector<std::string>& result,
std::vector<BT<std::string>> cmGeneratorTarget::GetLinkOptions(
std::string const& config, std::string const& language) const
{
+ ConfigAndLanguage cacheKey(config, language);
+ {
+ auto it = this->LinkOptionsCache.find(cacheKey);
+ if (it != this->LinkOptionsCache.end()) {
+ return it->second;
+ }
+ }
std::vector<BT<std::string>> result;
std::unordered_set<std::string> uniqueOptions;
@@ -4690,7 +4735,10 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkOptions(
// Last step: replace "LINKER:" prefixed elements by
// actual linker wrapper
- return this->ResolveLinkerWrapper(result, language);
+ result = this->ResolveLinkerWrapper(result, language);
+
+ this->LinkOptionsCache.emplace(cacheKey, result);
+ return result;
}
std::vector<BT<std::string>>& cmGeneratorTarget::ResolveLinkerWrapper(
@@ -4889,6 +4937,13 @@ void cmGeneratorTarget::GetLinkDirectories(std::vector<std::string>& result,
std::vector<BT<std::string>> cmGeneratorTarget::GetLinkDirectories(
std::string const& config, std::string const& language) const
{
+ ConfigAndLanguage cacheKey(config, language);
+ {
+ auto it = this->LinkDirectoriesCache.find(cacheKey);
+ if (it != this->LinkDirectoriesCache.end()) {
+ return it->second;
+ }
+ }
std::vector<BT<std::string>> result;
std::unordered_set<std::string> uniqueDirectories;
@@ -4918,6 +4973,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkDirectories(
processLinkDirectories(this, entries, result, uniqueDirectories,
debugDirectories);
+ this->LinkDirectoriesCache.emplace(cacheKey, result);
return result;
}