瀏覽代碼

Merge topic 'vs-slnx' into release-4.2

0c97912756 VS: Fix SLNX generation so .NET Core projects build in the IDE
7ce9185792 VS: Add include_external_msproject GUIDs for more project types
ab2ef244bd VS: Add include_external_msproject detection of `.njsproj` type
00db01ddcd Tests: Fix RunCMake.include_external_msproject .sln check failure

Acked-by: Kitware Robot <[email protected]>
Acked-by: Christian Lichtenberger <[email protected]>
Merge-request: !11613
Brad King 2 天之前
父節點
當前提交
2660f5fbb4

+ 3 - 0
Source/cmGlobalVisualStudioGenerator.cxx

@@ -798,6 +798,9 @@ cm::string_view cmGlobalVisualStudioGenerator::ExternalProjectTypeId(
   if (extension == ".dbproj"_s) {
   if (extension == ".dbproj"_s) {
     return Solution::Project::TypeIdDatabase;
     return Solution::Project::TypeIdDatabase;
   }
   }
+  if (extension == ".njsproj"_s) {
+    return Solution::Project::TypeIdNodeJS;
+  }
   if (extension == ".wapproj"_s) {
   if (extension == ".wapproj"_s) {
     return Solution::Project::TypeIdWinAppPkg;
     return Solution::Project::TypeIdWinAppPkg;
   }
   }

+ 27 - 3
Source/cmVSSolution.cxx

@@ -17,22 +17,36 @@
 namespace cm {
 namespace cm {
 namespace VS {
 namespace VS {
 
 
+cm::string_view const Solution::Project::TypeIdAspNetCore =
+  "8BB2217D-0F2D-49D1-97BC-3654ED321F3B"_s;
 cm::string_view const Solution::Project::TypeIdCSharp =
 cm::string_view const Solution::Project::TypeIdCSharp =
   "FAE04EC0-301F-11D3-BF4B-00C04F79EFBC"_s;
   "FAE04EC0-301F-11D3-BF4B-00C04F79EFBC"_s;
 cm::string_view const Solution::Project::TypeIdDatabase =
 cm::string_view const Solution::Project::TypeIdDatabase =
   "C8D11400-126E-41CD-887F-60BD40844F9E"_s;
   "C8D11400-126E-41CD-887F-60BD40844F9E"_s;
 cm::string_view const Solution::Project::TypeIdDefault =
 cm::string_view const Solution::Project::TypeIdDefault =
   "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942"_s;
   "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942"_s;
+cm::string_view const Solution::Project::TypeIdDotNetCore =
+  "9A19103F-16F7-4668-BE54-9A1E7A4F7556"_s;
 cm::string_view const Solution::Project::TypeIdFSharp =
 cm::string_view const Solution::Project::TypeIdFSharp =
   "F2A71F9B-5D33-465A-A702-920D77279786"_s;
   "F2A71F9B-5D33-465A-A702-920D77279786"_s;
 cm::string_view const Solution::Project::TypeIdFortran =
 cm::string_view const Solution::Project::TypeIdFortran =
   "6989167D-11E4-40FE-8C1A-2192A86A7E90"_s;
   "6989167D-11E4-40FE-8C1A-2192A86A7E90"_s;
+cm::string_view const Solution::Project::TypeIdJScript =
+  "262852C6-CD72-467D-83FE-5EEB1973A190"_s;
+cm::string_view const Solution::Project::TypeIdMisc =
+  "66A2671D-8FB5-11D2-AA7E-00C04F688DDE"_s;
+cm::string_view const Solution::Project::TypeIdNodeJS =
+  "9092AA53-FB77-4645-B42D-1CCCA6BD08BD"_s;
 cm::string_view const Solution::Project::TypeIdPython =
 cm::string_view const Solution::Project::TypeIdPython =
   "888888A0-9F3D-457C-B088-3A5042F75D52"_s;
   "888888A0-9F3D-457C-B088-3A5042F75D52"_s;
+cm::string_view const Solution::Project::TypeIdSqlSrv =
+  "00D1A9C2-B5F0-4AF3-8072-F6C62B433612"_s;
 cm::string_view const Solution::Project::TypeIdVDProj =
 cm::string_view const Solution::Project::TypeIdVDProj =
   "54435603-DBB4-11D2-8724-00A0C9A8B90C"_s;
   "54435603-DBB4-11D2-8724-00A0C9A8B90C"_s;
 cm::string_view const Solution::Project::TypeIdVisualBasic =
 cm::string_view const Solution::Project::TypeIdVisualBasic =
   "F184B08F-C81C-45F6-A57F-5ABD9991F28F"_s;
   "F184B08F-C81C-45F6-A57F-5ABD9991F28F"_s;
+cm::string_view const Solution::Project::TypeIdWebSite =
+  "E24C65DC-7377-472B-9ABA-BC803B73C61A"_s;
 cm::string_view const Solution::Project::TypeIdWinAppPkg =
 cm::string_view const Solution::Project::TypeIdWinAppPkg =
   "C7167F0D-BC9F-4E6E-AFE1-012C56B48DB5"_s;
   "C7167F0D-BC9F-4E6E-AFE1-012C56B48DB5"_s;
 cm::string_view const Solution::Project::TypeIdWiX =
 cm::string_view const Solution::Project::TypeIdWiX =
@@ -297,6 +311,18 @@ void WriteSln(std::ostream& sln, Solution const& solution)
 }
 }
 
 
 namespace {
 namespace {
+
+bool NeedExplicitProjectPlatform(cm::string_view typeId)
+{
+  // Some projects do not build interactively in the VS IDE unless they
+  // have an explicit platform, even if it matches the SLN platform.
+  if (typeId == Solution::Project::TypeIdCSharp ||
+      typeId == Solution::Project::TypeIdDotNetCore) {
+    return true;
+  }
+  return false;
+}
+
 void WriteSlnxSolutionConfigurationPlatforms(cmXMLElement& xmlParent,
 void WriteSlnxSolutionConfigurationPlatforms(cmXMLElement& xmlParent,
                                              Solution const& solution)
                                              Solution const& solution)
 {
 {
@@ -339,9 +365,7 @@ void WriteSlnxProject(cmXMLElement& xmlParent, Solution const& solution,
     }
     }
   }
   }
   if (project.Platform != solution.Platform ||
   if (project.Platform != solution.Platform ||
-      // C# projects do not build interactively in the VS IDE unless they
-      // have an explicit platform, even if it matches the SLN platform.
-      project.TypeId == Solution::Project::TypeIdCSharp) {
+      NeedExplicitProjectPlatform(project.TypeId)) {
     cmXMLElement(xmlProject, "Platform")
     cmXMLElement(xmlProject, "Platform")
       .Attribute("Project", project.Platform);
       .Attribute("Project", project.Platform);
   }
   }

+ 7 - 0
Source/cmVSSolution.h

@@ -70,14 +70,21 @@ struct Solution final
     std::vector<Project const*> BuildDependencies;
     std::vector<Project const*> BuildDependencies;
 
 
     // Project type GUIDs used during creation.
     // Project type GUIDs used during creation.
+    static cm::string_view const TypeIdAspNetCore;
     static cm::string_view const TypeIdCSharp;
     static cm::string_view const TypeIdCSharp;
     static cm::string_view const TypeIdDatabase;
     static cm::string_view const TypeIdDatabase;
     static cm::string_view const TypeIdDefault;
     static cm::string_view const TypeIdDefault;
+    static cm::string_view const TypeIdDotNetCore;
     static cm::string_view const TypeIdFSharp;
     static cm::string_view const TypeIdFSharp;
     static cm::string_view const TypeIdFortran;
     static cm::string_view const TypeIdFortran;
+    static cm::string_view const TypeIdJScript;
+    static cm::string_view const TypeIdMisc;
+    static cm::string_view const TypeIdNodeJS;
     static cm::string_view const TypeIdPython;
     static cm::string_view const TypeIdPython;
+    static cm::string_view const TypeIdSqlSrv;
     static cm::string_view const TypeIdVDProj;
     static cm::string_view const TypeIdVDProj;
     static cm::string_view const TypeIdVisualBasic;
     static cm::string_view const TypeIdVisualBasic;
+    static cm::string_view const TypeIdWebSite;
     static cm::string_view const TypeIdWinAppPkg;
     static cm::string_view const TypeIdWinAppPkg;
     static cm::string_view const TypeIdWiX;
     static cm::string_view const TypeIdWiX;
   };
   };

+ 1 - 0
Tests/RunCMake/include_external_msproject/AutoType-check-sln.cmake

@@ -1,6 +1,7 @@
 check_project(AutoType externalCS  "" "FAE04EC0-301F-11D3-BF4B-00C04F79EFBC" "" "")
 check_project(AutoType externalCS  "" "FAE04EC0-301F-11D3-BF4B-00C04F79EFBC" "" "")
 check_project(AutoType externalDB  "" "C8D11400-126E-41CD-887F-60BD40844F9E" "" "")
 check_project(AutoType externalDB  "" "C8D11400-126E-41CD-887F-60BD40844F9E" "" "")
 check_project(AutoType externalFS  "" "F2A71F9B-5D33-465A-A702-920D77279786" "" "")
 check_project(AutoType externalFS  "" "F2A71F9B-5D33-465A-A702-920D77279786" "" "")
+check_project(AutoType externalNJS "" "9092AA53-FB77-4645-B42D-1CCCA6BD08BD" "" "")
 check_project(AutoType externalPy  "" "888888A0-9F3D-457C-B088-3A5042F75D52" "" "")
 check_project(AutoType externalPy  "" "888888A0-9F3D-457C-B088-3A5042F75D52" "" "")
 check_project(AutoType externalVB  "" "F184B08F-C81C-45F6-A57F-5ABD9991F28F" "" "")
 check_project(AutoType externalVB  "" "F184B08F-C81C-45F6-A57F-5ABD9991F28F" "" "")
 check_project(AutoType externalVD  "" "54435603-DBB4-11D2-8724-00A0C9A8B90C" "" "")
 check_project(AutoType externalVD  "" "54435603-DBB4-11D2-8724-00A0C9A8B90C" "" "")

+ 4 - 0
Tests/RunCMake/include_external_msproject/AutoType-check-slnx.cmake

@@ -13,6 +13,7 @@ RunCMake_check_slnx("${RunCMake_TEST_BINARY_DIR}/AutoType.slnx" [[
     <BuildDependency Project="external\.csproj"/>
     <BuildDependency Project="external\.csproj"/>
     <BuildDependency Project="external\.dbproj"/>
     <BuildDependency Project="external\.dbproj"/>
     <BuildDependency Project="external\.fsproj"/>
     <BuildDependency Project="external\.fsproj"/>
+    <BuildDependency Project="external\.njsproj"/>
     <BuildDependency Project="external\.pyproj"/>
     <BuildDependency Project="external\.pyproj"/>
     <BuildDependency Project="external\.vbproj"/>
     <BuildDependency Project="external\.vbproj"/>
     <BuildDependency Project="external\.vdproj"/>
     <BuildDependency Project="external\.vdproj"/>
@@ -35,6 +36,9 @@ RunCMake_check_slnx("${RunCMake_TEST_BINARY_DIR}/AutoType.slnx" [[
   <Project Path="external\.fsproj" Type="f2a71f9b-5d33-465a-a702-920d77279786" Id="[0-9a-f-]+">
   <Project Path="external\.fsproj" Type="f2a71f9b-5d33-465a-a702-920d77279786" Id="[0-9a-f-]+">
     <BuildDependency Project="ZERO_CHECK.vcxproj"/>
     <BuildDependency Project="ZERO_CHECK.vcxproj"/>
   </Project>
   </Project>
+  <Project Path="external\.njsproj" Type="9092aa53-fb77-4645-b42d-1ccca6bd08bd" Id="[0-9a-f-]+">
+    <BuildDependency Project="ZERO_CHECK.vcxproj"/>
+  </Project>
   <Project Path="external\.pyproj" Type="888888a0-9f3d-457c-b088-3a5042f75d52" Id="[0-9a-f-]+">
   <Project Path="external\.pyproj" Type="888888a0-9f3d-457c-b088-3a5042f75d52" Id="[0-9a-f-]+">
     <BuildDependency Project="ZERO_CHECK.vcxproj"/>
     <BuildDependency Project="ZERO_CHECK.vcxproj"/>
   </Project>
   </Project>

+ 1 - 0
Tests/RunCMake/include_external_msproject/AutoType.cmake

@@ -2,6 +2,7 @@ include_external_msproject(externalCS  external.csproj)
 include_external_msproject(externalDB  external.dbproj)
 include_external_msproject(externalDB  external.dbproj)
 include_external_msproject(externalFS  external.fsproj)
 include_external_msproject(externalFS  external.fsproj)
 include_external_msproject(externalPy  external.pyproj)
 include_external_msproject(externalPy  external.pyproj)
+include_external_msproject(externalNJS external.njsproj)
 include_external_msproject(externalVB  external.vbproj)
 include_external_msproject(externalVB  external.vbproj)
 include_external_msproject(externalVD  external.vdproj)
 include_external_msproject(externalVD  external.vdproj)
 include_external_msproject(externalVF  external.vfproj)
 include_external_msproject(externalVF  external.vfproj)

+ 6 - 0
Tests/RunCMake/include_external_msproject/ProjType-check-sln.cmake

@@ -0,0 +1,6 @@
+check_project(ProjType AspNetCore    "" "8BB2217D-0F2D-49D1-97BC-3654ED321F3B" "" "")
+check_project(ProjType DotNetCore    "" "9A19103F-16F7-4668-BE54-9A1E7A4F7556" "" "")
+check_project(ProjType Misc          "" "66A2671D-8FB5-11D2-AA7E-00C04F688DDE" "" "")
+check_project(ProjType SqlSrv        "" "00D1A9C2-B5F0-4AF3-8072-F6C62B433612" "" "")
+check_project(ProjType JScript       "" "262852C6-CD72-467D-83FE-5EEB1973A190" "" "")
+check_project(ProjType WebSite       "" "E24C65DC-7377-472B-9ABA-BC803B73C61A" "" "")

+ 44 - 0
Tests/RunCMake/include_external_msproject/ProjType-check-slnx.cmake

@@ -0,0 +1,44 @@
+RunCMake_check_slnx("${RunCMake_TEST_BINARY_DIR}/ProjType.slnx" [[
+^<\?xml version="1\.0" encoding="UTF-8"\?>
+<Solution>
+  <Configurations>
+    <BuildType Name="Debug"/>
+    <BuildType Name="Release"/>
+    <BuildType Name="MinSizeRel"/>
+    <BuildType Name="RelWithDebInfo"/>
+    <Platform Name="[^"]+"/>
+  </Configurations>
+  <Project Path="ALL_BUILD\.vcxproj" Type="8bc9ceb8-8b4a-11d0-8d11-00a0c91bc942" Id="[0-9a-f-]+" DefaultStartup="true">
+    <BuildDependency Project="AspNetCore\.project"/>
+    <BuildDependency Project="DotNetCore\.project"/>
+    <BuildDependency Project="JScript\.project"/>
+    <BuildDependency Project="Misc\.project"/>
+    <BuildDependency Project="SqlSrv\.project"/>
+    <BuildDependency Project="WebSite\.project"/>
+    <BuildDependency Project="ZERO_CHECK\.vcxproj"/>
+    <Build Solution="Debug\|\*" Project="false"/>
+    <Build Solution="Release\|\*" Project="false"/>
+    <Build Solution="MinSizeRel\|\*" Project="false"/>
+    <Build Solution="RelWithDebInfo\|\*" Project="false"/>
+  </Project>
+  <Project Path="AspNetCore.project" Type="8bb2217d-0f2d-49d1-97bc-3654ed321f3b" Id="[0-9a-f-]+">
+    <BuildDependency Project="ZERO_CHECK\.vcxproj"/>
+  </Project>
+  <Project Path="DotNetCore.project" Type="9a19103f-16f7-4668-be54-9a1e7a4f7556" Id="[0-9a-f-]+">
+    <BuildDependency Project="ZERO_CHECK\.vcxproj"/>
+    <Platform Project="[^"]+"/>
+  </Project>
+  <Project Path="JScript.project" Type="262852c6-cd72-467d-83fe-5eeb1973a190" Id="[0-9a-f-]+">
+    <BuildDependency Project="ZERO_CHECK\.vcxproj"/>
+  </Project>
+  <Project Path="Misc.project" Type="66a2671d-8fb5-11d2-aa7e-00c04f688dde" Id="[0-9a-f-]+">
+    <BuildDependency Project="ZERO_CHECK\.vcxproj"/>
+  </Project>
+  <Project Path="SqlSrv.project" Type="00d1a9c2-b5f0-4af3-8072-f6c62b433612" Id="[0-9a-f-]+">
+    <BuildDependency Project="ZERO_CHECK\.vcxproj"/>
+  </Project>
+  <Project Path="WebSite.project" Type="e24c65dc-7377-472b-9aba-bc803b73c61a" Id="[0-9a-f-]+">
+    <BuildDependency Project="ZERO_CHECK\.vcxproj"/>
+  </Project>
+  <Project Path="ZERO_CHECK\.vcxproj" Type="8bc9ceb8-8b4a-11d0-8d11-00a0c91bc942" Id="[0-9a-f-]+"/>
+</Solution>$]])

+ 1 - 0
Tests/RunCMake/include_external_msproject/ProjType-check.cmake

@@ -0,0 +1 @@
+include(${CMAKE_CURRENT_LIST_DIR}/ProjType-check-${sln_ext}.cmake)

+ 6 - 0
Tests/RunCMake/include_external_msproject/ProjType.cmake

@@ -0,0 +1,6 @@
+include_external_msproject(AspNetCore    AspNetCore.project    TYPE 8BB2217D-0F2D-49D1-97BC-3654ED321F3B)
+include_external_msproject(DotNetCore    DotNetCore.project    TYPE 9A19103F-16F7-4668-BE54-9A1E7A4F7556)
+include_external_msproject(Misc          Misc.project          TYPE 66A2671D-8FB5-11D2-AA7E-00C04F688DDE)
+include_external_msproject(SqlSrv        SqlSrv.project        TYPE 00D1A9C2-B5F0-4AF3-8072-F6C62B433612)
+include_external_msproject(JScript       JScript.project       TYPE 262852C6-CD72-467D-83FE-5EEB1973A190)
+include_external_msproject(WebSite       WebSite.project       TYPE E24C65DC-7377-472B-9ABA-BC803B73C61A)

+ 2 - 0
Tests/RunCMake/include_external_msproject/RunCMakeTest.cmake

@@ -9,6 +9,8 @@ else()
 endif()
 endif()
 
 
 run_cmake(AutoType)
 run_cmake(AutoType)
+run_cmake(ProjType)
+
 run_cmake(CustomGuid)
 run_cmake(CustomGuid)
 run_cmake(CustomTypePlatform)
 run_cmake(CustomTypePlatform)
 run_cmake(CustomGuidTypePlatform)
 run_cmake(CustomGuidTypePlatform)

+ 5 - 11
Tests/RunCMake/include_external_msproject/check_utils.cmake

@@ -90,8 +90,6 @@ endfunction()
 # RunCMake test check helper
 # RunCMake test check helper
 function(check_project test name guid type platform imported_release_config_name)
 function(check_project test name guid type platform imported_release_config_name)
   set(sln "${RunCMake_TEST_BINARY_DIR}/${test}.sln")
   set(sln "${RunCMake_TEST_BINARY_DIR}/${test}.sln")
-  set(sep "")
-  set(failed "")
   if(NOT type)
   if(NOT type)
     set(type 8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942)
     set(type 8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942)
   endif()
   endif()
@@ -112,27 +110,23 @@ function(check_project test name guid type platform imported_release_config_name
   if(guid)
   if(guid)
     check_project_guid("${sln}" "${name}" "${guid}" passed_guid)
     check_project_guid("${sln}" "${name}" "${guid}" passed_guid)
     if(NOT passed_guid)
     if(NOT passed_guid)
-      string(APPEND failed "${sep}${name} solution has no project with expected GUID=${guid}")
-      set(sep "\n")
+      string(APPEND RunCMake_TEST_FAILED "${name} solution has no project with expected GUID=${guid}\n")
     endif()
     endif()
   else()
   else()
     set(passed_guid 1)
     set(passed_guid 1)
   endif()
   endif()
   check_project_type("${sln}" "${name}" "${type}" passed_type)
   check_project_type("${sln}" "${name}" "${type}" passed_type)
   if(NOT passed_type)
   if(NOT passed_type)
-    string(APPEND failed "${sep}${name} solution has no project with expected TYPE=${type}")
-    set(sep "\n")
+    string(APPEND RunCMake_TEST_FAILED "${name} solution has no project with expected TYPE=${type}\n")
   endif()
   endif()
   check_custom_platform("${sln}" "${name}" "${platform}" passed_platform)
   check_custom_platform("${sln}" "${name}" "${platform}" passed_platform)
   if(NOT passed_platform)
   if(NOT passed_platform)
-    string(APPEND failed "${sep}${name} solution has no project with expected PLATFORM=${platform}")
-    set(sep "\n")
+    string(APPEND RunCMake_TEST_FAILED "${name} solution has no project with expected PLATFORM=${platform}\n")
   endif()
   endif()
   check_custom_configuration("${sln}" "${name}" "Release" "${imported_release_config_name}" passed_configuration)
   check_custom_configuration("${sln}" "${name}" "Release" "${imported_release_config_name}" passed_configuration)
   if(NOT passed_configuration)
   if(NOT passed_configuration)
-    string(APPEND failed "${sep}${name} solution has no project with expected CONFIG=${imported_release_config_name}")
-    set(sep "\n")
+    string(APPEND RunCMake_TEST_FAILED "${name} solution has no project with expected CONFIG=${imported_release_config_name}\n")
   endif()
   endif()
 
 
-  set(RunCMake_TEST_FAILED "${failed}" PARENT_SCOPE)
+  set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE)
 endfunction()
 endfunction()