1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
5 #include "cmConfigure.h" // IWYU pragma: keep
12 #include <cm/string_view>
14 #include "cmCPackGenerator.h"
16 class cmCPackComponent
;
17 class cmCPackComponentGroup
;
19 /** \class cmCPackNSISGenerator
20 * \brief A generator for NSIS files
22 * http://people.freebsd.org/~kientzle/libarchive/
24 class cmCPackNSISGenerator
: public cmCPackGenerator
27 cmCPackTypeMacro(cmCPackNSISGenerator
, cmCPackGenerator
);
29 static cmCPackGenerator
* CreateGenerator64()
31 return new cmCPackNSISGenerator(true);
37 cmCPackNSISGenerator(bool nsis64
= false);
38 ~cmCPackNSISGenerator() override
;
41 int InitializeInternal() override
;
42 void CreateMenuLinks(std::ostream
& str
, std::ostream
& deleteStr
);
43 int PackageFiles() override
;
44 const char* GetOutputExtension() override
{ return ".exe"; }
45 const char* GetOutputPostfix() override
{ return "win32"; }
47 bool GetListOfSubdirectories(const char* dir
,
48 std::vector
<std::string
>& dirs
);
50 enum cmCPackGenerator::CPackSetDestdirSupport
SupportsSetDestdir()
52 bool SupportsAbsoluteDestination() const override
;
53 bool SupportsComponentInstallation() const override
;
55 /// Produce a string that contains the NSIS code to describe a
56 /// particular component. Any added macros will be emitted via
58 std::string
CreateComponentDescription(cmCPackComponent
* component
,
59 std::ostream
& macrosOut
);
61 /// Produce NSIS code that selects all of the components that this component
62 /// depends on, recursively.
63 std::string
CreateSelectionDependenciesDescription(
64 cmCPackComponent
* component
, std::set
<cmCPackComponent
*>& visited
);
66 /// Produce NSIS code that de-selects all of the components that are
67 /// dependent on this component, recursively.
68 std::string
CreateDeselectionDependenciesDescription(
69 cmCPackComponent
* component
, std::set
<cmCPackComponent
*>& visited
);
71 /// Produce a string that contains the NSIS code to describe a
72 /// particular component group, including its components. Any
73 /// added macros will be emitted via macrosOut.
74 std::string
CreateComponentGroupDescription(cmCPackComponentGroup
* group
,
75 std::ostream
& macrosOut
);
77 /// Returns the custom install directory if available for the specified
78 /// component, otherwise $INSTDIR is returned.
79 std::string
CustomComponentInstallDirectory(cm::string_view componentName
);
81 /// Translations any newlines found in the string into \\r\\n, so that the
82 /// resulting string can be used within NSIS.
83 static std::string
TranslateNewlines(std::string str
);