/src/CMake/Source/cmInstallTargetsCommand.cxx
Line | Count | Source |
1 | | /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying |
2 | | file LICENSE.rst or https://cmake.org/licensing for details. */ |
3 | | #include "cmInstallTargetsCommand.h" |
4 | | |
5 | | #include <unordered_map> |
6 | | #include <utility> |
7 | | |
8 | | #include "cmDiagnostics.h" |
9 | | #include "cmExecutionStatus.h" |
10 | | #include "cmGlobalGenerator.h" |
11 | | #include "cmMakefile.h" |
12 | | #include "cmStringAlgorithms.h" |
13 | | #include "cmTarget.h" |
14 | | |
15 | | bool cmInstallTargetsCommand(std::vector<std::string> const& args, |
16 | | cmExecutionStatus& status) |
17 | 0 | { |
18 | 0 | cmMakefile& mf = status.GetMakefile(); |
19 | |
|
20 | 0 | mf.IssueDiagnostic(cmDiagnostics::CMD_DEPRECATED, |
21 | 0 | "The 'install_targets' command has been superseded. " |
22 | 0 | "Use 'install(TARGETS)' instead."); |
23 | |
|
24 | 0 | if (args.size() < 2) { |
25 | 0 | status.SetError("called with incorrect number of arguments"); |
26 | 0 | return false; |
27 | 0 | } |
28 | | |
29 | | // Enable the install target. |
30 | 0 | mf.GetGlobalGenerator()->EnableInstallTarget(); |
31 | |
|
32 | 0 | cmMakefile::cmTargetMap& tgts = mf.GetTargets(); |
33 | 0 | auto s = args.begin(); |
34 | 0 | ++s; |
35 | 0 | std::string runtimeDir = "/bin"; |
36 | 0 | for (; s != args.end(); ++s) { |
37 | 0 | if (*s == "RUNTIME_DIRECTORY") { |
38 | 0 | ++s; |
39 | 0 | if (s == args.end()) { |
40 | 0 | status.SetError("called with RUNTIME_DIRECTORY but no actual " |
41 | 0 | "directory"); |
42 | 0 | return false; |
43 | 0 | } |
44 | | |
45 | 0 | runtimeDir = *s; |
46 | 0 | } else { |
47 | 0 | auto ti = tgts.find(*s); |
48 | 0 | if (ti != tgts.end()) { |
49 | 0 | ti->second.SetInstallPath(args[0]); |
50 | 0 | ti->second.SetRuntimeInstallPath(runtimeDir); |
51 | 0 | ti->second.SetHaveInstallRule(true); |
52 | 0 | } else { |
53 | 0 | status.SetError( |
54 | 0 | cmStrCat("Cannot find target: \"", *s, "\" to install.")); |
55 | 0 | return false; |
56 | 0 | } |
57 | 0 | } |
58 | 0 | } |
59 | | |
60 | 0 | mf.GetGlobalGenerator()->AddInstallComponent( |
61 | 0 | mf.GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME")); |
62 | |
|
63 | 0 | return true; |
64 | 0 | } |