summaryrefslogtreecommitdiff
path: root/Source/cmInstallExportGenerator.cxx
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2022-04-22 18:13:55 -0400
committerBen Boeckel <ben.boeckel@kitware.com>2022-04-28 09:13:48 -0400
commitc5b56b35c264664e897a2895e2561a5fb8287703 (patch)
tree74a2c0c2524178f8b0e60832a595500be29762e6 /Source/cmInstallExportGenerator.cxx
parentc107760417d5941202713fbaaa3e25e62d1dd12e (diff)
downloadcmake-c5b56b35c264664e897a2895e2561a5fb8287703.tar.gz
cmInstallExportGenerator: expose the temporary directory
This needs to be known so that C++ module properties for the install can be staged beside the other files. Always perform the MD5 transformation (in non-bootstrap builds) so that the path can be computed prior to generation (where it used the longest configuration name to detect too-long paths). Update tests to expect the always-present MD5 value. Note that this improves robustness of the test suite as testing in a too-long path may have triggered the MD5 conversion anyways.
Diffstat (limited to 'Source/cmInstallExportGenerator.cxx')
-rw-r--r--Source/cmInstallExportGenerator.cxx76
1 files changed, 19 insertions, 57 deletions
diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx
index eb7537d4bb..f1ac6561e0 100644
--- a/Source/cmInstallExportGenerator.cxx
+++ b/Source/cmInstallExportGenerator.cxx
@@ -2,7 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmInstallExportGenerator.h"
-#include <algorithm>
#include <map>
#include <sstream>
#include <utility>
@@ -54,73 +53,36 @@ bool cmInstallExportGenerator::Compute(cmLocalGenerator* lg)
return true;
}
-void cmInstallExportGenerator::ComputeTempDir()
+std::string cmInstallExportGenerator::TempDirCalculate() const
{
// Choose a temporary directory in which to generate the import
// files to be installed.
- this->TempDir = cmStrCat(this->LocalGenerator->GetCurrentBinaryDirectory(),
- "/CMakeFiles/Export");
+ std::string path = cmStrCat(
+ this->LocalGenerator->GetCurrentBinaryDirectory(), "/CMakeFiles/Export");
if (this->Destination.empty()) {
- return;
- }
- this->TempDir += "/";
-
- // Enforce a maximum length.
- bool useMD5 = false;
-#if defined(_WIN32) || defined(__CYGWIN__)
- std::string::size_type const max_total_len = 250;
-#else
- std::string::size_type const max_total_len = 1000;
-#endif
- // Will generate files of the form "<temp-dir>/<base>-<config>.<ext>".
- std::string::size_type const len = this->TempDir.size() + 1 +
- this->FileName.size() + 1 + this->GetMaxConfigLength();
- if (len < max_total_len) {
- // Keep the total path length below the limit.
- std::string::size_type const max_len = max_total_len - len;
- if (this->Destination.size() > max_len) {
- useMD5 = true;
- }
- } else {
- useMD5 = true;
+ return path;
}
- if (useMD5) {
- // Replace the destination path with a hash to keep it short.
+
#ifndef CMAKE_BOOTSTRAP
- this->TempDir += cmSystemTools::ComputeStringMD5(this->Destination);
+ path += '/';
+ // Replace the destination path with a hash to keep it short.
+ path += cmSystemTools::ComputeStringMD5(this->Destination);
#endif
- } else {
- std::string dest = this->Destination;
- // Avoid unix full paths.
- if (dest[0] == '/') {
- dest[0] = '_';
- }
- // Avoid windows full paths by removing colons.
- std::replace(dest.begin(), dest.end(), ':', '_');
- // Avoid relative paths that go up the tree.
- cmSystemTools::ReplaceString(dest, "../", "__/");
- // Avoid spaces.
- std::replace(dest.begin(), dest.end(), ' ', '_');
- this->TempDir += dest;
- }
+
+ return path;
}
-size_t cmInstallExportGenerator::GetMaxConfigLength() const
+void cmInstallExportGenerator::ComputeTempDir()
{
- // Always use at least 8 for "noconfig".
- size_t len = 8;
- if (this->ConfigurationTypes->empty()) {
- if (this->ConfigurationName.size() > 8) {
- len = this->ConfigurationName.size();
- }
- } else {
- for (std::string const& c : *this->ConfigurationTypes) {
- if (c.size() > len) {
- len = c.size();
- }
- }
+ this->TempDir = this->TempDirCalculate();
+}
+
+std::string cmInstallExportGenerator::GetTempDir() const
+{
+ if (this->TempDir.empty()) {
+ return this->TempDirCalculate();
}
- return len;
+ return this->TempDir;
}
void cmInstallExportGenerator::GenerateScript(std::ostream& os)