cmCPackRPMGenerator.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 <string>
  6. #include "cmCPackGenerator.h"
  7. /** \class cmCPackRPMGenerator
  8. * \brief A generator for RPM packages
  9. * The idea of the CPack RPM generator is to use
  10. * as minimal C++ code as possible.
  11. * Ideally the C++ part of the CPack RPM generator
  12. * will only 'execute' (aka ->ReadListFile) several
  13. * CMake macros files.
  14. */
  15. class cmCPackRPMGenerator : public cmCPackGenerator
  16. {
  17. public:
  18. cmCPackTypeMacro(cmCPackRPMGenerator, cmCPackGenerator);
  19. /**
  20. * Construct generator
  21. */
  22. cmCPackRPMGenerator();
  23. ~cmCPackRPMGenerator() override;
  24. static bool CanGenerate()
  25. {
  26. #ifdef __APPLE__
  27. // on MacOS enable CPackRPM iff rpmbuild is found
  28. std::vector<std::string> locations;
  29. locations.emplace_back("/sw/bin"); // Fink
  30. locations.emplace_back("/opt/local/bin"); // MacPorts
  31. return !cmSystemTools::FindProgram("rpmbuild").empty();
  32. #else
  33. // legacy behavior on other systems
  34. return true;
  35. #endif
  36. }
  37. protected:
  38. int InitializeInternal() override;
  39. int PackageFiles() override;
  40. /**
  41. * This method factors out the work done in component packaging case.
  42. */
  43. int PackageOnePack(std::string const& initialToplevel,
  44. std::string const& packageName);
  45. /**
  46. * The method used to package files when component
  47. * install is used. This will create one
  48. * archive for each component group.
  49. */
  50. int PackageComponents(bool ignoreGroup);
  51. /**
  52. * Special case of component install where all
  53. * components will be put in a single installer.
  54. */
  55. int PackageComponentsAllInOne(const std::string& compInstDirName);
  56. const char* GetOutputExtension() override { return ".rpm"; }
  57. bool SupportsComponentInstallation() const override;
  58. std::string GetComponentInstallDirNameSuffix(
  59. const std::string& componentName) override;
  60. void AddGeneratedPackageNames();
  61. };