1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmComputeLinkInformation.h,v $
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>
25 class cmGlobalGenerator
;
26 class cmLocalGenerator
;
29 class cmOrderDirectories
;
31 /** \class cmComputeLinkInformation
32 * \brief Compute link information for a target in one configuration.
34 class cmComputeLinkInformation
37 cmComputeLinkInformation(cmTarget
* target
, const char* config
);
38 ~cmComputeLinkInformation();
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
) {}
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();
69 void AddItem(std::string
const& item
, cmTarget
* tgt
);
70 void AddSharedDepItem(std::string
const& item
, cmTarget
* tgt
);
72 // Output information.
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.
83 cmLocalGenerator
* LocalGenerator
;
84 cmGlobalGenerator
* GlobalGenerator
;
87 // Configuration information.
89 const char* LinkLanguage
;
91 // Modes for dealing with dependent shared libraries.
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
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
);
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
;
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
;