diff options
author | Brad King <brad.king@kitware.com> | 2022-01-31 15:30:24 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-01-31 15:30:30 (GMT) |
commit | d3006c0ca79f502f026d9b1b36cacac8e60b933b (patch) | |
tree | 4876e69067977379a3c48627b6cdc951cd9a1485 /Source | |
parent | 3de6155ca08e2c308ffe075b6efcb949907bba71 (diff) | |
parent | 5f8c5657a9a41b6f6138bbc1f35901e4007c477a (diff) | |
download | CMake-d3006c0ca79f502f026d9b1b36cacac8e60b933b.zip CMake-d3006c0ca79f502f026d9b1b36cacac8e60b933b.tar.gz CMake-d3006c0ca79f502f026d9b1b36cacac8e60b933b.tar.bz2 |
Merge topic 'shorter-obj'
5f8c5657a9 Shorten object name even if still longer than CMAKE_OBJECT_PATH_MAX
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !6915
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmLocalGenerator.cxx | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 5b3aad3..50e6cdc 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -3430,21 +3430,27 @@ void cmLocalGenerator::GenerateTargetInstallRules( static bool cmLocalGeneratorShortenObjectName(std::string& objName, std::string::size_type max_len) { + // Check if the path can be shortened using an md5 sum replacement for + // a portion of the path. + std::string::size_type md5Len = 32; + std::string::size_type numExtraChars = objName.size() - max_len + md5Len; + std::string::size_type pos = objName.find('/', numExtraChars); + if (pos == std::string::npos) { + pos = objName.rfind('/', numExtraChars); + if (pos == std::string::npos || pos <= md5Len) { + return false; + } + } + // Replace the beginning of the path portion of the object name with // its own md5 sum. - std::string::size_type pos = - objName.find('/', objName.size() - max_len + 32); - if (pos != std::string::npos) { - cmCryptoHash md5(cmCryptoHash::AlgoMD5); - std::string md5name = cmStrCat(md5.HashString(objName.substr(0, pos)), - cm::string_view(objName).substr(pos)); - objName = md5name; + cmCryptoHash md5(cmCryptoHash::AlgoMD5); + std::string md5name = cmStrCat(md5.HashString(objName.substr(0, pos)), + cm::string_view(objName).substr(pos)); + objName = md5name; - // The object name is now short enough. - return true; - } - // The object name could not be shortened enough. - return false; + // The object name is now shorter, check if it is short enough. + return pos >= numExtraChars; } bool cmLocalGeneratorCheckObjectName(std::string& objName, |