cmCPackRPMGenerator.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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(std::string const& compInstDirName);
  56. char const* GetOutputExtension() override { return ".rpm"; }
  57. std::string GetSanitizedDirOrFileName(std::string const& name,
  58. bool isFullName = true) const override;
  59. bool SupportsComponentInstallation() const override;
  60. std::string GetComponentInstallSuffix(
  61. std::string const& componentName) override;
  62. std::string GetComponentInstallDirNameSuffix(
  63. std::string const& componentName) override;
  64. void AddGeneratedPackageNames();
  65. };