cmCPackIFWInstaller.cxx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  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 "cmCPackIFWInstaller.h"
  4. #include <cstddef>
  5. #include <sstream>
  6. #include <utility>
  7. #include "cmCPackIFWCommon.h"
  8. #include "cmCPackIFWGenerator.h"
  9. #include "cmCPackIFWPackage.h"
  10. #include "cmCPackIFWRepository.h"
  11. #include "cmCPackLog.h" // IWYU pragma: keep
  12. #include "cmGeneratedFileStream.h"
  13. #include "cmList.h"
  14. #include "cmStringAlgorithms.h"
  15. #include "cmSystemTools.h"
  16. #include "cmValue.h"
  17. #include "cmXMLParser.h"
  18. #include "cmXMLWriter.h"
  19. cmCPackIFWInstaller::cmCPackIFWInstaller() = default;
  20. void cmCPackIFWInstaller::printSkippedOptionWarning(
  21. const std::string& optionName, const std::string& optionValue)
  22. {
  23. cmCPackIFWLogger(
  24. WARNING,
  25. "Option "
  26. << optionName << " contains the value \"" << optionValue
  27. << "\" but will be skipped because the specified file does not exist."
  28. << std::endl);
  29. }
  30. void cmCPackIFWInstaller::ConfigureFromOptions()
  31. {
  32. // Name;
  33. if (cmValue optIFW_PACKAGE_NAME =
  34. this->GetOption("CPACK_IFW_PACKAGE_NAME")) {
  35. this->Name = *optIFW_PACKAGE_NAME;
  36. } else if (cmValue optPACKAGE_NAME = this->GetOption("CPACK_PACKAGE_NAME")) {
  37. this->Name = *optPACKAGE_NAME;
  38. } else {
  39. this->Name = "Your package";
  40. }
  41. // Title;
  42. if (cmValue optIFW_PACKAGE_TITLE =
  43. this->GetOption("CPACK_IFW_PACKAGE_TITLE")) {
  44. this->Title = *optIFW_PACKAGE_TITLE;
  45. } else if (cmValue optPACKAGE_DESCRIPTION_SUMMARY =
  46. this->GetOption("CPACK_PACKAGE_DESCRIPTION_SUMMARY")) {
  47. this->Title = *optPACKAGE_DESCRIPTION_SUMMARY;
  48. } else {
  49. this->Title = "Your package description";
  50. }
  51. // Version;
  52. if (cmValue option = this->GetOption("CPACK_PACKAGE_VERSION")) {
  53. this->Version = *option;
  54. } else {
  55. this->Version = "1.0.0";
  56. }
  57. // Publisher
  58. if (cmValue optIFW_PACKAGE_PUBLISHER =
  59. this->GetOption("CPACK_IFW_PACKAGE_PUBLISHER")) {
  60. this->Publisher = *optIFW_PACKAGE_PUBLISHER;
  61. } else if (cmValue optPACKAGE_VENDOR =
  62. this->GetOption("CPACK_PACKAGE_VENDOR")) {
  63. this->Publisher = *optPACKAGE_VENDOR;
  64. }
  65. // ProductUrl
  66. if (cmValue option = this->GetOption("CPACK_IFW_PRODUCT_URL")) {
  67. this->ProductUrl = *option;
  68. }
  69. // ApplicationIcon
  70. if (cmValue option = this->GetOption("CPACK_IFW_PACKAGE_ICON")) {
  71. if (cmSystemTools::FileExists(*option)) {
  72. this->InstallerApplicationIcon = *option;
  73. } else {
  74. this->printSkippedOptionWarning("CPACK_IFW_PACKAGE_ICON", *option);
  75. }
  76. }
  77. // WindowIcon
  78. if (cmValue option = this->GetOption("CPACK_IFW_PACKAGE_WINDOW_ICON")) {
  79. if (cmSystemTools::FileExists(*option)) {
  80. this->InstallerWindowIcon = *option;
  81. } else {
  82. this->printSkippedOptionWarning("CPACK_IFW_PACKAGE_WINDOW_ICON",
  83. *option);
  84. }
  85. }
  86. // RemoveTargetDir
  87. if (this->IsSetToOff("CPACK_IFW_PACKAGE_REMOVE_TARGET_DIR")) {
  88. this->RemoveTargetDir = "false";
  89. } else if (this->IsOn("CPACK_IFW_PACKAGE_REMOVE_TARGET_DIR")) {
  90. this->RemoveTargetDir = "true";
  91. } else {
  92. this->RemoveTargetDir.clear();
  93. }
  94. // Logo
  95. if (cmValue option = this->GetOption("CPACK_IFW_PACKAGE_LOGO")) {
  96. if (cmSystemTools::FileExists(*option)) {
  97. this->Logo = *option;
  98. } else {
  99. this->printSkippedOptionWarning("CPACK_IFW_PACKAGE_LOGO", *option);
  100. }
  101. }
  102. // Watermark
  103. if (cmValue option = this->GetOption("CPACK_IFW_PACKAGE_WATERMARK")) {
  104. if (cmSystemTools::FileExists(*option)) {
  105. this->Watermark = *option;
  106. } else {
  107. this->printSkippedOptionWarning("CPACK_IFW_PACKAGE_WATERMARK", *option);
  108. }
  109. }
  110. // Banner
  111. if (cmValue option = this->GetOption("CPACK_IFW_PACKAGE_BANNER")) {
  112. if (cmSystemTools::FileExists(*option)) {
  113. this->Banner = *option;
  114. } else {
  115. this->printSkippedOptionWarning("CPACK_IFW_PACKAGE_BANNER", *option);
  116. }
  117. }
  118. // Background
  119. if (cmValue option = this->GetOption("CPACK_IFW_PACKAGE_BACKGROUND")) {
  120. if (cmSystemTools::FileExists(*option)) {
  121. this->Background = *option;
  122. } else {
  123. this->printSkippedOptionWarning("CPACK_IFW_PACKAGE_BACKGROUND", *option);
  124. }
  125. }
  126. // WizardStyle
  127. if (cmValue option = this->GetOption("CPACK_IFW_PACKAGE_WIZARD_STYLE")) {
  128. // Setting the user value in any case
  129. this->WizardStyle = *option;
  130. // Check known values
  131. if (this->WizardStyle != "Modern" && this->WizardStyle != "Aero" &&
  132. this->WizardStyle != "Mac" && this->WizardStyle != "Classic") {
  133. cmCPackIFWLogger(
  134. WARNING,
  135. "Option CPACK_IFW_PACKAGE_WIZARD_STYLE has unknown value \""
  136. << option << "\". Expected values are: Modern, Aero, Mac, Classic."
  137. << std::endl);
  138. }
  139. }
  140. // StyleSheet
  141. if (cmValue option = this->GetOption("CPACK_IFW_PACKAGE_STYLE_SHEET")) {
  142. if (cmSystemTools::FileExists(*option)) {
  143. this->StyleSheet = *option;
  144. } else {
  145. this->printSkippedOptionWarning("CPACK_IFW_PACKAGE_STYLE_SHEET",
  146. *option);
  147. }
  148. }
  149. // WizardDefaultWidth
  150. if (cmValue option =
  151. this->GetOption("CPACK_IFW_PACKAGE_WIZARD_DEFAULT_WIDTH")) {
  152. this->WizardDefaultWidth = *option;
  153. }
  154. // WizardDefaultHeight
  155. if (cmValue option =
  156. this->GetOption("CPACK_IFW_PACKAGE_WIZARD_DEFAULT_HEIGHT")) {
  157. this->WizardDefaultHeight = *option;
  158. }
  159. // WizardShowPageList
  160. if (cmValue option =
  161. this->GetOption("CPACK_IFW_PACKAGE_WIZARD_SHOW_PAGE_LIST")) {
  162. if (!this->IsVersionLess("4.0")) {
  163. if (this->IsSetToOff("CPACK_IFW_PACKAGE_WIZARD_SHOW_PAGE_LIST")) {
  164. this->WizardShowPageList = "false";
  165. } else if (this->IsOn("CPACK_IFW_PACKAGE_WIZARD_SHOW_PAGE_LIST")) {
  166. this->WizardShowPageList = "true";
  167. } else {
  168. this->WizardShowPageList.clear();
  169. }
  170. } else {
  171. std::string currentVersionMsg;
  172. if (this->Generator) {
  173. currentVersionMsg =
  174. "QtIFW version " + this->Generator->FrameworkVersion;
  175. } else {
  176. currentVersionMsg = "an older QtIFW version";
  177. }
  178. cmCPackIFWLogger(
  179. WARNING,
  180. "Option CPACK_IFW_PACKAGE_WIZARD_SHOW_PAGE_LIST is set to \""
  181. << option
  182. << "\", but it is only supported with QtIFW version 4.0 or later. "
  183. "It is being ignored because you are using "
  184. << currentVersionMsg << std::endl);
  185. }
  186. }
  187. // TitleColor
  188. if (cmValue option = this->GetOption("CPACK_IFW_PACKAGE_TITLE_COLOR")) {
  189. this->TitleColor = *option;
  190. }
  191. // Start menu
  192. if (cmValue optIFW_START_MENU_DIR =
  193. this->GetOption("CPACK_IFW_PACKAGE_START_MENU_DIRECTORY")) {
  194. this->StartMenuDir = *optIFW_START_MENU_DIR;
  195. } else {
  196. this->StartMenuDir = this->Name;
  197. }
  198. // Default target directory for installation
  199. if (cmValue optIFW_TARGET_DIRECTORY =
  200. this->GetOption("CPACK_IFW_TARGET_DIRECTORY")) {
  201. this->TargetDir = *optIFW_TARGET_DIRECTORY;
  202. } else if (cmValue optPACKAGE_INSTALL_DIRECTORY =
  203. this->GetOption("CPACK_PACKAGE_INSTALL_DIRECTORY")) {
  204. this->TargetDir =
  205. cmStrCat("@ApplicationsDir@/", optPACKAGE_INSTALL_DIRECTORY);
  206. } else {
  207. this->TargetDir = "@RootDir@/usr/local";
  208. }
  209. // Default target directory for installation with administrator rights
  210. if (cmValue option = this->GetOption("CPACK_IFW_ADMIN_TARGET_DIRECTORY")) {
  211. this->AdminTargetDir = *option;
  212. }
  213. // Maintenance tool
  214. if (cmValue optIFW_MAINTENANCE_TOOL =
  215. this->GetOption("CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_NAME")) {
  216. this->MaintenanceToolName = *optIFW_MAINTENANCE_TOOL;
  217. }
  218. // Maintenance tool ini file
  219. if (cmValue optIFW_MAINTENANCE_TOOL_INI =
  220. this->GetOption("CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_INI_FILE")) {
  221. this->MaintenanceToolIniFile = *optIFW_MAINTENANCE_TOOL_INI;
  222. }
  223. // Allow non-ASCII characters
  224. if (this->GetOption("CPACK_IFW_PACKAGE_ALLOW_NON_ASCII_CHARACTERS")) {
  225. if (this->IsOn("CPACK_IFW_PACKAGE_ALLOW_NON_ASCII_CHARACTERS")) {
  226. this->AllowNonAsciiCharacters = "true";
  227. } else {
  228. this->AllowNonAsciiCharacters = "false";
  229. }
  230. }
  231. // DisableCommandLineInterface
  232. if (this->GetOption("CPACK_IFW_PACKAGE_DISABLE_COMMAND_LINE_INTERFACE")) {
  233. if (this->IsOn("CPACK_IFW_PACKAGE_DISABLE_COMMAND_LINE_INTERFACE")) {
  234. this->DisableCommandLineInterface = "true";
  235. } else if (this->IsSetToOff(
  236. "CPACK_IFW_PACKAGE_DISABLE_COMMAND_LINE_INTERFACE")) {
  237. this->DisableCommandLineInterface = "false";
  238. }
  239. }
  240. // Space in path
  241. if (this->GetOption("CPACK_IFW_PACKAGE_ALLOW_SPACE_IN_PATH")) {
  242. if (this->IsOn("CPACK_IFW_PACKAGE_ALLOW_SPACE_IN_PATH")) {
  243. this->AllowSpaceInPath = "true";
  244. } else {
  245. this->AllowSpaceInPath = "false";
  246. }
  247. }
  248. // Control script
  249. if (cmValue optIFW_CONTROL_SCRIPT =
  250. this->GetOption("CPACK_IFW_PACKAGE_CONTROL_SCRIPT")) {
  251. if (!cmSystemTools::FileExists(*optIFW_CONTROL_SCRIPT)) {
  252. this->printSkippedOptionWarning("CPACK_IFW_PACKAGE_CONTROL_SCRIPT",
  253. *optIFW_CONTROL_SCRIPT);
  254. } else {
  255. this->ControlScript = *optIFW_CONTROL_SCRIPT;
  256. }
  257. }
  258. // Resources
  259. if (cmValue optIFW_PACKAGE_RESOURCES =
  260. this->GetOption("CPACK_IFW_PACKAGE_RESOURCES")) {
  261. this->Resources.clear();
  262. cmExpandList(optIFW_PACKAGE_RESOURCES, this->Resources);
  263. for (const auto& file : this->Resources) {
  264. if (!cmSystemTools::FileExists(file)) {
  265. // The warning will say skipped, but there will later be a hard error
  266. // when the binarycreator tool tries to read the missing file.
  267. this->printSkippedOptionWarning("CPACK_IFW_PACKAGE_RESOURCES", file);
  268. }
  269. }
  270. }
  271. // ProductImages
  272. if (cmValue productImages =
  273. this->GetOption("CPACK_IFW_PACKAGE_PRODUCT_IMAGES")) {
  274. this->ProductImages.clear();
  275. cmExpandList(productImages, this->ProductImages);
  276. for (const auto& file : this->ProductImages) {
  277. if (!cmSystemTools::FileExists(file)) {
  278. // The warning will say skipped, but there will later be a hard error
  279. // when the binarycreator tool tries to read the missing file.
  280. this->printSkippedOptionWarning("CPACK_IFW_PACKAGE_PRODUCT_IMAGES",
  281. file);
  282. }
  283. }
  284. }
  285. // Run program, run program arguments, and run program description
  286. if (cmValue program = this->GetOption("CPACK_IFW_PACKAGE_RUN_PROGRAM")) {
  287. this->RunProgram = *program;
  288. }
  289. if (cmValue arguments =
  290. this->GetOption("CPACK_IFW_PACKAGE_RUN_PROGRAM_ARGUMENTS")) {
  291. this->RunProgramArguments.clear();
  292. cmExpandList(arguments, this->RunProgramArguments);
  293. }
  294. if (cmValue description =
  295. this->GetOption("CPACK_IFW_PACKAGE_RUN_PROGRAM_DESCRIPTION")) {
  296. this->RunProgramDescription = *description;
  297. }
  298. #ifdef __APPLE__
  299. // Code signing identity for signing the generated app bundle
  300. if (cmValue id = this->GetOption("CPACK_IFW_PACKAGE_SIGNING_IDENTITY")) {
  301. this->SigningIdentity = *id;
  302. }
  303. #endif
  304. }
  305. /** \class cmCPackIFWResourcesParser
  306. * \brief Helper class that parse resources form .qrc (Qt)
  307. */
  308. class cmCPackIFWResourcesParser : public cmXMLParser
  309. {
  310. public:
  311. explicit cmCPackIFWResourcesParser(cmCPackIFWInstaller* i)
  312. : installer(i)
  313. {
  314. this->path = i->Directory + "/resources";
  315. }
  316. bool ParseResource(size_t r)
  317. {
  318. this->hasFiles = false;
  319. this->hasErrors = false;
  320. this->basePath =
  321. cmSystemTools::GetFilenamePath(this->installer->Resources[r]);
  322. this->ParseFile(this->installer->Resources[r].data());
  323. return this->hasFiles && !this->hasErrors;
  324. }
  325. cmCPackIFWInstaller* installer;
  326. bool file = false;
  327. bool hasFiles = false;
  328. bool hasErrors = false;
  329. std::string path, basePath;
  330. protected:
  331. void StartElement(const std::string& name, const char** /*atts*/) override
  332. {
  333. this->file = name == "file";
  334. if (this->file) {
  335. this->hasFiles = true;
  336. }
  337. }
  338. void CharacterDataHandler(const char* data, int length) override
  339. {
  340. if (this->file) {
  341. std::string content(data, data + length);
  342. content = cmTrimWhitespace(content);
  343. std::string source = this->basePath + "/" + content;
  344. std::string destination = this->path + "/" + content;
  345. if (!cmSystemTools::CopyFileIfDifferent(source, destination)) {
  346. this->hasErrors = true;
  347. }
  348. }
  349. }
  350. void EndElement(const std::string& /*name*/) override {}
  351. };
  352. void cmCPackIFWInstaller::GenerateInstallerFile()
  353. {
  354. // Lazy directory initialization
  355. if (this->Directory.empty() && this->Generator) {
  356. this->Directory = this->Generator->toplevel;
  357. }
  358. // Output stream
  359. cmGeneratedFileStream fout(this->Directory + "/config/config.xml");
  360. cmXMLWriter xout(fout);
  361. xout.StartDocument();
  362. this->WriteGeneratedByToStrim(xout);
  363. xout.StartElement("Installer");
  364. xout.Element("Name", this->Name);
  365. xout.Element("Version", this->Version);
  366. xout.Element("Title", this->Title);
  367. if (!this->Publisher.empty()) {
  368. xout.Element("Publisher", this->Publisher);
  369. }
  370. if (!this->ProductUrl.empty()) {
  371. xout.Element("ProductUrl", this->ProductUrl);
  372. }
  373. // Logo
  374. if (!this->Logo.empty()) {
  375. std::string srcName = cmSystemTools::GetFilenameName(this->Logo);
  376. std::string suffix = cmSystemTools::GetFilenameLastExtension(srcName);
  377. std::string name = "cm_logo" + suffix;
  378. std::string path = this->Directory + "/config/" + name;
  379. cmsys::SystemTools::CopyFileIfDifferent(this->Logo, path);
  380. xout.Element("Logo", name);
  381. }
  382. // Banner
  383. if (!this->Banner.empty()) {
  384. std::string name = cmSystemTools::GetFilenameName(this->Banner);
  385. std::string path = this->Directory + "/config/" + name;
  386. cmsys::SystemTools::CopyFileIfDifferent(this->Banner, path);
  387. xout.Element("Banner", name);
  388. }
  389. // Watermark
  390. if (!this->Watermark.empty()) {
  391. std::string name = cmSystemTools::GetFilenameName(this->Watermark);
  392. std::string path = this->Directory + "/config/" + name;
  393. cmsys::SystemTools::CopyFileIfDifferent(this->Watermark, path);
  394. xout.Element("Watermark", name);
  395. }
  396. // Background
  397. if (!this->Background.empty()) {
  398. std::string name = cmSystemTools::GetFilenameName(this->Background);
  399. std::string path = this->Directory + "/config/" + name;
  400. cmsys::SystemTools::CopyFileIfDifferent(this->Background, path);
  401. xout.Element("Background", name);
  402. }
  403. // Attributes introduced in QtIFW 1.4.0
  404. if (!this->IsVersionLess("1.4")) {
  405. // ApplicationIcon
  406. if (!this->InstallerApplicationIcon.empty()) {
  407. std::string srcName =
  408. cmSystemTools::GetFilenameName(this->InstallerApplicationIcon);
  409. std::string suffix = cmSystemTools::GetFilenameLastExtension(srcName);
  410. std::string name = "cm_appicon" + suffix;
  411. std::string path = this->Directory + "/config/" + name;
  412. cmsys::SystemTools::CopyFileIfDifferent(this->InstallerApplicationIcon,
  413. path);
  414. // The actual file is looked up by attaching a '.icns' (macOS),
  415. // '.ico' (Windows). No functionality on Unix.
  416. name = cmSystemTools::GetFilenameWithoutExtension(name);
  417. xout.Element("InstallerApplicationIcon", name);
  418. }
  419. // WindowIcon
  420. if (!this->InstallerWindowIcon.empty()) {
  421. std::string srcName =
  422. cmSystemTools::GetFilenameName(this->InstallerWindowIcon);
  423. std::string suffix = cmSystemTools::GetFilenameLastExtension(srcName);
  424. std::string name = "cm_winicon" + suffix;
  425. std::string path = this->Directory + "/config/" + name;
  426. cmsys::SystemTools::CopyFileIfDifferent(this->InstallerWindowIcon, path);
  427. xout.Element("InstallerWindowIcon", name);
  428. }
  429. }
  430. // Attributes introduced in QtIFW 2.0.0
  431. if (!this->IsVersionLess("2.0")) {
  432. // WizardDefaultWidth
  433. if (!this->WizardDefaultWidth.empty()) {
  434. xout.Element("WizardDefaultWidth", this->WizardDefaultWidth);
  435. }
  436. // WizardDefaultHeight
  437. if (!this->WizardDefaultHeight.empty()) {
  438. xout.Element("WizardDefaultHeight", this->WizardDefaultHeight);
  439. }
  440. // Start menu directory
  441. if (!this->StartMenuDir.empty()) {
  442. xout.Element("StartMenuDir", this->StartMenuDir);
  443. }
  444. // Maintenance tool
  445. if (!this->MaintenanceToolName.empty()) {
  446. xout.Element("MaintenanceToolName", this->MaintenanceToolName);
  447. }
  448. // Maintenance tool ini file
  449. if (!this->MaintenanceToolIniFile.empty()) {
  450. xout.Element("MaintenanceToolIniFile", this->MaintenanceToolIniFile);
  451. }
  452. if (!this->AllowNonAsciiCharacters.empty()) {
  453. xout.Element("AllowNonAsciiCharacters", this->AllowNonAsciiCharacters);
  454. }
  455. if (!this->AllowSpaceInPath.empty()) {
  456. xout.Element("AllowSpaceInPath", this->AllowSpaceInPath);
  457. }
  458. // Control script (copy to config dir)
  459. if (!this->ControlScript.empty()) {
  460. std::string name = cmSystemTools::GetFilenameName(this->ControlScript);
  461. std::string path = this->Directory + "/config/" + name;
  462. cmsys::SystemTools::CopyFileIfDifferent(this->ControlScript, path);
  463. xout.Element("ControlScript", name);
  464. }
  465. } else {
  466. // CPack IFW default policy
  467. xout.Comment("CPack IFW default policy for QtIFW less 2.0");
  468. xout.Element("AllowNonAsciiCharacters", "true");
  469. xout.Element("AllowSpaceInPath", "true");
  470. }
  471. // Target dir
  472. if (!this->TargetDir.empty()) {
  473. xout.Element("TargetDir", this->TargetDir);
  474. }
  475. // Admin target dir
  476. if (!this->AdminTargetDir.empty()) {
  477. xout.Element("AdminTargetDir", this->AdminTargetDir);
  478. }
  479. // Remote repositories
  480. if (!this->RemoteRepositories.empty()) {
  481. xout.StartElement("RemoteRepositories");
  482. for (cmCPackIFWRepository* r : this->RemoteRepositories) {
  483. r->WriteRepositoryConfig(xout);
  484. }
  485. xout.EndElement();
  486. }
  487. // Attributes introduced in QtIFW 3.0.0
  488. if (!this->IsVersionLess("3.0")) {
  489. // WizardStyle
  490. if (!this->WizardStyle.empty()) {
  491. xout.Element("WizardStyle", this->WizardStyle);
  492. }
  493. // Stylesheet (copy to config dir)
  494. if (!this->StyleSheet.empty()) {
  495. std::string name = cmSystemTools::GetFilenameName(this->StyleSheet);
  496. std::string path = this->Directory + "/config/" + name;
  497. cmsys::SystemTools::CopyFileIfDifferent(this->StyleSheet, path);
  498. xout.Element("StyleSheet", name);
  499. }
  500. // TitleColor
  501. if (!this->TitleColor.empty()) {
  502. xout.Element("TitleColor", this->TitleColor);
  503. }
  504. }
  505. // Attributes introduced in QtIFW 4.0.0
  506. if (!this->IsVersionLess("4.0")) {
  507. // WizardShowPageList
  508. if (!this->WizardShowPageList.empty()) {
  509. xout.Element("WizardShowPageList", this->WizardShowPageList);
  510. }
  511. // DisableCommandLineInterface
  512. if (!this->DisableCommandLineInterface.empty()) {
  513. xout.Element("DisableCommandLineInterface",
  514. this->DisableCommandLineInterface);
  515. }
  516. // RunProgram
  517. if (!this->RunProgram.empty()) {
  518. xout.Element("RunProgram", this->RunProgram);
  519. }
  520. // RunProgramArguments
  521. if (!this->RunProgramArguments.empty()) {
  522. xout.StartElement("RunProgramArguments");
  523. for (const auto& arg : this->RunProgramArguments) {
  524. xout.Element("Argument", arg);
  525. }
  526. xout.EndElement();
  527. }
  528. // RunProgramDescription
  529. if (!this->RunProgramDescription.empty()) {
  530. xout.Element("RunProgramDescription", this->RunProgramDescription);
  531. }
  532. }
  533. if (!this->RemoveTargetDir.empty()) {
  534. xout.Element("RemoveTargetDir", this->RemoveTargetDir);
  535. }
  536. // Product images (copy to config dir)
  537. if (!this->IsVersionLess("4.0") && !this->ProductImages.empty()) {
  538. xout.StartElement("ProductImages");
  539. for (auto const& srcImg : this->ProductImages) {
  540. std::string name = cmSystemTools::GetFilenameName(srcImg);
  541. std::string dstImg = this->Directory + "/config/" + name;
  542. cmsys::SystemTools::CopyFileIfDifferent(srcImg, dstImg);
  543. xout.Element("Image", name);
  544. }
  545. xout.EndElement();
  546. }
  547. // Resources (copy to resources dir)
  548. if (!this->Resources.empty()) {
  549. std::vector<std::string> resources;
  550. cmCPackIFWResourcesParser parser(this);
  551. for (size_t i = 0; i < this->Resources.size(); i++) {
  552. if (parser.ParseResource(i)) {
  553. std::string name = cmSystemTools::GetFilenameName(this->Resources[i]);
  554. std::string path = this->Directory + "/resources/" + name;
  555. cmsys::SystemTools::CopyFileIfDifferent(this->Resources[i], path);
  556. resources.push_back(std::move(name));
  557. } else {
  558. cmCPackIFWLogger(WARNING,
  559. "Can't copy resources from \""
  560. << this->Resources[i]
  561. << "\". Resource will be skipped." << std::endl);
  562. }
  563. }
  564. this->Resources = resources;
  565. }
  566. xout.EndElement();
  567. xout.EndDocument();
  568. }
  569. void cmCPackIFWInstaller::GeneratePackageFiles()
  570. {
  571. if (this->Packages.empty() || this->Generator->IsOnePackage()) {
  572. // Generate default package
  573. cmCPackIFWPackage package;
  574. package.Generator = this->Generator;
  575. package.Installer = this;
  576. // Check package group
  577. if (cmValue option = this->GetOption("CPACK_IFW_PACKAGE_GROUP")) {
  578. package.ConfigureFromGroup(*option);
  579. std::string forcedOption = "CPACK_IFW_COMPONENT_GROUP_" +
  580. cmsys::SystemTools::UpperCase(*option) + "_FORCED_INSTALLATION";
  581. if (!this->GetOption(forcedOption)) {
  582. package.ForcedInstallation = "true";
  583. }
  584. } else {
  585. package.ConfigureFromOptions();
  586. }
  587. package.GeneratePackageFile();
  588. return;
  589. }
  590. // Generate packages meta information
  591. for (auto& p : this->Packages) {
  592. cmCPackIFWPackage* package = p.second;
  593. package->GeneratePackageFile();
  594. }
  595. }