cmTargetLinkLibrariesCommand.cxx 20 KB

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