From 9777e4c30e55fb84c13727b322665f116fa49473 Mon Sep 17 00:00:00 2001
From: Ed Hartley <ehartley@mathworks.com>
Date: Tue, 18 Oct 2022 09:20:44 +0100
Subject: MinGW Makefiles: Quote UNC paths on command lines

UNC paths (starting with `\\`) need quotes when generating MinGW
Makefiles to avoid gmake interpreting the first `\` as an escape
character.

Fixes: #24061
---
 Source/cmOutputConverter.cxx | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx
index 6883535..299ab3a 100644
--- a/Source/cmOutputConverter.cxx
+++ b/Source/cmOutputConverter.cxx
@@ -527,6 +527,13 @@ bool cmOutputConverter::Shell_ArgumentNeedsQuotes(cm::string_view in,
     }
   }
 
+  /* UNC paths in MinGW Makefiles need quotes.  */
+  if ((flags & Shell_Flag_MinGWMake) && (flags & Shell_Flag_Make)) {
+    if (in.size() > 1 && in[0] == '\\' && in[1] == '\\') {
+      return true;
+    }
+  }
+
   return false;
 }
 
-- 
cgit v0.12