cmCPackAppImageGenerator.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file LICENSE.rst or https://cmake.org/licensing for details. */
  3. #pragma once
  4. #include <string>
  5. #include <unordered_map>
  6. #include <cm/optional>
  7. #include "cmCPackGenerator.h"
  8. /** \class cmCPackAppImageGenerator
  9. * \brief A generator for creating AppImages with CPack
  10. */
  11. class cmCPackAppImageGenerator : public cmCPackGenerator
  12. {
  13. public:
  14. cmCPackTypeMacro(cmCPackAppImageGenerator, cmCPackGenerator);
  15. char const* GetOutputExtension() override { return ".AppImage"; }
  16. cmCPackAppImageGenerator();
  17. ~cmCPackAppImageGenerator() override;
  18. protected:
  19. /**
  20. * @brief Initializes the CPack engine with our defaults
  21. */
  22. int InitializeInternal() override;
  23. /**
  24. * @brief AppImages are for single applications
  25. */
  26. bool SupportsComponentInstallation() const override { return false; }
  27. /**
  28. * Main Packaging step
  29. */
  30. int PackageFiles() override;
  31. private:
  32. /**
  33. * @brief Finds the first installed file by it's name
  34. */
  35. cm::optional<std::string> FindFile(std::string const& filename) const;
  36. /**
  37. * @brief AppImage format requires a desktop file
  38. */
  39. cm::optional<std::string> FindDesktopFile() const;
  40. /**
  41. * @brief Parses a desktop file [Desktop Entry]
  42. */
  43. std::unordered_map<std::string, std::string> ParseDesktopFile(
  44. std::string const& filePath) const;
  45. /**
  46. * @brief changes the RPATH so that AppImage can find it's libraries
  47. */
  48. bool ChangeRPath();
  49. bool PatchElfSetRPath(std::string const& file,
  50. std::string const& rpath) const;
  51. std::string AppimagetoolPath;
  52. std::string PatchElfPath;
  53. };