From bc8a4a06a488a0cfd260901acf189e91c8906dbd Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Wed, 2 Jun 2021 10:30:55 -0400 Subject: install(IMPORTED_RUNTIME_ARTIFACTS): Add RUNTIME_DEPENDENCY_SET option --- Source/cmInstallCommand.cxx | 41 +++++++++++++++++++++- ...S-RUNTIME_DEPENDENCY_SET-unsupported-result.txt | 1 + ...S-RUNTIME_DEPENDENCY_SET-unsupported-stderr.txt | 6 ++++ ...IFACTS-RUNTIME_DEPENDENCY_SET-unsupported.cmake | 2 ++ Tests/RunCMake/install/RunCMakeTest.cmake | 1 + 5 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 Tests/RunCMake/install/IMPORTED_RUNTIME_ARTIFACTS-RUNTIME_DEPENDENCY_SET-unsupported-result.txt create mode 100644 Tests/RunCMake/install/IMPORTED_RUNTIME_ARTIFACTS-RUNTIME_DEPENDENCY_SET-unsupported-stderr.txt create mode 100644 Tests/RunCMake/install/IMPORTED_RUNTIME_ARTIFACTS-RUNTIME_DEPENDENCY_SET-unsupported.cmake 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 const& args, // now parse the generic args (i.e. the ones not specialized on LIBRARY, // RUNTIME etc. (see above) std::vector targetList; + std::string runtimeDependencySetArg; std::vector 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 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 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 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 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) -- cgit v0.12