CMake Nightly Date Stamp
[kiteware-cmake.git] / Source / CPack / cmCPackArchiveGenerator.h
blobb8a1afa644a5d9111b33a097bccc9e7c923185a2
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
5 #include "cmConfigure.h" // IWYU pragma: keep
7 #include <iosfwd>
8 #include <string>
10 #include "cmArchiveWrite.h"
11 #include "cmCPackGenerator.h"
13 class cmCPackComponent;
15 /** \class cmCPackArchiveGenerator
16 * \brief A generator base for libarchive generation.
17 * The generator itself uses the libarchive wrapper
18 * \ref cmArchiveWrite.
21 class cmCPackArchiveGenerator : public cmCPackGenerator
23 public:
24 using Superclass = cmCPackGenerator;
26 static cmCPackGenerator* Create7ZGenerator();
27 static cmCPackGenerator* CreateTBZ2Generator();
28 static cmCPackGenerator* CreateTGZGenerator();
29 static cmCPackGenerator* CreateTXZGenerator();
30 static cmCPackGenerator* CreateTZGenerator();
31 static cmCPackGenerator* CreateTZSTGenerator();
32 static cmCPackGenerator* CreateZIPGenerator();
34 /**
35 * Construct generator
37 cmCPackArchiveGenerator(cmArchiveWrite::Compress t, std::string format,
38 std::string extension);
39 ~cmCPackArchiveGenerator() override;
40 // Used to add a header to the archive
41 virtual int GenerateHeader(std::ostream* os);
42 // component support
43 bool SupportsComponentInstallation() const override;
45 private:
46 // get archive component filename
47 std::string GetArchiveComponentFileName(const std::string& component,
48 bool isGroupName);
50 class Deduplicator;
52 protected:
53 int InitializeInternal() override;
54 /**
55 * Add the files belonging to the specified component
56 * to the provided (already opened) archive.
57 * @param[in,out] archive the archive object
58 * @param[in] component the component whose file will be added to archive
59 * @param[in] deduplicator file deduplicator utility.
61 int addOneComponentToArchive(cmArchiveWrite& archive,
62 cmCPackComponent* component,
63 Deduplicator* deduplicator);
65 /**
66 * The main package file method.
67 * If component install was required this
68 * method will call either PackageComponents or
69 * PackageComponentsAllInOne.
71 int PackageFiles() override;
72 /**
73 * The method used to package files when component
74 * install is used. This will create one
75 * archive for each component group.
77 int PackageComponents(bool ignoreGroup);
78 /**
79 * Special case of component install where all
80 * components will be put in a single installer.
82 int PackageComponentsAllInOne();
84 private:
85 const char* GetNameOfClass() override { return "cmCPackArchiveGenerator"; }
87 const char* GetOutputExtension() override
89 return this->OutputExtension.c_str();
92 int GetThreadCount() const;
94 private:
95 cmArchiveWrite::Compress Compress;
96 std::string ArchiveFormat;
97 std::string OutputExtension;