cmTargetLinkLibrariesCommand.cxx 20 KB

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