cmTargetLinkLibrariesCommand.cxx 21 KB

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