diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2021-05-19 19:06:15 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2021-06-04 12:52:02 (GMT) |
commit | 4910132d8c94ac2c08fddd3fafc79585e7423362 (patch) | |
tree | d30bb40f25667cf5c43da2dc1450c2db5a871e66 | |
parent | bc8a4a06a488a0cfd260901acf189e91c8906dbd (diff) | |
download | CMake-4910132d8c94ac2c08fddd3fafc79585e7423362.zip CMake-4910132d8c94ac2c08fddd3fafc79585e7423362.tar.gz CMake-4910132d8c94ac2c08fddd3fafc79585e7423362.tar.bz2 |
install: Add RUNTIME_DEPENDENCY_SET mode
5 files changed, 123 insertions, 0 deletions
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 67451aa..79109b5 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -1942,6 +1942,120 @@ bool HandleExportMode(std::vector<std::string> const& args, return true; } +bool HandleRuntimeDependencySetMode(std::vector<std::string> const& args, + cmExecutionStatus& status) +{ + Helper helper(status); + + auto system = helper.Makefile->GetSafeDefinition("CMAKE_HOST_SYSTEM_NAME"); + if (!cmRuntimeDependencyArchive::PlatformSupportsRuntimeDependencies( + system)) { + status.SetError(cmStrCat( + "RUNTIME_DEPENDENCY_SET is not supported on system \"", system, '"')); + return false; + } + + // This is the RUNTIME_DEPENDENCY_SET mode. + cmInstallRuntimeDependencySet* runtimeDependencySet; + + struct ArgVectors + { + std::vector<std::string> Library; + std::vector<std::string> Runtime; + std::vector<std::string> Framework; + }; + + static auto const argHelper = cmArgumentParser<ArgVectors>{} + .Bind("LIBRARY"_s, &ArgVectors::Library) + .Bind("RUNTIME"_s, &ArgVectors::Runtime) + .Bind("FRAMEWORK"_s, &ArgVectors::Framework); + + std::vector<std::string> genericArgVector; + ArgVectors const argVectors = argHelper.Parse(args, &genericArgVector); + + // now parse the generic args (i.e. the ones not specialized on LIBRARY, + // RUNTIME, FRAMEWORK etc. (see above) + // These generic args also contain the runtime dependency set + std::string runtimeDependencySetArg; + std::vector<std::string> runtimeDependencyArgVector; + std::vector<std::string> parsedArgs; + cmInstallCommandArguments genericArgs(helper.DefaultComponentName); + genericArgs.Bind("RUNTIME_DEPENDENCY_SET"_s, runtimeDependencySetArg); + genericArgs.Parse(genericArgVector, &runtimeDependencyArgVector, nullptr, + &parsedArgs); + bool success = genericArgs.Finalize(); + + cmInstallCommandArguments libraryArgs(helper.DefaultComponentName); + cmInstallCommandArguments runtimeArgs(helper.DefaultComponentName); + cmInstallCommandArguments frameworkArgs(helper.DefaultComponentName); + + // Now also parse the file(GET_RUNTIME_DEPENDENCY) args + std::vector<std::string> unknownArgs; + auto runtimeDependencyArgs = RuntimeDependenciesArgHelper.Parse( + runtimeDependencyArgVector, &unknownArgs); + + // now parse the args for specific parts of the target (e.g. LIBRARY, + // RUNTIME, FRAMEWORK etc. + libraryArgs.Parse(argVectors.Library, &unknownArgs); + runtimeArgs.Parse(argVectors.Runtime, &unknownArgs); + frameworkArgs.Parse(argVectors.Framework, &unknownArgs); + + libraryArgs.SetGenericArguments(&genericArgs); + runtimeArgs.SetGenericArguments(&genericArgs); + frameworkArgs.SetGenericArguments(&genericArgs); + + success = success && libraryArgs.Finalize(); + success = success && runtimeArgs.Finalize(); + success = success && frameworkArgs.Finalize(); + + if (!success) { + return false; + } + + if (!unknownArgs.empty()) { + helper.SetError( + cmStrCat("RUNTIME_DEPENDENCY_SET given unknown argument \"", + unknownArgs.front(), "\".")); + return false; + } + + if (runtimeDependencySetArg.empty()) { + helper.SetError( + "RUNTIME_DEPENDENCY_SET not given a runtime dependency set."); + return false; + } + + runtimeDependencySet = + helper.Makefile->GetGlobalGenerator()->GetNamedRuntimeDependencySet( + runtimeDependencySetArg); + + bool installsRuntime = false; + bool installsLibrary = false; + bool installsFramework = false; + + AddInstallRuntimeDependenciesGenerator( + helper, runtimeDependencySet, runtimeArgs, libraryArgs, frameworkArgs, + std::move(runtimeDependencyArgs), installsRuntime, installsLibrary, + installsFramework); + + // Tell the global generator about any installation component names + // specified + if (installsLibrary) { + helper.Makefile->GetGlobalGenerator()->AddInstallComponent( + libraryArgs.GetComponent()); + } + if (installsRuntime) { + helper.Makefile->GetGlobalGenerator()->AddInstallComponent( + runtimeArgs.GetComponent()); + } + if (installsFramework) { + helper.Makefile->GetGlobalGenerator()->AddInstallComponent( + frameworkArgs.GetComponent()); + } + + return true; +} + bool Helper::MakeFilesFullPath(const char* modeName, const std::vector<std::string>& relFiles, std::vector<std::string>& absFiles) @@ -2176,6 +2290,7 @@ bool cmInstallCommand(std::vector<std::string> const& args, { "DIRECTORY"_s, HandleDirectoryMode }, { "EXPORT"_s, HandleExportMode }, { "EXPORT_ANDROID_MK"_s, HandleExportAndroidMKMode }, + { "RUNTIME_DEPENDENCY_SET"_s, HandleRuntimeDependencySetMode }, }; return subcommand(args[0], args, status); diff --git a/Tests/RunCMake/install/RUNTIME_DEPENDENCY_SET-unsupported-result.txt b/Tests/RunCMake/install/RUNTIME_DEPENDENCY_SET-unsupported-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/install/RUNTIME_DEPENDENCY_SET-unsupported-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/install/RUNTIME_DEPENDENCY_SET-unsupported-stderr.txt b/Tests/RunCMake/install/RUNTIME_DEPENDENCY_SET-unsupported-stderr.txt new file mode 100644 index 0000000..cab309b --- /dev/null +++ b/Tests/RunCMake/install/RUNTIME_DEPENDENCY_SET-unsupported-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at RUNTIME_DEPENDENCY_SET-unsupported\.cmake:[0-9]+ \(install\): + install 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/RUNTIME_DEPENDENCY_SET-unsupported.cmake b/Tests/RunCMake/install/RUNTIME_DEPENDENCY_SET-unsupported.cmake new file mode 100644 index 0000000..60772a0 --- /dev/null +++ b/Tests/RunCMake/install/RUNTIME_DEPENDENCY_SET-unsupported.cmake @@ -0,0 +1 @@ +install(RUNTIME_DEPENDENCY_SET deps) diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake index 6f6a193..e9a29c4 100644 --- a/Tests/RunCMake/install/RunCMakeTest.cmake +++ b/Tests/RunCMake/install/RunCMakeTest.cmake @@ -190,6 +190,7 @@ else() run_cmake(TARGETS-RUNTIME_DEPENDENCIES-unsupported) run_cmake(TARGETS-RUNTIME_DEPENDENCY_SET-unsupported) run_cmake(IMPORTED_RUNTIME_ARTIFACTS-RUNTIME_DEPENDENCY_SET-unsupported) + run_cmake(RUNTIME_DEPENDENCY_SET-unsupported) endif() set(run_install_test_components 1) |