Browse Source

install(IMPORTED_RUNTIME_ARTIFACTS): Add RUNTIME_DEPENDENCY_SET option

Kyle Edwards 4 years ago
parent
commit
bc8a4a06a4

+ 40 - 1
Source/cmInstallCommand.cxx

@@ -1098,9 +1098,11 @@ bool HandleImportedRuntimeArtifactsMode(std::vector<std::string> const& args,
   // now parse the generic args (i.e. the ones not specialized on LIBRARY,
   // RUNTIME etc. (see above)
   std::vector<std::string> targetList;
+  std::string runtimeDependencySetArg;
   std::vector<std::string> unknownArgs;
   cmInstallCommandArguments genericArgs(helper.DefaultComponentName);
-  genericArgs.Bind("IMPORTED_RUNTIME_ARTIFACTS"_s, targetList);
+  genericArgs.Bind("IMPORTED_RUNTIME_ARTIFACTS"_s, targetList)
+    .Bind("RUNTIME_DEPENDENCY_SET"_s, runtimeDependencySetArg);
   genericArgs.Parse(genericArgVector, &unknownArgs);
   bool success = genericArgs.Finalize();
 
@@ -1139,6 +1141,22 @@ bool HandleImportedRuntimeArtifactsMode(std::vector<std::string> const& args,
     return false;
   }
 
+  cmInstallRuntimeDependencySet* runtimeDependencySet = nullptr;
+  if (!runtimeDependencySetArg.empty()) {
+    auto system = helper.Makefile->GetSafeDefinition("CMAKE_HOST_SYSTEM_NAME");
+    if (!cmRuntimeDependencyArchive::PlatformSupportsRuntimeDependencies(
+          system)) {
+      status.SetError(
+        cmStrCat("IMPORTED_RUNTIME_ARTIFACTS RUNTIME_DEPENDENCY_SET is not "
+                 "supported on system \"",
+                 system, '"'));
+      return false;
+    }
+    runtimeDependencySet =
+      helper.Makefile->GetGlobalGenerator()->GetNamedRuntimeDependencySet(
+        runtimeDependencySetArg);
+  }
+
   // Check if there is something to do.
   if (targetList.empty()) {
     return true;
@@ -1217,6 +1235,9 @@ bool HandleImportedRuntimeArtifactsMode(std::vector<std::string> const& args,
         if (target.IsDLLPlatform()) {
           runtimeGenerator = createInstallGenerator(
             target, runtimeArgs, helper.GetRuntimeDestination(&runtimeArgs));
+          if (runtimeDependencySet) {
+            runtimeDependencySet->AddLibrary(runtimeGenerator.get());
+          }
         } else if (target.IsFrameworkOnApple()) {
           if (frameworkArgs.GetDestination().empty()) {
             status.SetError(cmStrCat("IMPORTED_RUNTIME_ARTIFACTS given no "
@@ -1227,14 +1248,23 @@ bool HandleImportedRuntimeArtifactsMode(std::vector<std::string> const& args,
           }
           frameworkGenerator = createInstallGenerator(
             target, frameworkArgs, frameworkArgs.GetDestination());
+          if (runtimeDependencySet) {
+            runtimeDependencySet->AddLibrary(frameworkGenerator.get());
+          }
         } else {
           libraryGenerator = createInstallGenerator(
             target, libraryArgs, helper.GetLibraryDestination(&libraryArgs));
+          if (runtimeDependencySet) {
+            runtimeDependencySet->AddLibrary(libraryGenerator.get());
+          }
         }
         break;
       case cmStateEnums::MODULE_LIBRARY:
         libraryGenerator = createInstallGenerator(
           target, libraryArgs, helper.GetLibraryDestination(&libraryArgs));
+        if (runtimeDependencySet) {
+          runtimeDependencySet->AddModule(libraryGenerator.get());
+        }
         break;
       case cmStateEnums::EXECUTABLE:
         if (target.IsAppBundleOnApple()) {
@@ -1247,9 +1277,18 @@ bool HandleImportedRuntimeArtifactsMode(std::vector<std::string> const& args,
           }
           bundleGenerator = createInstallGenerator(
             target, bundleArgs, bundleArgs.GetDestination());
+          if (runtimeDependencySet) {
+            if (!AddBundleExecutable(helper, runtimeDependencySet,
+                                     bundleGenerator.get())) {
+              return false;
+            }
+          }
         } else {
           runtimeGenerator = createInstallGenerator(
             target, runtimeArgs, helper.GetRuntimeDestination(&runtimeArgs));
+          if (runtimeDependencySet) {
+            runtimeDependencySet->AddExecutable(runtimeGenerator.get());
+          }
         }
         break;
       default:

+ 1 - 0
Tests/RunCMake/install/IMPORTED_RUNTIME_ARTIFACTS-RUNTIME_DEPENDENCY_SET-unsupported-result.txt

@@ -0,0 +1 @@
+1

+ 6 - 0
Tests/RunCMake/install/IMPORTED_RUNTIME_ARTIFACTS-RUNTIME_DEPENDENCY_SET-unsupported-stderr.txt

@@ -0,0 +1,6 @@
+^CMake Error at IMPORTED_RUNTIME_ARTIFACTS-RUNTIME_DEPENDENCY_SET-unsupported\.cmake:[0-9]+ \(install\):
+  install IMPORTED_RUNTIME_ARTIFACTS RUNTIME_DEPENDENCY_SET is not supported
+  on system "[^
+]*"
+Call Stack \(most recent call first\):
+  CMakeLists\.txt:[0-9]+ \(include\)$

+ 2 - 0
Tests/RunCMake/install/IMPORTED_RUNTIME_ARTIFACTS-RUNTIME_DEPENDENCY_SET-unsupported.cmake

@@ -0,0 +1,2 @@
+add_executable(exe IMPORTED)
+install(IMPORTED_RUNTIME_ARTIFACTS exe RUNTIME_DEPENDENCY_SET deps)

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

@@ -189,6 +189,7 @@ if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|Darwin|Windows)$")
 else()
   run_cmake(TARGETS-RUNTIME_DEPENDENCIES-unsupported)
   run_cmake(TARGETS-RUNTIME_DEPENDENCY_SET-unsupported)
+  run_cmake(IMPORTED_RUNTIME_ARTIFACTS-RUNTIME_DEPENDENCY_SET-unsupported)
 endif()
 
 set(run_install_test_components 1)