1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmComputeLinkInformation.h,v $
6 Date: $Date: 2008-09-15 17:30:07 $
7 Version: $Revision: 1.22 $
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
&);
163 std::set
<cmStdString
> ImplicitLinkDirs
;
165 // Linker search path compatibility mode.
166 std::set
<cmStdString
> OldLinkDirMask
;
167 std::vector
<std::string
> OldLinkDirItems
;
168 std::vector
<std::string
> OldUserFlagItems
;
171 // Runtime path computation.
172 cmOrderDirectories
* OrderRuntimeSearchPath
;
173 void AddLibraryRuntimeInfo(std::string
const& fullPath
, cmTarget
* target
);
174 void AddLibraryRuntimeInfo(std::string
const& fullPath
);
176 // Dependent library path computation.
177 cmOrderDirectories
* OrderDependentRPath
;