CMake Nightly Date Stamp
[kiteware-cmake.git] / Source / CPack / cmCPackInnoSetupGenerator.h
blobe057e6c0eefe66e471850d4b53cad16f79a9b217
1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
4 #pragma once
6 #include <map>
7 #include <string>
8 #include <vector>
10 #include "cmCPackGenerator.h"
11 #include "cmValue.h"
13 using cmCPackInnoSetupKeyValuePairs = std::map<std::string, std::string>;
15 class cmCPackComponentGroup;
16 class cmCPackComponent;
18 /** \class cmCPackInnoSetupGenerator
19 * \brief A generator for Inno Setup
21 * https://jrsoftware.org/isinfo.php
23 class cmCPackInnoSetupGenerator : public cmCPackGenerator
25 public:
26 cmCPackTypeMacro(cmCPackInnoSetupGenerator, cmCPackGenerator);
28 /**
29 * Construct generator
31 cmCPackInnoSetupGenerator();
32 ~cmCPackInnoSetupGenerator() override;
34 static bool CanGenerate();
36 protected:
37 int InitializeInternal() override;
38 int PackageFiles() override;
40 inline const char* GetOutputExtension() override { return ".exe"; }
42 inline cmCPackGenerator::CPackSetDestdirSupport SupportsSetDestdir()
43 const override
45 return cmCPackGenerator::SETDESTDIR_UNSUPPORTED;
48 inline bool SupportsAbsoluteDestination() const override { return false; }
49 inline bool SupportsComponentInstallation() const override { return true; }
51 private:
52 enum class PathType
54 Windows,
55 Native,
58 bool ProcessSetupSection();
59 bool ProcessFiles();
60 bool ProcessComponents();
62 bool ConfigureISScript();
63 bool Compile();
65 bool BuildDownloadedComponentArchive(cmCPackComponent* component,
66 const std::string& uploadDirectory,
67 std::string* hash);
69 /**
70 * Returns the option's value or an empty string if the option isn't set.
72 cmValue RequireOption(const std::string& key);
74 std::string CustomComponentInstallDirectory(
75 const cmCPackComponent* component);
77 /**
78 * Translates boolean expressions into "yes" or "no", as required in
79 * Inno Setup (only if "CPACK_INNOSETUP_USE_CMAKE_BOOL_FORMAT" is on).
81 std::string TranslateBool(const std::string& value);
83 /**
84 * Creates a typical line of key and value pairs using the given map.
86 * (e.g.: Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}";
87 * GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked)
89 std::string ISKeyValueLine(const cmCPackInnoSetupKeyValuePairs& params);
91 std::string CreateRecursiveComponentPath(cmCPackComponentGroup* group,
92 const std::string& path = "");
94 void CreateRecursiveComponentGroups(cmCPackComponentGroup* group);
96 /**
97 * These functions add quotes if the given value hasn't already quotes.
98 * Paths are converted into the format used by Windows before.
100 std::string Quote(const std::string& string);
101 std::string QuotePath(const std::string& path,
102 PathType type = PathType::Windows);
105 * This function replaces the following 5 characters with their %-encoding:
106 * '|' '}' ',' '%' '"'
107 * Required for Inno Setup constants like {cm:...}
109 std::string PrepareForConstant(const std::string& string);
111 std::vector<std::string> includeDirectives;
112 cmCPackInnoSetupKeyValuePairs setupDirectives;
113 bool toplevelProgramFolder;
114 std::vector<std::string> languageInstructions;
115 std::vector<std::string> fileInstructions;
116 std::vector<std::string> dirInstructions;
117 std::vector<std::string> typeInstructions;
118 std::vector<std::string> componentInstructions;
119 std::vector<std::string> iconInstructions;
120 std::vector<std::string> desktopIconComponents;
121 std::vector<std::string> runInstructions;
122 std::vector<std::string> codeIncludes;