cmCPackRPMGenerator.h 2.1 KB

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