Updated formatting of documentation plus a little reorganization.
[cmake.git] / Source / cmComputeLinkInformation.h
blobd2b3c09b704c6a56f4fb3410fa7fdf6d6e8dbbfd
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmComputeLinkInformation.h,v $
5 Language: C++
6 Date: $Date: 2009-08-24 17:15:47 $
7 Version: $Revision: 1.25 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #ifndef cmComputeLinkInformation_h
18 #define cmComputeLinkInformation_h
20 #include "cmStandardIncludes.h"
22 #include <cmsys/RegularExpression.hxx>
24 class cmake;
25 class cmGlobalGenerator;
26 class cmLocalGenerator;
27 class cmMakefile;
28 class cmTarget;
29 class cmOrderDirectories;
31 /** \class cmComputeLinkInformation
32 * \brief Compute link information for a target in one configuration.
34 class cmComputeLinkInformation
36 public:
37 cmComputeLinkInformation(cmTarget* target, const char* config);
38 ~cmComputeLinkInformation();
39 bool Compute();
41 struct Item
43 Item(): Value(), IsPath(true), Target(0) {}
44 Item(Item const& item):
45 Value(item.Value), IsPath(item.IsPath), Target(item.Target) {}
46 Item(std::string const& v, bool p, cmTarget* target = 0):
47 Value(v), IsPath(p), Target(target) {}
48 std::string Value;
49 bool IsPath;
50 cmTarget* Target;
52 typedef std::vector<Item> ItemVector;
53 ItemVector const& GetItems();
54 std::vector<std::string> const& GetDirectories();
55 std::vector<std::string> const& GetDepends();
56 std::vector<std::string> const& GetFrameworkPaths();
57 const char* GetLinkLanguage() const { return this->LinkLanguage; }
58 std::vector<std::string> const& GetRuntimeSearchPath();
59 std::string const& GetRuntimeFlag() const { return this->RuntimeFlag; }
60 std::string const& GetRuntimeSep() const { return this->RuntimeSep; }
61 void GetRPath(std::vector<std::string>& runtimeDirs, bool for_install);
62 std::string GetRPathString(bool for_install);
63 std::string GetChrpathString();
64 std::set<cmTarget*> const& GetSharedLibrariesLinked();
66 std::string const& GetRPathLinkFlag() const { return this->RPathLinkFlag; }
67 std::string GetRPathLinkString();
68 private:
69 void AddItem(std::string const& item, cmTarget* tgt);
70 void AddSharedDepItem(std::string const& item, cmTarget* tgt);
72 // Output information.
73 ItemVector Items;
74 std::vector<std::string> Directories;
75 std::vector<std::string> Depends;
76 std::vector<std::string> FrameworkPaths;
77 std::vector<std::string> RuntimeSearchPath;
78 std::set<cmTarget*> SharedLibrariesLinked;
80 // Context information.
81 cmTarget* Target;
82 cmMakefile* Makefile;
83 cmLocalGenerator* LocalGenerator;
84 cmGlobalGenerator* GlobalGenerator;
85 cmake* CMakeInstance;
87 // Configuration information.
88 const char* Config;
89 const char* LinkLanguage;
91 // Modes for dealing with dependent shared libraries.
92 enum SharedDepMode
94 SharedDepModeNone, // Drop
95 SharedDepModeDir, // List dir in -rpath-link flag
96 SharedDepModeLibDir, // List dir in linker search path
97 SharedDepModeLink // List file on link line
100 // System info.
101 bool UseImportLibrary;
102 const char* LoaderFlag;
103 std::string LibLinkFlag;
104 std::string LibLinkFileFlag;
105 std::string LibLinkSuffix;
106 std::string RuntimeFlag;
107 std::string RuntimeSep;
108 std::string RuntimeAlways;
109 bool RuntimeUseChrpath;
110 bool NoSONameUsesPath;
111 bool LinkWithRuntimePath;
112 std::string RPathLinkFlag;
113 SharedDepMode SharedDependencyMode;
115 // Link type adjustment.
116 void ComputeLinkTypeInfo();
117 enum LinkType { LinkUnknown, LinkStatic, LinkShared };
118 LinkType StartLinkType;
119 LinkType CurrentLinkType;
120 std::string StaticLinkTypeFlag;
121 std::string SharedLinkTypeFlag;
122 bool LinkTypeEnabled;
123 void SetCurrentLinkType(LinkType lt);
124 bool ArchivesMayBeShared;
126 // Link item parsing.
127 void ComputeItemParserInfo();
128 std::vector<std::string> StaticLinkExtensions;
129 std::vector<std::string> SharedLinkExtensions;
130 std::vector<std::string> LinkExtensions;
131 std::set<cmStdString> LinkPrefixes;
132 cmsys::RegularExpression ExtractStaticLibraryName;
133 cmsys::RegularExpression ExtractSharedLibraryName;
134 cmsys::RegularExpression ExtractAnyLibraryName;
135 std::string SharedRegexString;
136 void AddLinkPrefix(const char* p);
137 void AddLinkExtension(const char* e, LinkType type);
138 std::string CreateExtensionRegex(std::vector<std::string> const& exts);
139 std::string NoCaseExpression(const char* str);
141 // Handling of link items.
142 void AddTargetItem(std::string const& item, cmTarget* target);
143 void AddFullItem(std::string const& item);
144 bool CheckImplicitDirItem(std::string const& item);
145 void AddUserItem(std::string const& item, bool pathNotKnown);
146 void AddDirectoryItem(std::string const& item);
147 void AddFrameworkItem(std::string const& item);
148 void DropDirectoryItem(std::string const& item);
149 bool CheckSharedLibNoSOName(std::string const& item);
150 void AddSharedLibNoSOName(std::string const& item);
151 void HandleBadFullItem(std::string const& item, std::string const& file);
153 // Framework info.
154 void ComputeFrameworkInfo();
155 void AddFrameworkPath(std::string const& p);
156 std::set<cmStdString> FrameworkPathsEmmitted;
157 cmsys::RegularExpression SplitFramework;
159 // Linker search path computation.
160 cmOrderDirectories* OrderLinkerSearchPath;
161 bool FinishLinkerSearchDirectories();
162 void PrintLinkPolicyDiagnosis(std::ostream&);
164 // Implicit link libraries and directories for linker language.
165 void LoadImplicitLinkInfo();
166 void AddImplicitLinkInfo();
167 void AddImplicitLinkInfo(std::string const& lang);
168 std::set<cmStdString> ImplicitLinkDirs;
169 std::set<cmStdString> ImplicitLinkLibs;
171 // Linker search path compatibility mode.
172 std::set<cmStdString> OldLinkDirMask;
173 std::vector<std::string> OldLinkDirItems;
174 std::vector<std::string> OldUserFlagItems;
175 bool OldLinkDirMode;
177 // Runtime path computation.
178 cmOrderDirectories* OrderRuntimeSearchPath;
179 void AddLibraryRuntimeInfo(std::string const& fullPath, cmTarget* target);
180 void AddLibraryRuntimeInfo(std::string const& fullPath);
182 // Dependent library path computation.
183 cmOrderDirectories* OrderDependentRPath;
186 #endif