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