cmCPackInnoSetupGenerator.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 char const* 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. enum class PathType
  40. {
  41. Windows,
  42. Native,
  43. };
  44. bool ProcessSetupSection();
  45. bool ProcessFiles();
  46. bool ProcessComponents();
  47. bool ConfigureISScript();
  48. bool Compile();
  49. bool BuildDownloadedComponentArchive(cmCPackComponent* component,
  50. std::string const& uploadDirectory,
  51. std::string* hash);
  52. /**
  53. * Returns the option's value or an empty string if the option isn't set.
  54. */
  55. cmValue RequireOption(std::string const& key);
  56. std::string CustomComponentInstallDirectory(
  57. cmCPackComponent const* component);
  58. /**
  59. * Translates boolean expressions into "yes" or "no", as required in
  60. * Inno Setup (only if "CPACK_INNOSETUP_USE_CMAKE_BOOL_FORMAT" is on).
  61. */
  62. std::string TranslateBool(std::string const& value);
  63. /**
  64. * Creates a typical line of key and value pairs using the given map.
  65. *
  66. * (e.g.: Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}";
  67. * GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked)
  68. */
  69. std::string ISKeyValueLine(cmCPackInnoSetupKeyValuePairs const& params);
  70. std::string CreateRecursiveComponentPath(cmCPackComponentGroup* group,
  71. std::string const& path = "");
  72. void CreateRecursiveComponentGroups(cmCPackComponentGroup* group);
  73. /**
  74. * These functions add quotes if the given value hasn't already quotes.
  75. * Paths are converted into the format used by Windows before.
  76. */
  77. std::string Quote(std::string const& string);
  78. std::string QuotePath(std::string const& path,
  79. PathType type = PathType::Windows);
  80. /**
  81. * This function replaces the following 5 characters with their %-encoding:
  82. * '|' '}' ',' '%' '"'
  83. * Required for Inno Setup constants like {cm:...}
  84. */
  85. std::string PrepareForConstant(std::string const& string);
  86. std::vector<std::string> includeDirectives;
  87. cmCPackInnoSetupKeyValuePairs setupDirectives;
  88. bool toplevelProgramFolder;
  89. std::vector<std::string> languageInstructions;
  90. std::vector<std::string> fileInstructions;
  91. std::vector<std::string> dirInstructions;
  92. std::vector<std::string> typeInstructions;
  93. std::vector<std::string> componentInstructions;
  94. std::vector<std::string> iconInstructions;
  95. std::vector<std::string> desktopIconComponents;
  96. std::vector<std::string> runInstructions;
  97. std::vector<std::string> codeIncludes;
  98. };