cmCPackIFWPackage.cxx 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  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 "cmCPackIFWPackage.h"
  4. #include "cmCPackComponentGroup.h"
  5. #include "cmCPackGenerator.h"
  6. #include "cmCPackIFWGenerator.h"
  7. #include "cmCPackIFWInstaller.h"
  8. #include "cmCPackLog.h"
  9. #include "cmGeneratedFileStream.h"
  10. #include "cmSystemTools.h"
  11. #include "cmTimestamp.h"
  12. #include "cmXMLWriter.h"
  13. #include "cmConfigure.h"
  14. #include <map>
  15. #include <sstream>
  16. #include <stddef.h>
  17. //----------------------------------------------------------------- Logger ---
  18. #ifdef cmCPackLogger
  19. #undef cmCPackLogger
  20. #endif
  21. #define cmCPackLogger(logType, msg) \
  22. do { \
  23. std::ostringstream cmCPackLog_msg; \
  24. cmCPackLog_msg << msg; \
  25. if (Generator) { \
  26. Generator->Logger->Log(logType, __FILE__, __LINE__, \
  27. cmCPackLog_msg.str().c_str()); \
  28. } \
  29. } while (false)
  30. //---------------------------------------------------------- CompareStruct ---
  31. cmCPackIFWPackage::CompareStruct::CompareStruct()
  32. : Type(CompareNone)
  33. {
  34. }
  35. //------------------------------------------------------- DependenceStruct ---
  36. cmCPackIFWPackage::DependenceStruct::DependenceStruct()
  37. {
  38. }
  39. cmCPackIFWPackage::DependenceStruct::DependenceStruct(
  40. const std::string& dependence)
  41. {
  42. // Search compare section
  43. size_t pos = std::string::npos;
  44. if ((pos = dependence.find("<=")) != std::string::npos) {
  45. Compare.Type = CompareLessOrEqual;
  46. Compare.Value = dependence.substr(pos + 2);
  47. } else if ((pos = dependence.find(">=")) != std::string::npos) {
  48. Compare.Type = CompareGreaterOrEqual;
  49. Compare.Value = dependence.substr(pos + 2);
  50. } else if ((pos = dependence.find('<')) != std::string::npos) {
  51. Compare.Type = CompareLess;
  52. Compare.Value = dependence.substr(pos + 1);
  53. } else if ((pos = dependence.find('=')) != std::string::npos) {
  54. Compare.Type = CompareEqual;
  55. Compare.Value = dependence.substr(pos + 1);
  56. } else if ((pos = dependence.find('>')) != std::string::npos) {
  57. Compare.Type = CompareGreater;
  58. Compare.Value = dependence.substr(pos + 1);
  59. } else if ((pos = dependence.find('-')) != std::string::npos) {
  60. Compare.Type = CompareNone;
  61. Compare.Value = dependence.substr(pos + 1);
  62. }
  63. size_t dashPos = dependence.find('-');
  64. if (dashPos != std::string::npos) {
  65. pos = dashPos;
  66. }
  67. Name = pos == std::string::npos ? dependence : dependence.substr(0, pos);
  68. }
  69. std::string cmCPackIFWPackage::DependenceStruct::NameWithCompare() const
  70. {
  71. if (Compare.Type == CompareNone) {
  72. return Name;
  73. }
  74. std::string result = Name;
  75. if (Compare.Type != CompareNone || !Compare.Value.empty()) {
  76. result += "-";
  77. }
  78. if (Compare.Type == CompareLessOrEqual) {
  79. result += "<=";
  80. } else if (Compare.Type == CompareGreaterOrEqual) {
  81. result += ">=";
  82. } else if (Compare.Type == CompareLess) {
  83. result += "<";
  84. } else if (Compare.Type == CompareEqual) {
  85. result += "=";
  86. } else if (Compare.Type == CompareGreater) {
  87. result += ">";
  88. }
  89. result += Compare.Value;
  90. return result;
  91. }
  92. //------------------------------------------------------ cmCPackIFWPackage ---
  93. cmCPackIFWPackage::cmCPackIFWPackage()
  94. : Generator(CM_NULLPTR)
  95. , Installer(CM_NULLPTR)
  96. {
  97. }
  98. const char* cmCPackIFWPackage::GetOption(const std::string& op) const
  99. {
  100. const char* option = Generator ? Generator->GetOption(op) : CM_NULLPTR;
  101. return option && *option ? option : CM_NULLPTR;
  102. }
  103. bool cmCPackIFWPackage::IsOn(const std::string& op) const
  104. {
  105. return Generator ? Generator->IsOn(op) : false;
  106. }
  107. bool cmCPackIFWPackage::IsSetToOff(const std::string& op) const
  108. {
  109. return Generator ? Generator->IsSetToOff(op) : false;
  110. }
  111. bool cmCPackIFWPackage::IsSetToEmpty(const std::string& op) const
  112. {
  113. return Generator ? Generator->IsSetToEmpty(op) : false;
  114. }
  115. bool cmCPackIFWPackage::IsVersionLess(const char* version)
  116. {
  117. return Generator ? Generator->IsVersionLess(version) : false;
  118. }
  119. bool cmCPackIFWPackage::IsVersionGreater(const char* version)
  120. {
  121. return Generator ? Generator->IsVersionGreater(version) : false;
  122. }
  123. bool cmCPackIFWPackage::IsVersionEqual(const char* version)
  124. {
  125. return Generator ? Generator->IsVersionEqual(version) : false;
  126. }
  127. std::string cmCPackIFWPackage::GetComponentName(cmCPackComponent* component)
  128. {
  129. if (!component) {
  130. return "";
  131. }
  132. const char* option =
  133. GetOption("CPACK_IFW_COMPONENT_" +
  134. cmsys::SystemTools::UpperCase(component->Name) + "_NAME");
  135. return option ? option : component->Name;
  136. }
  137. void cmCPackIFWPackage::DefaultConfiguration()
  138. {
  139. DisplayName = "";
  140. Description = "";
  141. Version = "";
  142. ReleaseDate = "";
  143. Script = "";
  144. Licenses.clear();
  145. UserInterfaces.clear();
  146. Translations.clear();
  147. SortingPriority = "";
  148. UpdateText = "";
  149. Default = "";
  150. Essential = "";
  151. Virtual = "";
  152. ForcedInstallation = "";
  153. RequiresAdminRights = "";
  154. }
  155. // Defaul configuration (all in one package)
  156. int cmCPackIFWPackage::ConfigureFromOptions()
  157. {
  158. // Restore defaul configuration
  159. DefaultConfiguration();
  160. // Name
  161. Name = Generator->GetRootPackageName();
  162. // Display name
  163. if (const char* option = this->GetOption("CPACK_PACKAGE_NAME")) {
  164. DisplayName = option;
  165. } else {
  166. DisplayName = "Your package";
  167. }
  168. // Description
  169. if (const char* option =
  170. this->GetOption("CPACK_PACKAGE_DESCRIPTION_SUMMARY")) {
  171. Description = option;
  172. } else {
  173. Description = "Your package description";
  174. }
  175. // Version
  176. if (const char* option = GetOption("CPACK_PACKAGE_VERSION")) {
  177. Version = option;
  178. } else {
  179. Version = "1.0.0";
  180. }
  181. ForcedInstallation = "true";
  182. return 1;
  183. }
  184. int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent* component)
  185. {
  186. if (!component) {
  187. return 0;
  188. }
  189. // Restore defaul configuration
  190. DefaultConfiguration();
  191. std::string prefix = "CPACK_IFW_COMPONENT_" +
  192. cmsys::SystemTools::UpperCase(component->Name) + "_";
  193. // Display name
  194. DisplayName = component->DisplayName;
  195. // Description
  196. Description = component->Description;
  197. // Version
  198. if (const char* optVERSION = GetOption(prefix + "VERSION")) {
  199. Version = optVERSION;
  200. } else if (const char* optPACKAGE_VERSION =
  201. GetOption("CPACK_PACKAGE_VERSION")) {
  202. Version = optPACKAGE_VERSION;
  203. } else {
  204. Version = "1.0.0";
  205. }
  206. // Script
  207. if (const char* option = GetOption(prefix + "SCRIPT")) {
  208. Script = option;
  209. }
  210. // User interfaces
  211. if (const char* option = this->GetOption(prefix + "USER_INTERFACES")) {
  212. UserInterfaces.clear();
  213. cmSystemTools::ExpandListArgument(option, UserInterfaces);
  214. }
  215. // CMake dependencies
  216. if (!component->Dependencies.empty()) {
  217. std::vector<cmCPackComponent*>::iterator dit;
  218. for (dit = component->Dependencies.begin();
  219. dit != component->Dependencies.end(); ++dit) {
  220. Dependencies.insert(Generator->ComponentPackages[*dit]);
  221. }
  222. }
  223. // Licenses
  224. if (const char* option = this->GetOption(prefix + "LICENSES")) {
  225. Licenses.clear();
  226. cmSystemTools::ExpandListArgument(option, Licenses);
  227. if (Licenses.size() % 2 != 0) {
  228. cmCPackLogger(
  229. cmCPackLog::LOG_WARNING, prefix
  230. << "LICENSES"
  231. << " should contain pairs of <display_name> and <file_path>."
  232. << std::endl);
  233. Licenses.clear();
  234. }
  235. }
  236. // Priority
  237. if (const char* option = this->GetOption(prefix + "PRIORITY")) {
  238. SortingPriority = option;
  239. cmCPackLogger(
  240. cmCPackLog::LOG_WARNING, "The \"PRIORITY\" option is set "
  241. << "for component \"" << component->Name << "\", but there option is "
  242. << "deprecated. Please use \"SORTING_PRIORITY\" option instead."
  243. << std::endl);
  244. }
  245. // Default
  246. Default = component->IsDisabledByDefault ? "false" : "true";
  247. // Essential
  248. if (this->IsOn(prefix + "ESSENTIAL")) {
  249. Essential = "true";
  250. }
  251. // Virtual
  252. Virtual = component->IsHidden ? "true" : "";
  253. // ForcedInstallation
  254. ForcedInstallation = component->IsRequired ? "true" : "false";
  255. return ConfigureFromPrefix(prefix);
  256. }
  257. int cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup* group)
  258. {
  259. if (!group) {
  260. return 0;
  261. }
  262. // Restore defaul configuration
  263. DefaultConfiguration();
  264. std::string prefix = "CPACK_IFW_COMPONENT_GROUP_" +
  265. cmsys::SystemTools::UpperCase(group->Name) + "_";
  266. DisplayName = group->DisplayName;
  267. Description = group->Description;
  268. // Version
  269. if (const char* optVERSION = GetOption(prefix + "VERSION")) {
  270. Version = optVERSION;
  271. } else if (const char* optPACKAGE_VERSION =
  272. GetOption("CPACK_PACKAGE_VERSION")) {
  273. Version = optPACKAGE_VERSION;
  274. } else {
  275. Version = "1.0.0";
  276. }
  277. // Script
  278. if (const char* option = GetOption(prefix + "SCRIPT")) {
  279. Script = option;
  280. }
  281. // User interfaces
  282. if (const char* option = this->GetOption(prefix + "USER_INTERFACES")) {
  283. UserInterfaces.clear();
  284. cmSystemTools::ExpandListArgument(option, UserInterfaces);
  285. }
  286. // Licenses
  287. if (const char* option = this->GetOption(prefix + "LICENSES")) {
  288. Licenses.clear();
  289. cmSystemTools::ExpandListArgument(option, Licenses);
  290. if (Licenses.size() % 2 != 0) {
  291. cmCPackLogger(
  292. cmCPackLog::LOG_WARNING, prefix
  293. << "LICENSES"
  294. << " should contain pairs of <display_name> and <file_path>."
  295. << std::endl);
  296. Licenses.clear();
  297. }
  298. }
  299. // Priority
  300. if (const char* option = this->GetOption(prefix + "PRIORITY")) {
  301. SortingPriority = option;
  302. cmCPackLogger(
  303. cmCPackLog::LOG_WARNING, "The \"PRIORITY\" option is set "
  304. << "for component group \"" << group->Name
  305. << "\", but there option is "
  306. << "deprecated. Please use \"SORTING_PRIORITY\" option instead."
  307. << std::endl);
  308. }
  309. return ConfigureFromPrefix(prefix);
  310. }
  311. int cmCPackIFWPackage::ConfigureFromGroup(const std::string& groupName)
  312. {
  313. // Group configuration
  314. cmCPackComponentGroup group;
  315. std::string prefix =
  316. "CPACK_COMPONENT_GROUP_" + cmsys::SystemTools::UpperCase(groupName) + "_";
  317. if (const char* option = GetOption(prefix + "DISPLAY_NAME")) {
  318. group.DisplayName = option;
  319. } else {
  320. group.DisplayName = group.Name;
  321. }
  322. if (const char* option = GetOption(prefix + "DESCRIPTION")) {
  323. group.Description = option;
  324. }
  325. group.IsBold = IsOn(prefix + "BOLD_TITLE");
  326. group.IsExpandedByDefault = IsOn(prefix + "EXPANDED");
  327. // Package configuration
  328. group.Name = groupName;
  329. if (Generator) {
  330. Name = Generator->GetGroupPackageName(&group);
  331. } else {
  332. Name = group.Name;
  333. }
  334. return ConfigureFromGroup(&group);
  335. }
  336. // Common options for components and groups
  337. int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix)
  338. {
  339. // Temporary variable for full option name
  340. std::string option;
  341. // Display name
  342. option = prefix + "DISPLAY_NAME";
  343. if (IsSetToEmpty(option)) {
  344. DisplayName.clear();
  345. } else if (const char* value = GetOption(option)) {
  346. DisplayName = value;
  347. }
  348. // Description
  349. option = prefix + "DESCRIPTION";
  350. if (IsSetToEmpty(option)) {
  351. Description.clear();
  352. } else if (const char* value = GetOption(option)) {
  353. Description = value;
  354. }
  355. // Release date
  356. option = prefix + "RELEASE_DATE";
  357. if (IsSetToEmpty(option)) {
  358. ReleaseDate.clear();
  359. } else if (const char* value = GetOption(option)) {
  360. ReleaseDate = value;
  361. }
  362. // Sorting priority
  363. option = prefix + "SORTING_PRIORITY";
  364. if (IsSetToEmpty(option)) {
  365. SortingPriority.clear();
  366. } else if (const char* value = GetOption(option)) {
  367. SortingPriority = value;
  368. }
  369. // Update text
  370. option = prefix + "UPDATE_TEXT";
  371. if (IsSetToEmpty(option)) {
  372. UpdateText.clear();
  373. } else if (const char* value = GetOption(option)) {
  374. UpdateText = value;
  375. }
  376. // Translations
  377. option = prefix + "TRANSLATIONS";
  378. if (IsSetToEmpty(option)) {
  379. Translations.clear();
  380. } else if (const char* value = this->GetOption(option)) {
  381. Translations.clear();
  382. cmSystemTools::ExpandListArgument(value, Translations);
  383. }
  384. // QtIFW dependencies
  385. std::vector<std::string> deps;
  386. option = prefix + "DEPENDS";
  387. if (const char* value = this->GetOption(option)) {
  388. cmSystemTools::ExpandListArgument(value, deps);
  389. }
  390. option = prefix + "DEPENDENCIES";
  391. if (const char* value = this->GetOption(option)) {
  392. cmSystemTools::ExpandListArgument(value, deps);
  393. }
  394. for (std::vector<std::string>::iterator dit = deps.begin();
  395. dit != deps.end(); ++dit) {
  396. DependenceStruct dep(*dit);
  397. if (Generator->Packages.count(dep.Name)) {
  398. cmCPackIFWPackage& depPkg = Generator->Packages[dep.Name];
  399. dep.Name = depPkg.Name;
  400. }
  401. bool hasDep = Generator->DependentPackages.count(dep.Name) > 0;
  402. DependenceStruct& depRef = Generator->DependentPackages[dep.Name];
  403. if (!hasDep) {
  404. depRef = dep;
  405. }
  406. AlienDependencies.insert(&depRef);
  407. }
  408. // Automatic dependency on
  409. option = prefix + "AUTO_DEPEND_ON";
  410. if (IsSetToEmpty(option)) {
  411. AlienAutoDependOn.clear();
  412. } else if (const char* value = this->GetOption(option)) {
  413. std::vector<std::string> depsOn;
  414. cmSystemTools::ExpandListArgument(value, depsOn);
  415. for (std::vector<std::string>::iterator dit = depsOn.begin();
  416. dit != depsOn.end(); ++dit) {
  417. DependenceStruct dep(*dit);
  418. if (Generator->Packages.count(dep.Name)) {
  419. cmCPackIFWPackage& depPkg = Generator->Packages[dep.Name];
  420. dep.Name = depPkg.Name;
  421. }
  422. bool hasDep = Generator->DependentPackages.count(dep.Name) > 0;
  423. DependenceStruct& depRef = Generator->DependentPackages[dep.Name];
  424. if (!hasDep) {
  425. depRef = dep;
  426. }
  427. AlienAutoDependOn.insert(&depRef);
  428. }
  429. }
  430. // Visibility
  431. option = prefix + "VIRTUAL";
  432. if (IsSetToEmpty(option)) {
  433. Virtual.clear();
  434. } else if (IsOn(option)) {
  435. Virtual = "true";
  436. }
  437. // Default selection
  438. option = prefix + "DEFAULT";
  439. if (IsSetToEmpty(option)) {
  440. Default.clear();
  441. } else if (const char* value = GetOption(option)) {
  442. std::string lowerValue = cmsys::SystemTools::LowerCase(value);
  443. if (lowerValue.compare("true") == 0) {
  444. Default = "true";
  445. } else if (lowerValue.compare("false") == 0) {
  446. Default = "false";
  447. } else if (lowerValue.compare("script") == 0) {
  448. Default = "script";
  449. } else {
  450. Default = value;
  451. }
  452. }
  453. // Forsed installation
  454. option = prefix + "FORCED_INSTALLATION";
  455. if (IsSetToEmpty(option)) {
  456. ForcedInstallation.clear();
  457. } else if (IsOn(option)) {
  458. ForcedInstallation = "true";
  459. } else if (IsSetToOff(option)) {
  460. ForcedInstallation = "false";
  461. }
  462. // Requires admin rights
  463. option = prefix + "REQUIRES_ADMIN_RIGHTS";
  464. if (IsSetToEmpty(option)) {
  465. RequiresAdminRights.clear();
  466. } else if (IsOn(option)) {
  467. RequiresAdminRights = "true";
  468. } else if (IsSetToOff(option)) {
  469. RequiresAdminRights = "false";
  470. }
  471. return 1;
  472. }
  473. void cmCPackIFWPackage::GeneratePackageFile()
  474. {
  475. // Lazy directory initialization
  476. if (Directory.empty()) {
  477. if (Installer) {
  478. Directory = Installer->Directory + "/packages/" + Name;
  479. } else if (Generator) {
  480. Directory = Generator->toplevel + "/packages/" + Name;
  481. }
  482. }
  483. // Output stream
  484. cmGeneratedFileStream fout((Directory + "/meta/package.xml").data());
  485. cmXMLWriter xout(fout);
  486. xout.StartDocument();
  487. WriteGeneratedByToStrim(xout);
  488. xout.StartElement("Package");
  489. xout.Element("DisplayName", DisplayName);
  490. xout.Element("Description", Description);
  491. // Update text
  492. if (!UpdateText.empty()) {
  493. xout.Element("UpdateText", UpdateText);
  494. }
  495. xout.Element("Name", Name);
  496. xout.Element("Version", Version);
  497. if (!ReleaseDate.empty()) {
  498. xout.Element("ReleaseDate", ReleaseDate);
  499. } else {
  500. xout.Element("ReleaseDate", cmTimestamp().CurrentTime("%Y-%m-%d", true));
  501. }
  502. // Script (copy to meta dir)
  503. if (!Script.empty()) {
  504. std::string name = cmSystemTools::GetFilenameName(Script);
  505. std::string path = Directory + "/meta/" + name;
  506. cmsys::SystemTools::CopyFileIfDifferent(Script, path);
  507. xout.Element("Script", name);
  508. }
  509. // User Interfaces (copy to meta dir)
  510. std::vector<std::string> userInterfaces = UserInterfaces;
  511. for (size_t i = 0; i < userInterfaces.size(); i++) {
  512. std::string name = cmSystemTools::GetFilenameName(userInterfaces[i]);
  513. std::string path = Directory + "/meta/" + name;
  514. cmsys::SystemTools::CopyFileIfDifferent(userInterfaces[i], path);
  515. userInterfaces[i] = name;
  516. }
  517. if (!userInterfaces.empty()) {
  518. xout.StartElement("UserInterfaces");
  519. for (size_t i = 0; i < userInterfaces.size(); i++) {
  520. xout.Element("UserInterface", userInterfaces[i]);
  521. }
  522. xout.EndElement();
  523. }
  524. // Translations (copy to meta dir)
  525. std::vector<std::string> translations = Translations;
  526. for (size_t i = 0; i < translations.size(); i++) {
  527. std::string name = cmSystemTools::GetFilenameName(translations[i]);
  528. std::string path = Directory + "/meta/" + name;
  529. cmsys::SystemTools::CopyFileIfDifferent(translations[i], path);
  530. translations[i] = name;
  531. }
  532. if (!translations.empty()) {
  533. xout.StartElement("Translations");
  534. for (size_t i = 0; i < translations.size(); i++) {
  535. xout.Element("Translation", translations[i]);
  536. }
  537. xout.EndElement();
  538. }
  539. // Dependencies
  540. std::set<DependenceStruct> compDepSet;
  541. for (std::set<DependenceStruct*>::iterator ait = AlienDependencies.begin();
  542. ait != AlienDependencies.end(); ++ait) {
  543. compDepSet.insert(*(*ait));
  544. }
  545. for (std::set<cmCPackIFWPackage*>::iterator it = Dependencies.begin();
  546. it != Dependencies.end(); ++it) {
  547. compDepSet.insert(DependenceStruct((*it)->Name));
  548. }
  549. // Write dependencies
  550. if (!compDepSet.empty()) {
  551. std::ostringstream dependencies;
  552. std::set<DependenceStruct>::iterator it = compDepSet.begin();
  553. dependencies << it->NameWithCompare();
  554. ++it;
  555. while (it != compDepSet.end()) {
  556. dependencies << "," << it->NameWithCompare();
  557. ++it;
  558. }
  559. xout.Element("Dependencies", dependencies.str());
  560. }
  561. // Automatic dependency on
  562. std::set<DependenceStruct> compAutoDepSet;
  563. for (std::set<DependenceStruct*>::iterator ait = AlienAutoDependOn.begin();
  564. ait != AlienAutoDependOn.end(); ++ait) {
  565. compAutoDepSet.insert(*(*ait));
  566. }
  567. // Write automatic dependency on
  568. if (!compAutoDepSet.empty()) {
  569. std::ostringstream dependencies;
  570. std::set<DependenceStruct>::iterator it = compAutoDepSet.begin();
  571. dependencies << it->NameWithCompare();
  572. ++it;
  573. while (it != compAutoDepSet.end()) {
  574. dependencies << "," << it->NameWithCompare();
  575. ++it;
  576. }
  577. xout.Element("AutoDependOn", dependencies.str());
  578. }
  579. // Licenses (copy to meta dir)
  580. std::vector<std::string> licenses = Licenses;
  581. for (size_t i = 1; i < licenses.size(); i += 2) {
  582. std::string name = cmSystemTools::GetFilenameName(licenses[i]);
  583. std::string path = Directory + "/meta/" + name;
  584. cmsys::SystemTools::CopyFileIfDifferent(licenses[i], path);
  585. licenses[i] = name;
  586. }
  587. if (!licenses.empty()) {
  588. xout.StartElement("Licenses");
  589. for (size_t i = 0; i < licenses.size(); i += 2) {
  590. xout.StartElement("License");
  591. xout.Attribute("name", licenses[i]);
  592. xout.Attribute("file", licenses[i + 1]);
  593. xout.EndElement();
  594. }
  595. xout.EndElement();
  596. }
  597. if (!ForcedInstallation.empty()) {
  598. xout.Element("ForcedInstallation", ForcedInstallation);
  599. }
  600. if (!RequiresAdminRights.empty()) {
  601. xout.Element("RequiresAdminRights", RequiresAdminRights);
  602. }
  603. if (!Virtual.empty()) {
  604. xout.Element("Virtual", Virtual);
  605. } else if (!Default.empty()) {
  606. xout.Element("Default", Default);
  607. }
  608. // Essential
  609. if (!Essential.empty()) {
  610. xout.Element("Essential", Essential);
  611. }
  612. // Priority
  613. if (!SortingPriority.empty()) {
  614. xout.Element("SortingPriority", SortingPriority);
  615. }
  616. xout.EndElement();
  617. xout.EndDocument();
  618. }
  619. void cmCPackIFWPackage::WriteGeneratedByToStrim(cmXMLWriter& xout)
  620. {
  621. if (Generator) {
  622. Generator->WriteGeneratedByToStrim(xout);
  623. }
  624. }