1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
3 #include "cmInstallTargetsCommand.h"
5 #include <unordered_map>
8 #include "cmExecutionStatus.h"
9 #include "cmGlobalGenerator.h"
10 #include "cmMakefile.h"
13 bool cmInstallTargetsCommand(std::vector<std::string> const& args,
14 cmExecutionStatus& status)
16 if (args.size() < 2) {
17 status.SetError("called with incorrect number of arguments");
21 cmMakefile& mf = status.GetMakefile();
23 // Enable the install target.
24 mf.GetGlobalGenerator()->EnableInstallTarget();
26 cmMakefile::cmTargetMap& tgts = mf.GetTargets();
27 auto s = args.begin();
29 std::string runtime_dir = "/bin";
30 for (; s != args.end(); ++s) {
31 if (*s == "RUNTIME_DIRECTORY") {
33 if (s == args.end()) {
34 status.SetError("called with RUNTIME_DIRECTORY but no actual "
41 auto ti = tgts.find(*s);
42 if (ti != tgts.end()) {
43 ti->second.SetInstallPath(args[0]);
44 ti->second.SetRuntimeInstallPath(runtime_dir);
45 ti->second.SetHaveInstallRule(true);
47 std::string str = "Cannot find target: \"" + *s + "\" to install.";
54 mf.GetGlobalGenerator()->AddInstallComponent(
55 mf.GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"));