| 66 | int right); |
| 67 | |
| 68 | bool cmTargetLinkLibrariesCommand(std::vector<std::string> const& args, |
| 69 | cmExecutionStatus& status) |
| 70 | { |
| 71 | // Must have at least one argument. |
| 72 | if (args.empty()) { |
| 73 | status.SetError("called with incorrect number of arguments"); |
| 74 | return false; |
| 75 | } |
| 76 | |
| 77 | cmMakefile& mf = status.GetMakefile(); |
| 78 | |
| 79 | // Alias targets cannot be on the LHS of this command. |
| 80 | if (mf.IsAlias(args[0])) { |
| 81 | status.SetError("can not be used on an ALIAS target."); |
| 82 | return false; |
| 83 | } |
| 84 | |
| 85 | // Lookup the target for which libraries are specified. |
| 86 | cmTarget* target = mf.GetGlobalGenerator()->FindTarget(args[0]); |
| 87 | if (!target) { |
| 88 | for (auto const& importedTarget : mf.GetOwnedImportedTargets()) { |
| 89 | if (importedTarget->GetName() == args[0] && |
| 90 | !importedTarget->IsForeign()) { |
| 91 | target = importedTarget.get(); |
| 92 | break; |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | if (!target) { |
| 97 | mf.IssueMessage(MessageType::FATAL_ERROR, |
| 98 | cmStrCat("Cannot specify link libraries for target \"", |
| 99 | args[0], |
| 100 | "\" which is not built by this project.")); |
| 101 | cmSystemTools::SetFatalErrorOccurred(); |
| 102 | return true; |
| 103 | } |
| 104 | |
| 105 | if (target->IsSymbolic()) { |
| 106 | status.SetError("can not be used on a SYMBOLIC target."); |
| 107 | return false; |
| 108 | } |
| 109 | |
| 110 | // Having a UTILITY library on the LHS is a bug. |
| 111 | if (target->GetType() == cmStateEnums::UTILITY) { |
| 112 | mf.IssueMessage( |
| 113 | MessageType::FATAL_ERROR, |
| 114 | cmStrCat( |
| 115 | "Utility target \"", target->GetName(), |
| 116 | "\" must not be used as the target of a target_link_libraries call.")); |
| 117 | return false; |
| 118 | } |
| 119 | |
| 120 | // But we might not have any libs after variable expansion. |
| 121 | if (args.size() < 2) { |
| 122 | return true; |
| 123 | } |
| 124 | |
| 125 | TLL tll(mf, target); |
nothing calls this directly
no test coverage detected
searching dependent graphs…