|
@@ -2,7 +2,6 @@
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
|
|
#include "cmInstallExportGenerator.h"
|
|
#include "cmInstallExportGenerator.h"
|
|
|
|
|
|
|
|
-#include <algorithm>
|
|
|
|
|
#include <map>
|
|
#include <map>
|
|
|
#include <sstream>
|
|
#include <sstream>
|
|
|
#include <utility>
|
|
#include <utility>
|
|
@@ -54,73 +53,36 @@ bool cmInstallExportGenerator::Compute(cmLocalGenerator* lg)
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void cmInstallExportGenerator::ComputeTempDir()
|
|
|
|
|
|
|
+std::string cmInstallExportGenerator::TempDirCalculate() const
|
|
|
{
|
|
{
|
|
|
// Choose a temporary directory in which to generate the import
|
|
// Choose a temporary directory in which to generate the import
|
|
|
// files to be installed.
|
|
// 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()) {
|
|
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
|
|
#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
|
|
#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)
|
|
void cmInstallExportGenerator::GenerateScript(std::ostream& os)
|