From 3e7d3c252a5638d66dbbe536be79d6ed3e0e288d Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Wed, 19 May 2021 13:36:30 -0400 Subject: install(TARGETS): Add RUNTIME_DEPENDENCY_SET argument --- Source/cmInstallCommand.cxx | 19 +++++++++++++++++++ Tests/RunCMake/install/RunCMakeTest.cmake | 2 ++ ...DENCY_SET-RUNTIME_DEPENDENCIES-conflict-result.txt | 1 + ...DENCY_SET-RUNTIME_DEPENDENCIES-conflict-stderr.txt | 5 +++++ ...DEPENDENCY_SET-RUNTIME_DEPENDENCIES-conflict.cmake | 7 +++++++ ...GETS-RUNTIME_DEPENDENCY_SET-unsupported-result.txt | 1 + ...GETS-RUNTIME_DEPENDENCY_SET-unsupported-stderr.txt | 5 +++++ .../TARGETS-RUNTIME_DEPENDENCY_SET-unsupported.cmake | 4 ++++ 8 files changed, 44 insertions(+) create mode 100644 Tests/RunCMake/install/TARGETS-RUNTIME_DEPENDENCY_SET-RUNTIME_DEPENDENCIES-conflict-result.txt create mode 100644 Tests/RunCMake/install/TARGETS-RUNTIME_DEPENDENCY_SET-RUNTIME_DEPENDENCIES-conflict-stderr.txt create mode 100644 Tests/RunCMake/install/TARGETS-RUNTIME_DEPENDENCY_SET-RUNTIME_DEPENDENCIES-conflict.cmake create mode 100644 Tests/RunCMake/install/TARGETS-RUNTIME_DEPENDENCY_SET-unsupported-result.txt create mode 100644 Tests/RunCMake/install/TARGETS-RUNTIME_DEPENDENCY_SET-unsupported-stderr.txt create mode 100644 Tests/RunCMake/install/TARGETS-RUNTIME_DEPENDENCY_SET-unsupported.cmake diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index c36778d..5d5a5a6 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -413,12 +413,14 @@ bool HandleTargetsMode(std::vector const& args, std::vector targetList; std::string exports; std::vector runtimeDependenciesArgVector; + std::string runtimeDependencySetArg; std::vector unknownArgs; std::vector parsedArgs; cmInstallCommandArguments genericArgs(helper.DefaultComponentName); genericArgs.Bind("TARGETS"_s, targetList); genericArgs.Bind("EXPORT"_s, exports); genericArgs.Bind("RUNTIME_DEPENDENCIES"_s, runtimeDependenciesArgVector); + genericArgs.Bind("RUNTIME_DEPENDENCY_SET"_s, runtimeDependencySetArg); genericArgs.Parse(genericArgVector, &unknownArgs, nullptr, &parsedArgs); bool success = genericArgs.Finalize(); @@ -537,6 +539,11 @@ bool HandleTargetsMode(std::vector const& args, cmInstallRuntimeDependencySet* runtimeDependencySet = nullptr; if (withRuntimeDependencies) { + if (!runtimeDependencySetArg.empty()) { + status.SetError("TARGETS cannot have both RUNTIME_DEPENDENCIES and " + "RUNTIME_DEPENDENCY_SET."); + return false; + } auto system = helper.Makefile->GetSafeDefinition("CMAKE_HOST_SYSTEM_NAME"); if (!cmRuntimeDependencyArchive::PlatformSupportsRuntimeDependencies( system)) { @@ -559,6 +566,18 @@ bool HandleTargetsMode(std::vector const& args, } runtimeDependencySet = helper.Makefile->GetGlobalGenerator() ->CreateAnonymousRuntimeDependencySet(); + } else if (!runtimeDependencySetArg.empty()) { + auto system = helper.Makefile->GetSafeDefinition("CMAKE_HOST_SYSTEM_NAME"); + if (!cmRuntimeDependencyArchive::PlatformSupportsRuntimeDependencies( + system)) { + status.SetError(cmStrCat( + "TARGETS RUNTIME_DEPENDENCY_SET is not supported on system \"", system, + '"')); + return false; + } + runtimeDependencySet = + helper.Makefile->GetGlobalGenerator()->GetNamedRuntimeDependencySet( + runtimeDependencySetArg); } // Select the mode for installing symlinks to versioned shared libraries. diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake index 0f6ec70..bfd01ac 100644 --- a/Tests/RunCMake/install/RunCMakeTest.cmake +++ b/Tests/RunCMake/install/RunCMakeTest.cmake @@ -185,8 +185,10 @@ if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|Darwin|Windows)$") set(RunCMake_TEST_OPTIONS "-DCMAKE_SYSTEM_NAME:STRING=${CMAKE_SYSTEM_NAME}") run_cmake(TARGETS-RUNTIME_DEPENDENCIES-cross) unset(RunCMake_TEST_OPTIONS) + run_cmake(TARGETS-RUNTIME_DEPENDENCY_SET-RUNTIME_DEPENDENCIES-conflict) else() run_cmake(TARGETS-RUNTIME_DEPENDENCIES-unsupported) + run_cmake(TARGETS-RUNTIME_DEPENDENCY_SET-unsupported) endif() set(run_install_test_components 1) diff --git a/Tests/RunCMake/install/TARGETS-RUNTIME_DEPENDENCY_SET-RUNTIME_DEPENDENCIES-conflict-result.txt b/Tests/RunCMake/install/TARGETS-RUNTIME_DEPENDENCY_SET-RUNTIME_DEPENDENCIES-conflict-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-RUNTIME_DEPENDENCY_SET-RUNTIME_DEPENDENCIES-conflict-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/install/TARGETS-RUNTIME_DEPENDENCY_SET-RUNTIME_DEPENDENCIES-conflict-stderr.txt b/Tests/RunCMake/install/TARGETS-RUNTIME_DEPENDENCY_SET-RUNTIME_DEPENDENCIES-conflict-stderr.txt new file mode 100644 index 0000000..e2484ec --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-RUNTIME_DEPENDENCY_SET-RUNTIME_DEPENDENCIES-conflict-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at TARGETS-RUNTIME_DEPENDENCY_SET-RUNTIME_DEPENDENCIES-conflict\.cmake:[0-9]+ \(install\): + install TARGETS cannot have both RUNTIME_DEPENDENCIES and + RUNTIME_DEPENDENCY_SET\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/install/TARGETS-RUNTIME_DEPENDENCY_SET-RUNTIME_DEPENDENCIES-conflict.cmake b/Tests/RunCMake/install/TARGETS-RUNTIME_DEPENDENCY_SET-RUNTIME_DEPENDENCIES-conflict.cmake new file mode 100644 index 0000000..f373b3b --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-RUNTIME_DEPENDENCY_SET-RUNTIME_DEPENDENCIES-conflict.cmake @@ -0,0 +1,7 @@ +enable_language(C) + +add_executable(exe main.c) +install(TARGETS exe + RUNTIME_DEPENDENCY_SET deps + RUNTIME_DEPENDENCIES + ) diff --git a/Tests/RunCMake/install/TARGETS-RUNTIME_DEPENDENCY_SET-unsupported-result.txt b/Tests/RunCMake/install/TARGETS-RUNTIME_DEPENDENCY_SET-unsupported-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-RUNTIME_DEPENDENCY_SET-unsupported-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/install/TARGETS-RUNTIME_DEPENDENCY_SET-unsupported-stderr.txt b/Tests/RunCMake/install/TARGETS-RUNTIME_DEPENDENCY_SET-unsupported-stderr.txt new file mode 100644 index 0000000..f660346 --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-RUNTIME_DEPENDENCY_SET-unsupported-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at TARGETS-RUNTIME_DEPENDENCY_SET-unsupported\.cmake:[0-9]+ \(install\): + install TARGETS 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/TARGETS-RUNTIME_DEPENDENCY_SET-unsupported.cmake b/Tests/RunCMake/install/TARGETS-RUNTIME_DEPENDENCY_SET-unsupported.cmake new file mode 100644 index 0000000..be0f507 --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-RUNTIME_DEPENDENCY_SET-unsupported.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_executable(exe main.c) +install(TARGETS exe RUNTIME_DEPENDENCY_SET deps) -- cgit v0.12