summaryrefslogtreecommitdiffstats
path: root/Source/cmSystemTools.cxx
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2021-01-06 12:52:53 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2021-01-09 10:35:00 (GMT)
commit8ec7408d745a9e17a1e35a4e97e9ab33044832c9 (patch)
tree7eecc261db167be34f52ce087e61dc3e38e1167b /Source/cmSystemTools.cxx
parentce874fbcd6350225ce854a984efd34caf78c3e0f (diff)
downloadCMake-8ec7408d745a9e17a1e35a4e97e9ab33044832c9.zip
CMake-8ec7408d745a9e17a1e35a4e97e9ab33044832c9.tar.gz
CMake-8ec7408d745a9e17a1e35a4e97e9ab33044832c9.tar.bz2
Makefile dependencies: ensure long paths are used on Windows
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r--Source/cmSystemTools.cxx24
1 files changed, 24 insertions, 0 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 6a705f4..024356f 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1255,6 +1255,30 @@ void cmSystemTools::ConvertToOutputSlashes(std::string& path)
#endif
}
+void cmSystemTools::ConvertToLongPath(std::string& path)
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ // Try to convert path to a long path only if the path contains character '~'
+ if (path.find('~') == std::string::npos) {
+ return;
+ }
+
+ std::wstring wPath = cmsys::Encoding::ToWide(path);
+ DWORD ret = GetLongPathNameW(wPath.c_str(), nullptr, 0);
+ std::vector<wchar_t> buffer(ret);
+ if (ret != 0) {
+ ret = GetLongPathNameW(wPath.c_str(), buffer.data(),
+ static_cast<DWORD>(buffer.size()));
+ }
+
+ if (ret != 0) {
+ path = cmsys::Encoding::ToNarrow(buffer.data());
+ }
+#else
+ static_cast<void>(path);
+#endif
+}
+
std::string cmSystemTools::ConvertToRunCommandPath(const std::string& path)
{
#if defined(_WIN32) && !defined(__CYGWIN__)