cmInstallTargetGenerator.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  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 cmInstallTargetGenerator_h
  11. #define cmInstallTargetGenerator_h
  12. #include "cmInstallGenerator.h"
  13. #include "cmTarget.h"
  14. #include "cmGeneratorTarget.h"
  15. /** \class cmInstallTargetGenerator
  16. * \brief Generate target installation rules.
  17. */
  18. class cmInstallTargetGenerator: public cmInstallGenerator
  19. {
  20. public:
  21. cmInstallTargetGenerator(
  22. cmTarget& t, const char* dest, bool implib,
  23. const char* file_permissions = "",
  24. std::vector<std::string> const& configurations
  25. = std::vector<std::string>(),
  26. const char* component = "Unspecified",
  27. bool optional = false
  28. );
  29. virtual ~cmInstallTargetGenerator();
  30. /** Select the policy for installing shared library linkable name
  31. symlinks. */
  32. enum NamelinkModeType
  33. {
  34. NamelinkModeNone,
  35. NamelinkModeOnly,
  36. NamelinkModeSkip
  37. };
  38. void SetNamelinkMode(NamelinkModeType mode) { this->NamelinkMode = mode; }
  39. NamelinkModeType GetNamelinkMode() const { return this->NamelinkMode; }
  40. std::string GetInstallFilename(const char* config) const;
  41. enum NameType
  42. {
  43. NameNormal,
  44. NameImplib,
  45. NameSO,
  46. NameReal
  47. };
  48. static std::string GetInstallFilename(cmTarget*target, const char* config,
  49. NameType nameType = NameNormal);
  50. cmTarget* GetTarget() const { return this->Target; }
  51. bool IsImportLibrary() const { return this->ImportLibrary; }
  52. protected:
  53. virtual void GenerateScript(std::ostream& os);
  54. virtual void GenerateScriptForConfig(std::ostream& os,
  55. const char* config,
  56. Indent const& indent);
  57. typedef void (cmInstallTargetGenerator::*TweakMethod)(
  58. std::ostream&, Indent const&, const char*, std::string const&
  59. );
  60. void AddTweak(std::ostream& os, Indent const& indent,
  61. const char* config, std::string const& file,
  62. TweakMethod tweak);
  63. void AddTweak(std::ostream& os, Indent const& indent,
  64. const char* config, std::vector<std::string> const& files,
  65. TweakMethod tweak);
  66. std::string GetDestDirPath(std::string const& file);
  67. void PreReplacementTweaks(std::ostream& os, Indent const& indent,
  68. const char* config, std::string const& file);
  69. void PostReplacementTweaks(std::ostream& os, Indent const& indent,
  70. const char* config, std::string const& file);
  71. void AddInstallNamePatchRule(std::ostream& os, Indent const& indent,
  72. const char* config,
  73. const std::string& toDestDirPath);
  74. void AddChrpathPatchRule(std::ostream& os, Indent const& indent,
  75. const char* config,
  76. std::string const& toDestDirPath);
  77. void AddRPathCheckRule(std::ostream& os, Indent const& indent,
  78. const char* config,
  79. std::string const& toDestDirPath);
  80. void AddStripRule(std::ostream& os, Indent const& indent,
  81. const std::string& toDestDirPath);
  82. void AddRanlibRule(std::ostream& os, Indent const& indent,
  83. const std::string& toDestDirPath);
  84. cmTarget* Target;
  85. bool ImportLibrary;
  86. std::string FilePermissions;
  87. bool Optional;
  88. NamelinkModeType NamelinkMode;
  89. cmGeneratorTarget* GeneratorTarget;
  90. };
  91. #endif