فهرست منبع

Merge branch 'backport-3.15-vs-v142-version' into release-3.15

Merge-request: !4133
Brad King 6 سال پیش
والد
کامیت
b3a536e726
2فایلهای تغییر یافته به همراه15 افزوده شده و 12 حذف شده
  1. 4 3
      Modules/CMakeDetermineCompilerId.cmake
  2. 11 9
      Source/cmGlobalVisualStudioVersionedGenerator.cxx

+ 4 - 3
Modules/CMakeDetermineCompilerId.cmake

@@ -284,10 +284,11 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
           set(id_cl icl.exe)
           set(id_cl icl.exe)
         endif()
         endif()
         if(CMAKE_VS_PLATFORM_TOOLSET_VERSION)
         if(CMAKE_VS_PLATFORM_TOOLSET_VERSION)
+          set(id_sep "\\")
           if(CMAKE_VS_PLATFORM_TOOLSET_VERSION VERSION_GREATER_EQUAL "14.20")
           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()
           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\" />")
           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)
           unset(id_sep)

+ 11 - 9
Source/cmGlobalVisualStudioVersionedGenerator.cxx

@@ -388,15 +388,17 @@ std::string cmGlobalVisualStudioVersionedGenerator::GetAuxiliaryToolset() const
   if (version) {
   if (version) {
     std::string instancePath;
     std::string instancePath;
     GetVSInstance(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 = toolsetDir + "." + version +
+        "/Microsoft.VCToolsVersion." + version + ".props";
+      if (cmSystemTools::PathExists(toolsetDot)) {
+        sep = '.';
+      }
+    }
+    std::string toolsetPath = toolsetDir + sep + version +
+      "/Microsoft.VCToolsVersion." + version + ".props";
     cmSystemTools::ConvertToUnixSlashes(toolsetPath);
     cmSystemTools::ConvertToUnixSlashes(toolsetPath);
     return toolsetPath;
     return toolsetPath;
   }
   }