From 2266e223c56be365cadfdf9f394009c095a37c8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20B=C3=B6ger?= Date: Sun, 19 Sep 2021 17:15:21 +0100 Subject: macOS: Speed up rpath install name dir lookup with a cache Fixes: #20602 --- Source/cmGeneratorTarget.cxx | 15 +++++++++++++++ Source/cmGeneratorTarget.h | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4bad7ab..30c022f 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -2170,6 +2170,21 @@ bool cmGeneratorTarget::IsImportedSharedLibWithoutSOName( bool cmGeneratorTarget::HasMacOSXRpathInstallNameDir( const std::string& config) const { + TargetPtrToBoolMap& cache = this->MacOSXRpathInstallNameDirCache[config]; + const auto lookup = cache.find(this->Target); + + if (lookup != cache.cend()) { + return lookup->second; + } + + const bool result = this->DetermineHasMacOSXRpathInstallNameDir(config); + cache[this->Target] = result; + return result; +} + +bool cmGeneratorTarget::DetermineHasMacOSXRpathInstallNameDir( + const std::string& config) const +{ bool install_name_is_rpath = false; bool macosx_rpath = false; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 0076085..85b4ea0 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -866,6 +866,11 @@ private: mutable std::map Objects; std::set ExplicitObjectName; + using TargetPtrToBoolMap = std::unordered_map; + mutable std::unordered_map + MacOSXRpathInstallNameDirCache; + bool DetermineHasMacOSXRpathInstallNameDir(const std::string& config) const; + // "config/language" is the key mutable std::map> SystemIncludesCache; -- cgit v0.12