ENH: put the 64 bit paths first
[cmake.git] / Source / cmComputeLinkInformation.h
blob192b905952b3ab482328263cee87e47ab455ed6a
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmComputeLinkInformation.h,v $
5 Language: C++
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>
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&);
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;
169 bool OldLinkDirMode;
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;
180 #endif