瀏覽代碼

install(PACKAGE_INFO): Record COMPONENT in global COMPONENTS list

Fixes: #27249
F. Pichot 1 月之前
父節點
當前提交
a20e9569f1

+ 5 - 0
Source/cmInstallCommand.cxx

@@ -2205,6 +2205,11 @@ bool HandlePackageInfoMode(std::vector<std::string> const& args,
   cmInstallGenerator::MessageLevel message =
     cmInstallGenerator::SelectMessageLevel(helper.Makefile);
 
+  // Tell the global generator about any installation component names
+  // specified
+  helper.Makefile->GetGlobalGenerator()->AddInstallComponent(
+    ica.GetComponent());
+
   // Create the export install generator.
   helper.Makefile->AddInstallGenerator(
     cm::make_unique<cmInstallPackageInfoExportGenerator>(

+ 1 - 0
Tests/RunCMake/InstallPackageInfo/Component-stdout.txt

@@ -0,0 +1 @@
+-- COMPONENTS='Unspecified;cps'

+ 6 - 0
Tests/RunCMake/InstallPackageInfo/Component.cmake

@@ -0,0 +1,6 @@
+add_library(foo INTERFACE)
+
+install(TARGETS foo EXPORT foo DESTINATION .)
+install(PACKAGE_INFO foo DESTINATION cps EXPORT foo COMPONENT cps)
+get_cmake_property(components COMPONENTS)
+message(STATUS "COMPONENTS='${components}'")

+ 1 - 0
Tests/RunCMake/InstallPackageInfo/RunCMakeTest.cmake

@@ -38,6 +38,7 @@ run_cmake(DependsMultipleDifferentSets)
 
 # Test functionality
 run_cmake(Appendix)
+run_cmake(Component)
 run_cmake(InterfaceProperties)
 run_cmake(Metadata)
 run_cmake(ProjectMetadata)