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 5 #include "cmConfigure.h" // IWYU pragma: keep 6 7 #include <set> 8 #include <sstream> 9 #include <string> 10 11 #include <cm/string_view> 12 13 #include "cmCPackComponentGroup.h" 14 #include "cmCPackGenerator.h" 15 16 class cmXMLWriter; 17 18 /** \class cmCPackPKGGenerator 19 * \brief A generator for pkg files 20 * 21 */ 22 class cmCPackPKGGenerator : public cmCPackGenerator 23 { 24 public: 25 cmCPackTypeMacro(cmCPackPKGGenerator, cmCPackGenerator); 26 27 /** 28 * Construct generator 29 */ 30 cmCPackPKGGenerator(); 31 ~cmCPackPKGGenerator() override; 32 33 bool SupportsComponentInstallation() const override; 34 35 protected: 36 int InitializeInternal() override; GetOutputPostfix()37 const char* GetOutputPostfix() override { return "darwin"; } 38 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, const char* outName = 0); 47 48 int CopyInstallScript(const std::string& resdir, const std::string& script, 49 const std::string& name); 50 51 // Retrieve the name of package file that will be generated for this 52 // component. The name is just the file name with extension, and 53 // does not include the subdirectory. 54 std::string GetPackageName(const cmCPackComponent& component); 55 56 // Writes a distribution.dist file, which turns a metapackage into a 57 // full-fledged distribution. This file is used to describe 58 // inter-component dependencies. metapackageFile is the name of the 59 // metapackage for the distribution. Only valid for a 60 // component-based install. 61 void WriteDistributionFile(const char* metapackageFile, const char* genName); 62 63 // Subroutine of WriteDistributionFile that writes out the 64 // dependency attributes for inter-component dependencies. 65 void AddDependencyAttributes(const cmCPackComponent& component, 66 std::set<const cmCPackComponent*>& visited, 67 std::ostringstream& out); 68 69 // Subroutine of WriteDistributionFile that writes out the 70 // reverse dependency attributes for inter-component dependencies. 71 void AddReverseDependencyAttributes( 72 const cmCPackComponent& component, 73 std::set<const cmCPackComponent*>& visited, std::ostringstream& out); 74 75 // Generates XML that encodes the hierarchy of component groups and 76 // their components in a form that can be used by distribution 77 // metapackages. 78 void CreateChoiceOutline(const cmCPackComponentGroup& group, 79 cmXMLWriter& xout); 80 81 /// Create the "choice" XML element to describe a component group 82 /// for the installer GUI. 83 void CreateChoice(const cmCPackComponentGroup& group, cmXMLWriter& xout); 84 85 /// Create the "choice" XML element to describe a component for the 86 /// installer GUI. 87 void CreateChoice(const cmCPackComponent& component, cmXMLWriter& xout); 88 89 /// Creates a background in the distribution XML. 90 void CreateBackground(const char* themeName, const char* metapackageFile, 91 cm::string_view genName, cmXMLWriter& xout); 92 93 // The PostFlight component when creating a metapackage 94 cmCPackComponent PostFlightComponent; 95 }; 96