cmTargetLinkLibrariesCommand.cxx 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  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 "cmTargetLinkLibrariesCommand.h"
  4. #include <memory>
  5. #include <sstream>
  6. #include <unordered_set>
  7. #include <utility>
  8. #include "cmExecutionStatus.h"
  9. #include "cmGeneratorExpression.h"
  10. #include "cmGlobalGenerator.h"
  11. #include "cmListFileCache.h"
  12. #include "cmMakefile.h"
  13. #include "cmMessageType.h"
  14. #include "cmPolicies.h"
  15. #include "cmState.h"
  16. #include "cmStateTypes.h"
  17. #include "cmStringAlgorithms.h"
  18. #include "cmSystemTools.h"
  19. #include "cmTarget.h"
  20. #include "cmTargetLinkLibraryType.h"
  21. #include "cmValue.h"
  22. #include "cmake.h"
  23. namespace {
  24. enum ProcessingState
  25. {
  26. ProcessingLinkLibraries,
  27. ProcessingPlainLinkInterface,
  28. ProcessingKeywordLinkInterface,
  29. ProcessingPlainPublicInterface,
  30. ProcessingKeywordPublicInterface,
  31. ProcessingPlainPrivateInterface,
  32. ProcessingKeywordPrivateInterface
  33. };
  34. const char* LinkLibraryTypeNames[3] = { "general", "debug", "optimized" };
  35. struct TLL
  36. {
  37. cmMakefile& Makefile;
  38. cmTarget* Target;
  39. bool WarnRemoteInterface = false;
  40. bool RejectRemoteLinking = false;
  41. bool EncodeRemoteReference = false;
  42. std::string DirectoryId;
  43. std::unordered_set<std::string> Props;
  44. TLL(cmMakefile& mf, cmTarget* target);
  45. ~TLL();
  46. bool HandleLibrary(ProcessingState currentProcessingState,
  47. const std::string& lib, cmTargetLinkLibraryType llt);
  48. void AppendProperty(std::string const& prop, std::string const& value);
  49. void AffectsProperty(std::string const& prop);
  50. };
  51. } // namespace
  52. static void LinkLibraryTypeSpecifierWarning(cmMakefile& mf, int left,
  53. int right);
  54. bool cmTargetLinkLibrariesCommand(std::vector<std::string> const& args,
  55. cmExecutionStatus& status)
  56. {
  57. // Must have at least one argument.
  58. if (args.empty()) {
  59. status.SetError("called with incorrect number of arguments");
  60. return false;
  61. }
  62. cmMakefile& mf = status.GetMakefile();
  63. // Alias targets cannot be on the LHS of this command.
  64. if (mf.IsAlias(args[0])) {
  65. status.SetError("can not be used on an ALIAS target.");
  66. return false;
  67. }
  68. // Lookup the target for which libraries are specified.
  69. cmTarget* target =
  70. mf.GetCMakeInstance()->GetGlobalGenerator()->FindTarget(args[0]);
  71. if (!target) {
  72. for (const auto& importedTarget : mf.GetOwnedImportedTargets()) {
  73. if (importedTarget->GetName() == args[0]) {
  74. target = importedTarget.get();
  75. break;
  76. }
  77. }
  78. }
  79. if (!target) {
  80. MessageType t = MessageType::FATAL_ERROR; // fail by default
  81. std::ostringstream e;
  82. e << "Cannot specify link libraries for target \"" << args[0] << "\" "
  83. << "which is not built by this project.";
  84. // The bad target is the only argument. Check how policy CMP0016 is set,
  85. // and accept, warn or fail respectively:
  86. if (args.size() < 2) {
  87. switch (mf.GetPolicyStatus(cmPolicies::CMP0016)) {
  88. case cmPolicies::WARN:
  89. t = MessageType::AUTHOR_WARNING;
  90. // Print the warning.
  91. e << "\n"
  92. << "CMake does not support this but it used to work accidentally "
  93. << "and is being allowed for compatibility."
  94. << "\n"
  95. << cmPolicies::GetPolicyWarning(cmPolicies::CMP0016);
  96. break;
  97. case cmPolicies::OLD: // OLD behavior does not warn.
  98. t = MessageType::MESSAGE;
  99. break;
  100. case cmPolicies::REQUIRED_IF_USED:
  101. case cmPolicies::REQUIRED_ALWAYS:
  102. e << "\n" << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0016);
  103. break;
  104. case cmPolicies::NEW: // NEW behavior prints the error.
  105. break;
  106. }
  107. }
  108. // Now actually print the message.
  109. switch (t) {
  110. case MessageType::AUTHOR_WARNING:
  111. mf.IssueMessage(MessageType::AUTHOR_WARNING, e.str());
  112. break;
  113. case MessageType::FATAL_ERROR:
  114. mf.IssueMessage(MessageType::FATAL_ERROR, e.str());
  115. cmSystemTools::SetFatalErrorOccured();
  116. break;
  117. default:
  118. break;
  119. }
  120. return true;
  121. }
  122. // Having a UTILITY library on the LHS is a bug.
  123. if (target->GetType() == cmStateEnums::UTILITY) {
  124. std::ostringstream e;
  125. const char* modal = nullptr;
  126. MessageType messageType = MessageType::AUTHOR_WARNING;
  127. switch (mf.GetPolicyStatus(cmPolicies::CMP0039)) {
  128. case cmPolicies::WARN:
  129. e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0039) << "\n";
  130. modal = "should";
  131. CM_FALLTHROUGH;
  132. case cmPolicies::OLD:
  133. break;
  134. case cmPolicies::REQUIRED_ALWAYS:
  135. case cmPolicies::REQUIRED_IF_USED:
  136. case cmPolicies::NEW:
  137. modal = "must";
  138. messageType = MessageType::FATAL_ERROR;
  139. break;
  140. }
  141. if (modal) {
  142. e << "Utility target \"" << target->GetName() << "\" " << modal
  143. << " not be used as the target of a target_link_libraries call.";
  144. mf.IssueMessage(messageType, e.str());
  145. if (messageType == MessageType::FATAL_ERROR) {
  146. return false;
  147. }
  148. }
  149. }
  150. // But we might not have any libs after variable expansion.
  151. if (args.size() < 2) {
  152. return true;
  153. }
  154. TLL tll(mf, target);
  155. // Keep track of link configuration specifiers.
  156. cmTargetLinkLibraryType llt = GENERAL_LibraryType;
  157. bool haveLLT = false;
  158. // Start with primary linking and switch to link interface
  159. // specification if the keyword is encountered as the first argument.
  160. ProcessingState currentProcessingState = ProcessingLinkLibraries;
  161. // Add libraries, note that there is an optional prefix
  162. // of debug and optimized that can be used.
  163. for (unsigned int i = 1; i < args.size(); ++i) {
  164. if (args[i] == "LINK_INTERFACE_LIBRARIES") {
  165. currentProcessingState = ProcessingPlainLinkInterface;
  166. if (i != 1) {
  167. mf.IssueMessage(
  168. MessageType::FATAL_ERROR,
  169. "The LINK_INTERFACE_LIBRARIES option must appear as the second "
  170. "argument, just after the target name.");
  171. return true;
  172. }
  173. } else if (args[i] == "INTERFACE") {
  174. if (i != 1 &&
  175. currentProcessingState != ProcessingKeywordPrivateInterface &&
  176. currentProcessingState != ProcessingKeywordPublicInterface &&
  177. currentProcessingState != ProcessingKeywordLinkInterface) {
  178. mf.IssueMessage(
  179. MessageType::FATAL_ERROR,
  180. "The INTERFACE, PUBLIC or PRIVATE option must appear as the second "
  181. "argument, just after the target name.");
  182. return true;
  183. }
  184. currentProcessingState = ProcessingKeywordLinkInterface;
  185. } else if (args[i] == "LINK_PUBLIC") {
  186. if (i != 1 &&
  187. currentProcessingState != ProcessingPlainPrivateInterface &&
  188. currentProcessingState != ProcessingPlainPublicInterface) {
  189. mf.IssueMessage(
  190. MessageType::FATAL_ERROR,
  191. "The LINK_PUBLIC or LINK_PRIVATE option must appear as the second "
  192. "argument, just after the target name.");
  193. return true;
  194. }
  195. currentProcessingState = ProcessingPlainPublicInterface;
  196. } else if (args[i] == "PUBLIC") {
  197. if (i != 1 &&
  198. currentProcessingState != ProcessingKeywordPrivateInterface &&
  199. currentProcessingState != ProcessingKeywordPublicInterface &&
  200. currentProcessingState != ProcessingKeywordLinkInterface) {
  201. mf.IssueMessage(
  202. MessageType::FATAL_ERROR,
  203. "The INTERFACE, PUBLIC or PRIVATE option must appear as the second "
  204. "argument, just after the target name.");
  205. return true;
  206. }
  207. currentProcessingState = ProcessingKeywordPublicInterface;
  208. } else if (args[i] == "LINK_PRIVATE") {
  209. if (i != 1 && currentProcessingState != ProcessingPlainPublicInterface &&
  210. currentProcessingState != ProcessingPlainPrivateInterface) {
  211. mf.IssueMessage(
  212. MessageType::FATAL_ERROR,
  213. "The LINK_PUBLIC or LINK_PRIVATE option must appear as the second "
  214. "argument, just after the target name.");
  215. return true;
  216. }
  217. currentProcessingState = ProcessingPlainPrivateInterface;
  218. } else if (args[i] == "PRIVATE") {
  219. if (i != 1 &&
  220. currentProcessingState != ProcessingKeywordPrivateInterface &&
  221. currentProcessingState != ProcessingKeywordPublicInterface &&
  222. currentProcessingState != ProcessingKeywordLinkInterface) {
  223. mf.IssueMessage(
  224. MessageType::FATAL_ERROR,
  225. "The INTERFACE, PUBLIC or PRIVATE option must appear as the second "
  226. "argument, just after the target name.");
  227. return true;
  228. }
  229. currentProcessingState = ProcessingKeywordPrivateInterface;
  230. } else if (args[i] == "debug") {
  231. if (haveLLT) {
  232. LinkLibraryTypeSpecifierWarning(mf, llt, DEBUG_LibraryType);
  233. }
  234. llt = DEBUG_LibraryType;
  235. haveLLT = true;
  236. } else if (args[i] == "optimized") {
  237. if (haveLLT) {
  238. LinkLibraryTypeSpecifierWarning(mf, llt, OPTIMIZED_LibraryType);
  239. }
  240. llt = OPTIMIZED_LibraryType;
  241. haveLLT = true;
  242. } else if (args[i] == "general") {
  243. if (haveLLT) {
  244. LinkLibraryTypeSpecifierWarning(mf, llt, GENERAL_LibraryType);
  245. }
  246. llt = GENERAL_LibraryType;
  247. haveLLT = true;
  248. } else if (haveLLT) {
  249. // The link type was specified by the previous argument.
  250. haveLLT = false;
  251. if (!tll.HandleLibrary(currentProcessingState, args[i], llt)) {
  252. return false;
  253. }
  254. llt = GENERAL_LibraryType;
  255. } else {
  256. if (!tll.HandleLibrary(currentProcessingState, args[i],
  257. GENERAL_LibraryType)) {
  258. return false;
  259. }
  260. }
  261. }
  262. // Make sure the last argument was not a library type specifier.
  263. if (haveLLT) {
  264. mf.IssueMessage(MessageType::FATAL_ERROR,
  265. cmStrCat("The \"", LinkLibraryTypeNames[llt],
  266. "\" argument must be followed by a library."));
  267. cmSystemTools::SetFatalErrorOccured();
  268. }
  269. const cmPolicies::PolicyStatus policy22Status =
  270. target->GetPolicyStatusCMP0022();
  271. // If any of the LINK_ options were given, make sure the
  272. // LINK_INTERFACE_LIBRARIES target property exists.
  273. // Use of any of the new keywords implies awareness of
  274. // this property. And if no libraries are named, it should
  275. // result in an empty link interface.
  276. if ((policy22Status == cmPolicies::OLD ||
  277. policy22Status == cmPolicies::WARN) &&
  278. currentProcessingState != ProcessingLinkLibraries &&
  279. !target->GetProperty("LINK_INTERFACE_LIBRARIES")) {
  280. target->SetProperty("LINK_INTERFACE_LIBRARIES", "");
  281. }
  282. return true;
  283. }
  284. static void LinkLibraryTypeSpecifierWarning(cmMakefile& mf, int left,
  285. int right)
  286. {
  287. mf.IssueMessage(
  288. MessageType::AUTHOR_WARNING,
  289. cmStrCat(
  290. "Link library type specifier \"", LinkLibraryTypeNames[left],
  291. "\" is followed by specifier \"", LinkLibraryTypeNames[right],
  292. "\" instead of a library name. The first specifier will be ignored."));
  293. }
  294. namespace {
  295. TLL::TLL(cmMakefile& mf, cmTarget* target)
  296. : Makefile(mf)
  297. , Target(target)
  298. {
  299. if (&this->Makefile != this->Target->GetMakefile()) {
  300. // The LHS target was created in another directory.
  301. switch (this->Makefile.GetPolicyStatus(cmPolicies::CMP0079)) {
  302. case cmPolicies::WARN:
  303. this->WarnRemoteInterface = true;
  304. CM_FALLTHROUGH;
  305. case cmPolicies::OLD:
  306. this->RejectRemoteLinking = true;
  307. break;
  308. case cmPolicies::REQUIRED_ALWAYS:
  309. case cmPolicies::REQUIRED_IF_USED:
  310. case cmPolicies::NEW:
  311. this->EncodeRemoteReference = true;
  312. break;
  313. }
  314. }
  315. if (this->EncodeRemoteReference) {
  316. cmDirectoryId const dirId = this->Makefile.GetDirectoryId();
  317. this->DirectoryId = cmStrCat(CMAKE_DIRECTORY_ID_SEP, dirId.String);
  318. }
  319. }
  320. bool TLL::HandleLibrary(ProcessingState currentProcessingState,
  321. const std::string& lib, cmTargetLinkLibraryType llt)
  322. {
  323. if (this->Target->GetType() == cmStateEnums::INTERFACE_LIBRARY &&
  324. currentProcessingState != ProcessingKeywordLinkInterface) {
  325. this->Makefile.IssueMessage(
  326. MessageType::FATAL_ERROR,
  327. "INTERFACE library can only be used with the INTERFACE keyword of "
  328. "target_link_libraries");
  329. return false;
  330. }
  331. if (this->Target->IsImported() &&
  332. currentProcessingState != ProcessingKeywordLinkInterface) {
  333. this->Makefile.IssueMessage(
  334. MessageType::FATAL_ERROR,
  335. "IMPORTED library can only be used with the INTERFACE keyword of "
  336. "target_link_libraries");
  337. return false;
  338. }
  339. cmTarget::TLLSignature sig =
  340. (currentProcessingState == ProcessingPlainPrivateInterface ||
  341. currentProcessingState == ProcessingPlainPublicInterface ||
  342. currentProcessingState == ProcessingKeywordPrivateInterface ||
  343. currentProcessingState == ProcessingKeywordPublicInterface ||
  344. currentProcessingState == ProcessingKeywordLinkInterface)
  345. ? cmTarget::KeywordTLLSignature
  346. : cmTarget::PlainTLLSignature;
  347. if (!this->Target->PushTLLCommandTrace(
  348. sig, this->Makefile.GetBacktrace().Top())) {
  349. std::ostringstream e;
  350. const char* modal = nullptr;
  351. MessageType messageType = MessageType::AUTHOR_WARNING;
  352. switch (this->Makefile.GetPolicyStatus(cmPolicies::CMP0023)) {
  353. case cmPolicies::WARN:
  354. e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0023) << "\n";
  355. modal = "should";
  356. CM_FALLTHROUGH;
  357. case cmPolicies::OLD:
  358. break;
  359. case cmPolicies::REQUIRED_ALWAYS:
  360. case cmPolicies::REQUIRED_IF_USED:
  361. case cmPolicies::NEW:
  362. modal = "must";
  363. messageType = MessageType::FATAL_ERROR;
  364. break;
  365. }
  366. if (modal) {
  367. // If the sig is a keyword form and there is a conflict, the existing
  368. // form must be the plain form.
  369. const char* existingSig =
  370. (sig == cmTarget::KeywordTLLSignature ? "plain" : "keyword");
  371. e << "The " << existingSig
  372. << " signature for target_link_libraries has "
  373. "already been used with the target \""
  374. << this->Target->GetName()
  375. << "\". All uses of target_link_libraries with a target " << modal
  376. << " be either all-keyword or all-plain.\n";
  377. this->Target->GetTllSignatureTraces(e,
  378. sig == cmTarget::KeywordTLLSignature
  379. ? cmTarget::PlainTLLSignature
  380. : cmTarget::KeywordTLLSignature);
  381. this->Makefile.IssueMessage(messageType, e.str());
  382. if (messageType == MessageType::FATAL_ERROR) {
  383. return false;
  384. }
  385. }
  386. }
  387. // Handle normal case where the command was called with another keyword than
  388. // INTERFACE / LINK_INTERFACE_LIBRARIES or none at all. (The "LINK_LIBRARIES"
  389. // property of the target on the LHS shall be populated.)
  390. if (currentProcessingState != ProcessingKeywordLinkInterface &&
  391. currentProcessingState != ProcessingPlainLinkInterface) {
  392. if (this->RejectRemoteLinking) {
  393. this->Makefile.IssueMessage(
  394. MessageType::FATAL_ERROR,
  395. cmStrCat("Attempt to add link library \"", lib, "\" to target \"",
  396. this->Target->GetName(),
  397. "\" which is not built in this "
  398. "directory.\nThis is allowed only when policy CMP0079 "
  399. "is set to NEW."));
  400. return false;
  401. }
  402. cmTarget* tgt = this->Makefile.GetGlobalGenerator()->FindTarget(lib);
  403. if (tgt && (tgt->GetType() != cmStateEnums::STATIC_LIBRARY) &&
  404. (tgt->GetType() != cmStateEnums::SHARED_LIBRARY) &&
  405. (tgt->GetType() != cmStateEnums::UNKNOWN_LIBRARY) &&
  406. (tgt->GetType() != cmStateEnums::OBJECT_LIBRARY) &&
  407. (tgt->GetType() != cmStateEnums::INTERFACE_LIBRARY) &&
  408. !tgt->IsExecutableWithExports()) {
  409. this->Makefile.IssueMessage(
  410. MessageType::FATAL_ERROR,
  411. cmStrCat(
  412. "Target \"", lib, "\" of type ",
  413. cmState::GetTargetTypeName(tgt->GetType()),
  414. " may not be linked into another target. One may link only to "
  415. "INTERFACE, OBJECT, STATIC or SHARED libraries, or to ",
  416. "executables with the ENABLE_EXPORTS property set."));
  417. }
  418. this->AffectsProperty("LINK_LIBRARIES");
  419. this->Target->AddLinkLibrary(this->Makefile, lib, llt);
  420. }
  421. if (this->WarnRemoteInterface) {
  422. this->Makefile.IssueMessage(
  423. MessageType::AUTHOR_WARNING,
  424. cmStrCat(
  425. cmPolicies::GetPolicyWarning(cmPolicies::CMP0079), "\nTarget\n ",
  426. this->Target->GetName(),
  427. "\nis not created in this "
  428. "directory. For compatibility with older versions of CMake, link "
  429. "library\n ",
  430. lib,
  431. "\nwill be looked up in the directory in which "
  432. "the target was created rather than in this calling directory."));
  433. }
  434. // Handle (additional) case where the command was called with PRIVATE /
  435. // LINK_PRIVATE and stop its processing. (The "INTERFACE_LINK_LIBRARIES"
  436. // property of the target on the LHS shall only be populated if it is a
  437. // STATIC library.)
  438. if (currentProcessingState == ProcessingKeywordPrivateInterface ||
  439. currentProcessingState == ProcessingPlainPrivateInterface) {
  440. if (this->Target->GetType() == cmStateEnums::STATIC_LIBRARY ||
  441. this->Target->GetType() == cmStateEnums::OBJECT_LIBRARY) {
  442. std::string configLib =
  443. this->Target->GetDebugGeneratorExpressions(lib, llt);
  444. if (cmGeneratorExpression::IsValidTargetName(lib) ||
  445. cmGeneratorExpression::Find(lib) != std::string::npos) {
  446. configLib = "$<LINK_ONLY:" + configLib + ">";
  447. }
  448. this->AppendProperty("INTERFACE_LINK_LIBRARIES", configLib);
  449. }
  450. return true;
  451. }
  452. // Handle general case where the command was called with another keyword than
  453. // PRIVATE / LINK_PRIVATE or none at all. (The "INTERFACE_LINK_LIBRARIES"
  454. // property of the target on the LHS shall be populated.)
  455. this->AppendProperty("INTERFACE_LINK_LIBRARIES",
  456. this->Target->GetDebugGeneratorExpressions(lib, llt));
  457. // Stop processing if called without any keyword.
  458. if (currentProcessingState == ProcessingLinkLibraries) {
  459. return true;
  460. }
  461. // Stop processing if policy CMP0022 is set to NEW.
  462. const cmPolicies::PolicyStatus policy22Status =
  463. this->Target->GetPolicyStatusCMP0022();
  464. if (policy22Status != cmPolicies::OLD &&
  465. policy22Status != cmPolicies::WARN) {
  466. return true;
  467. }
  468. // Stop processing if called with an INTERFACE library on the LHS.
  469. if (this->Target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
  470. return true;
  471. }
  472. // Handle (additional) backward-compatibility case where the command was
  473. // called with PUBLIC / INTERFACE / LINK_PUBLIC / LINK_INTERFACE_LIBRARIES.
  474. // (The policy CMP0022 is not set to NEW.)
  475. {
  476. // Get the list of configurations considered to be DEBUG.
  477. std::vector<std::string> debugConfigs =
  478. this->Makefile.GetCMakeInstance()->GetDebugConfigs();
  479. std::string prop;
  480. // Include this library in the link interface for the target.
  481. if (llt == DEBUG_LibraryType || llt == GENERAL_LibraryType) {
  482. // Put in the DEBUG configuration interfaces.
  483. for (std::string const& dc : debugConfigs) {
  484. prop = cmStrCat("LINK_INTERFACE_LIBRARIES_", dc);
  485. this->AppendProperty(prop, lib);
  486. }
  487. }
  488. if (llt == OPTIMIZED_LibraryType || llt == GENERAL_LibraryType) {
  489. // Put in the non-DEBUG configuration interfaces.
  490. this->AppendProperty("LINK_INTERFACE_LIBRARIES", lib);
  491. // Make sure the DEBUG configuration interfaces exist so that the
  492. // general one will not be used as a fall-back.
  493. for (std::string const& dc : debugConfigs) {
  494. prop = cmStrCat("LINK_INTERFACE_LIBRARIES_", dc);
  495. if (!this->Target->GetProperty(prop)) {
  496. this->Target->SetProperty(prop, "");
  497. }
  498. }
  499. }
  500. }
  501. return true;
  502. }
  503. void TLL::AppendProperty(std::string const& prop, std::string const& value)
  504. {
  505. this->AffectsProperty(prop);
  506. this->Target->AppendProperty(prop, value);
  507. }
  508. void TLL::AffectsProperty(std::string const& prop)
  509. {
  510. if (!this->EncodeRemoteReference) {
  511. return;
  512. }
  513. // Add a wrapper to the expression to tell LookupLinkItem to look up
  514. // names in the caller's directory.
  515. if (this->Props.insert(prop).second) {
  516. this->Target->AppendProperty(prop, this->DirectoryId);
  517. }
  518. }
  519. TLL::~TLL()
  520. {
  521. for (std::string const& prop : this->Props) {
  522. this->Target->AppendProperty(prop, CMAKE_DIRECTORY_ID_SEP);
  523. }
  524. }
  525. } // namespace