cmTargetLinkLibrariesCommand.cxx 21 KB

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