cmCPackRPMGenerator.h 2.5 KB

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