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
11 #include <cm/string_view>
13 #include "cmCPackComponentGroup.h"
14 #include "cmCPackGenerator.h"
18 /** \class cmCPackPKGGenerator
19 * \brief A generator for pkg files
22 class cmCPackPKGGenerator
: public cmCPackGenerator
25 cmCPackTypeMacro(cmCPackPKGGenerator
, cmCPackGenerator
);
30 cmCPackPKGGenerator();
31 ~cmCPackPKGGenerator() override
;
33 bool SupportsComponentInstallation() const override
;
36 int InitializeInternal() override
;
37 const char* GetOutputPostfix() override
{ return "darwin"; }
39 // Copies or creates the resource file with the given name to the
40 // package or package staging directory dirName. The variable
41 // CPACK_RESOURCE_FILE_${NAME} (where ${NAME} is the uppercased
42 // version of name) specifies the input file to use for this file,
43 // which will be configured via ConfigureFile.
44 bool CopyCreateResourceFile(const std::string
& name
,
45 const std::string
& dirName
);
46 bool CopyResourcePlistFile(const std::string
& name
,
47 const char* outName
= nullptr);
49 int CopyInstallScript(const std::string
& resdir
, const std::string
& script
,
50 const std::string
& name
);
52 // Retrieve the name of package file that will be generated for this
53 // component. The name is just the file name with extension, and
54 // does not include the subdirectory.
55 std::string
GetPackageName(const cmCPackComponent
& component
);
57 // Writes a distribution.dist file, which turns a metapackage into a
58 // full-fledged distribution. This file is used to describe
59 // inter-component dependencies. metapackageFile is the name of the
60 // metapackage for the distribution. Only valid for a
61 // component-based install.
62 void WriteDistributionFile(const char* metapackageFile
, const char* genName
);
64 // Subroutine of WriteDistributionFile that writes out the
65 // dependency attributes for inter-component dependencies.
66 void AddDependencyAttributes(const cmCPackComponent
& component
,
67 std::set
<const cmCPackComponent
*>& visited
,
68 std::ostringstream
& out
);
70 // Subroutine of WriteDistributionFile that writes out the
71 // reverse dependency attributes for inter-component dependencies.
72 void AddReverseDependencyAttributes(
73 const cmCPackComponent
& component
,
74 std::set
<const cmCPackComponent
*>& visited
, std::ostringstream
& out
);
76 // Generates XML that encodes the hierarchy of component groups and
77 // their components in a form that can be used by distribution
79 void CreateChoiceOutline(const cmCPackComponentGroup
& group
,
82 /// Create the "choice" XML element to describe a component group
83 /// for the installer GUI.
84 void CreateChoice(const cmCPackComponentGroup
& group
, cmXMLWriter
& xout
);
86 /// Create the "choice" XML element to describe a component for the
88 void CreateChoice(const cmCPackComponent
& component
, cmXMLWriter
& xout
);
90 /// Creates a background in the distribution XML.
91 void CreateBackground(const char* themeName
, const char* metapackageFile
,
92 cm::string_view genName
, cmXMLWriter
& xout
);
94 /// Create the "domains" XML element to indicate where the product can
96 void CreateDomains(cmXMLWriter
& xout
);
98 // The PostFlight component when creating a metapackage
99 cmCPackComponent PostFlightComponent
;