| 11 | #include "cmTarget.h" |
| 12 | |
| 13 | bool cmInstallTargetsCommand(std::vector<std::string> const& args, |
| 14 | cmExecutionStatus& status) |
| 15 | { |
| 16 | if (args.size() < 2) { |
| 17 | status.SetError("called with incorrect number of arguments"); |
| 18 | return false; |
| 19 | } |
| 20 | |
| 21 | cmMakefile& mf = status.GetMakefile(); |
| 22 | |
| 23 | // Enable the install target. |
| 24 | mf.GetGlobalGenerator()->EnableInstallTarget(); |
| 25 | |
| 26 | cmMakefile::cmTargetMap& tgts = mf.GetTargets(); |
| 27 | auto s = args.begin(); |
| 28 | ++s; |
| 29 | std::string runtime_dir = "/bin"; |
| 30 | for (; s != args.end(); ++s) { |
| 31 | if (*s == "RUNTIME_DIRECTORY") { |
| 32 | ++s; |
| 33 | if (s == args.end()) { |
| 34 | status.SetError("called with RUNTIME_DIRECTORY but no actual " |
| 35 | "directory"); |
| 36 | return false; |
| 37 | } |
| 38 | |
| 39 | runtime_dir = *s; |
| 40 | } else { |
| 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); |
| 46 | } else { |
| 47 | std::string str = "Cannot find target: \"" + *s + "\" to install."; |
| 48 | status.SetError(str); |
| 49 | return false; |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | mf.GetGlobalGenerator()->AddInstallComponent( |
| 55 | mf.GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME")); |
| 56 | |
| 57 | return true; |
| 58 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…