VS: Fix support for v142 toolset minor versions in VS 16.5+

The fix in commit 5117389931 (VS: Fix support for v142 toolset minor
versions, 2019-10-01, v3.16.0-rc1~32^2) worked around a bug in VS's
placement of toolset files.   VS 16.5 will fix that bug and restore the
original pattern for locations of toolset files.  Update our logic to
look for both possibilities.

Issue: #19779
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index 908e530..7b571c3 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -284,10 +284,11 @@
           set(id_cl icl.exe)
         endif()
         if(CMAKE_VS_PLATFORM_TOOLSET_VERSION)
+          set(id_sep "\\")
           if(CMAKE_VS_PLATFORM_TOOLSET_VERSION VERSION_GREATER_EQUAL "14.20")
-            set(id_sep ".")
-          else()
-            set(id_sep "\\")
+            if(EXISTS "${CMAKE_GENERATOR_INSTANCE}/VC/Auxiliary/Build.${CMAKE_VS_PLATFORM_TOOLSET_VERSION}/Microsoft.VCToolsVersion.${CMAKE_VS_PLATFORM_TOOLSET_VERSION}.props")
+              set(id_sep ".")
+            endif()
           endif()
           set(id_toolset_version_props "<Import Project=\"${CMAKE_GENERATOR_INSTANCE}\\VC\\Auxiliary\\Build${id_sep}${CMAKE_VS_PLATFORM_TOOLSET_VERSION}\\Microsoft.VCToolsVersion.${CMAKE_VS_PLATFORM_TOOLSET_VERSION}.props\" />")
           unset(id_sep)
diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx
index 1eca1f6..a371633 100644
--- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx
+++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx
@@ -6,6 +6,7 @@
 #include "cmDocumentationEntry.h"
 #include "cmLocalVisualStudio10Generator.h"
 #include "cmMakefile.h"
+#include "cmStringAlgorithms.h"
 #include "cmVSSetupHelper.h"
 #include "cmake.h"
 
@@ -388,15 +389,19 @@
   if (version) {
     std::string instancePath;
     GetVSInstance(instancePath);
-    std::stringstream path;
-    path << instancePath;
-    path << "/VC/Auxiliary/Build";
-    path << (cmSystemTools::VersionCompareGreaterEq(version, "14.20") ? '.'
-                                                                      : '/');
-    path << version;
-    path << "/Microsoft.VCToolsVersion." << version << ".props";
-
-    std::string toolsetPath = path.str();
+    std::string toolsetDir = instancePath + "/VC/Auxiliary/Build";
+    char sep = '/';
+    if (cmSystemTools::VersionCompareGreaterEq(version, "14.20")) {
+      std::string toolsetDot =
+        cmStrCat(toolsetDir, '.', version, "/Microsoft.VCToolsVersion.",
+                 version, ".props");
+      if (cmSystemTools::PathExists(toolsetDot)) {
+        sep = '.';
+      }
+    }
+    std::string toolsetPath =
+      cmStrCat(toolsetDir, sep, version, "/Microsoft.VCToolsVersion.", version,
+               ".props");
     cmSystemTools::ConvertToUnixSlashes(toolsetPath);
     return toolsetPath;
   }