SDL: Merge commit '62297e7da506e767de678c8aab4efdfd2fc38c89' into main

From 62297e7da506e767de678c8aab4efdfd2fc38c89 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Mon, 9 Jan 2023 15:44:38 +0100
Subject: [PATCH] cmake: avoid string(SUBSTRING) on short strings

CMake 3.1 and older throws an error when the input string is too short
---
 cmake/macros.cmake | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/cmake/macros.cmake b/cmake/macros.cmake
index 06df6c6d01d1..65b6cc9c8a6d 100644
--- a/cmake/macros.cmake
+++ b/cmake/macros.cmake
@@ -78,8 +78,7 @@ function(listtostr LIST OUTPUT)
   # Do not use string(REPLACE ";" " ") here to avoid messing up list entries
   set(res)
   foreach(ITEM ${${LIST}})
-    string(SUBSTRING "${ITEM}" 0 6 start)
-    if(start STREQUAL "SHELL:")
+    if(ITEM MATCHES "^SHELL:")
       string(SUBSTRING "${ITEM}" 6 -1 ITEM)
     endif()
     if(ITEM)