cmCPackArchiveGenerator.h 2.7 KB

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