cmCPackInnoSetupGenerator.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #pragma once
  4. #include <map>
  5. #include <string>
  6. #include <vector>
  7. #include "cmCPackGenerator.h"
  8. #include "cmValue.h"
  9. using cmCPackInnoSetupKeyValuePairs = std::map<std::string, std::string>;
  10. class cmCPackComponentGroup;
  11. class cmCPackComponent;
  12. /** \class cmCPackInnoSetupGenerator
  13. * \brief A generator for Inno Setup
  14. *
  15. * https://jrsoftware.org/isinfo.php
  16. */
  17. class cmCPackInnoSetupGenerator : public cmCPackGenerator
  18. {
  19. public:
  20. cmCPackTypeMacro(cmCPackInnoSetupGenerator, cmCPackGenerator);
  21. /**
  22. * Construct generator
  23. */
  24. cmCPackInnoSetupGenerator();
  25. ~cmCPackInnoSetupGenerator() override;
  26. static bool CanGenerate();
  27. protected:
  28. int InitializeInternal() override;
  29. int PackageFiles() override;
  30. inline const char* GetOutputExtension() override { return ".exe"; }
  31. inline cmCPackGenerator::CPackSetDestdirSupport SupportsSetDestdir()
  32. const override
  33. {
  34. return cmCPackGenerator::SETDESTDIR_UNSUPPORTED;
  35. }
  36. inline bool SupportsAbsoluteDestination() const override { return false; }
  37. inline bool SupportsComponentInstallation() const override { return true; }
  38. private:
  39. bool ProcessSetupSection();
  40. bool ProcessFiles();
  41. bool ProcessComponents();
  42. bool ConfigureISScript();
  43. bool Compile();
  44. bool BuildDownloadedComponentArchive(cmCPackComponent* component,
  45. const std::string& uploadDirectory,
  46. std::string* hash);
  47. /**
  48. * Returns the option's value or an empty string if the option isn't set.
  49. */
  50. cmValue RequireOption(const std::string& key);
  51. std::string CustomComponentInstallDirectory(
  52. const cmCPackComponent* component);
  53. /**
  54. * Translates boolean expressions into "yes" or "no", as required in
  55. * Inno Setup (only if "CPACK_INNOSETUP_USE_CMAKE_BOOL_FORMAT" is on).
  56. */
  57. std::string TranslateBool(const std::string& value);
  58. /**
  59. * Creates a typical line of key and value pairs using the given map.
  60. *
  61. * (e.g.: Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}";
  62. * GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked)
  63. */
  64. std::string ISKeyValueLine(const cmCPackInnoSetupKeyValuePairs& params);
  65. std::string CreateRecursiveComponentPath(cmCPackComponentGroup* group,
  66. const std::string& path = "");
  67. void CreateRecursiveComponentGroups(cmCPackComponentGroup* group);
  68. /**
  69. * These functions add quotes if the given value hasn't already quotes.
  70. * Paths are converted into the format used by Windows before.
  71. */
  72. std::string Quote(const std::string& string);
  73. std::string QuotePath(const std::string& path);
  74. /**
  75. * This function replaces the following 5 characters with their %-encoding:
  76. * '|' '}' ',' '%' '"'
  77. * Required for Inno Setup constants like {cm:...}
  78. */
  79. std::string PrepareForConstant(const std::string& string);
  80. std::vector<std::string> includeDirectives;
  81. cmCPackInnoSetupKeyValuePairs setupDirectives;
  82. bool toplevelProgramFolder;
  83. std::vector<std::string> languageInstructions;
  84. std::vector<std::string> fileInstructions;
  85. std::vector<std::string> dirInstructions;
  86. std::vector<std::string> typeInstructions;
  87. std::vector<std::string> componentInstructions;
  88. std::vector<std::string> iconInstructions;
  89. std::vector<std::string> desktopIconComponents;
  90. std::vector<std::string> runInstructions;
  91. std::vector<std::string> codeIncludes;
  92. };