diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2021-06-02 14:30:55 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2021-06-04 12:52:02 (GMT) |
commit | bc8a4a06a488a0cfd260901acf189e91c8906dbd (patch) | |
tree | 996e09a3cb1e07448fad2627a8d55fa59ab71cd0 | |
parent | 3e7d3c252a5638d66dbbe536be79d6ed3e0e288d (diff) | |
download | CMake-bc8a4a06a488a0cfd260901acf189e91c8906dbd.zip CMake-bc8a4a06a488a0cfd260901acf189e91c8906dbd.tar.gz CMake-bc8a4a06a488a0cfd260901acf189e91c8906dbd.tar.bz2 |
install(IMPORTED_RUNTIME_ARTIFACTS): Add RUNTIME_DEPENDENCY_SET option
5 files changed, 50 insertions, 1 deletions
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 5d5a5a6..67451aa 100644 --- a/Source/cmInstallCommand.cxx +++ b/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: diff --git a/Tests/RunCMake/install/IMPORTED_RUNTIME_ARTIFACTS-RUNTIME_DEPENDENCY_SET-unsupported-result.txt b/Tests/RunCMake/install/IMPORTED_RUNTIME_ARTIFACTS-RUNTIME_DEPENDENCY_SET-unsupported-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/install/IMPORTED_RUNTIME_ARTIFACTS-RUNTIME_DEPENDENCY_SET-unsupported-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/install/IMPORTED_RUNTIME_ARTIFACTS-RUNTIME_DEPENDENCY_SET-unsupported-stderr.txt b/Tests/RunCMake/install/IMPORTED_RUNTIME_ARTIFACTS-RUNTIME_DEPENDENCY_SET-unsupported-stderr.txt new file mode 100644 index 0000000..7ae6606 --- /dev/null +++ b/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\)$ diff --git a/Tests/RunCMake/install/IMPORTED_RUNTIME_ARTIFACTS-RUNTIME_DEPENDENCY_SET-unsupported.cmake b/Tests/RunCMake/install/IMPORTED_RUNTIME_ARTIFACTS-RUNTIME_DEPENDENCY_SET-unsupported.cmake new file mode 100644 index 0000000..04f1995 --- /dev/null +++ b/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) diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake index bfd01ac..6f6a193 100644 --- a/Tests/RunCMake/install/RunCMakeTest.cmake +++ b/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) |