packaging: Initial packaging
[platform/upstream/cmake.git] / Source / cmInstallTargetGenerator.h
1 /*============================================================================
2   CMake - Cross Platform Makefile Generator
3   Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
4
5   Distributed under the OSI-approved BSD License (the "License");
6   see accompanying file Copyright.txt for details.
7
8   This software is distributed WITHOUT ANY WARRANTY; without even the
9   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10   See the License for more information.
11 ============================================================================*/
12 #ifndef cmInstallTargetGenerator_h
13 #define cmInstallTargetGenerator_h
14
15 #include "cmInstallGenerator.h"
16 #include "cmTarget.h"
17 #include "cmGeneratorTarget.h"
18
19 /** \class cmInstallTargetGenerator
20  * \brief Generate target installation rules.
21  */
22 class cmInstallTargetGenerator: public cmInstallGenerator
23 {
24 public:
25   cmInstallTargetGenerator(
26     cmTarget& t, const char* dest, bool implib,
27     const char* file_permissions = "",
28     std::vector<std::string> const& configurations
29     = std::vector<std::string>(),
30     const char* component = "Unspecified",
31     bool optional = false
32     );
33   virtual ~cmInstallTargetGenerator();
34
35   /** Select the policy for installing shared library linkable name
36       symlinks.  */
37   enum NamelinkModeType
38   {
39     NamelinkModeNone,
40     NamelinkModeOnly,
41     NamelinkModeSkip
42   };
43   void SetNamelinkMode(NamelinkModeType mode) { this->NamelinkMode = mode; }
44   NamelinkModeType GetNamelinkMode() const { return this->NamelinkMode; }
45
46   std::string GetInstallFilename(const char* config) const;
47
48   enum NameType
49   {
50     NameNormal,
51     NameImplib,
52     NameSO,
53     NameReal
54   };
55
56   static std::string GetInstallFilename(cmTarget*target, const char* config,
57                                         NameType nameType = NameNormal);
58
59   cmTarget* GetTarget() const { return this->Target; }
60   bool IsImportLibrary() const { return this->ImportLibrary; }
61
62 protected:
63   virtual void GenerateScript(std::ostream& os);
64   virtual void GenerateScriptForConfig(std::ostream& os,
65                                        const char* config,
66                                        Indent const& indent);
67   typedef void (cmInstallTargetGenerator::*TweakMethod)(
68     std::ostream&, Indent const&, const char*, std::string const&
69     );
70   void AddTweak(std::ostream& os, Indent const& indent,
71                 const char* config, std::string const& file,
72                 TweakMethod tweak);
73   void AddTweak(std::ostream& os, Indent const& indent,
74                 const char* config, std::vector<std::string> const& files,
75                 TweakMethod tweak);
76   std::string GetDestDirPath(std::string const& file);
77   void PreReplacementTweaks(std::ostream& os, Indent const& indent,
78                             const char* config, std::string const& file);
79   void PostReplacementTweaks(std::ostream& os, Indent const& indent,
80                              const char* config, std::string const& file);
81   void AddInstallNamePatchRule(std::ostream& os, Indent const& indent,
82                                const char* config,
83                                const std::string& toDestDirPath);
84   void AddChrpathPatchRule(std::ostream& os, Indent const& indent,
85                            const char* config,
86                            std::string const& toDestDirPath);
87   void AddRPathCheckRule(std::ostream& os, Indent const& indent,
88                          const char* config,
89                          std::string const& toDestDirPath);
90
91   void AddStripRule(std::ostream& os, Indent const& indent,
92                     const std::string& toDestDirPath);
93   void AddRanlibRule(std::ostream& os, Indent const& indent,
94                      const std::string& toDestDirPath);
95
96   cmTarget* Target;
97   bool ImportLibrary;
98   std::string FilePermissions;
99   bool Optional;
100   NamelinkModeType NamelinkMode;
101   cmGeneratorTarget* GeneratorTarget;
102 };
103
104 #endif