Initial commit.
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmComputeLinkDepends.h
blobb7af2dc6a52691ff80bafc4d8a943b52ecc4a4c5
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmComputeLinkDepends.h,v $
5 Language: C++
6 Date: $Date: 2008/01/31 20:45:30 $
7 Version: $Revision: 1.3 $
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 cmComputeLinkDepends_h
18 #define cmComputeLinkDepends_h
20 #include "cmStandardIncludes.h"
21 #include "cmTarget.h"
23 #include <queue>
25 class cmGlobalGenerator;
26 class cmLocalGenerator;
27 class cmMakefile;
28 class cmTarget;
30 /** \class cmComputeLinkDepends
31 * \brief Compute link dependencies for targets.
33 class cmComputeLinkDepends
35 public:
36 cmComputeLinkDepends(cmTarget* target, const char* config);
37 ~cmComputeLinkDepends();
39 // Basic information about each link item.
40 struct LinkEntry
42 std::string Item;
43 cmTarget* Target;
44 bool IsSharedDep;
45 LinkEntry(): Item(), Target(0), IsSharedDep(false) {}
46 LinkEntry(LinkEntry const& r):
47 Item(r.Item), Target(r.Target), IsSharedDep(r.IsSharedDep) {}
50 typedef std::vector<LinkEntry> EntryVector;
51 EntryVector const& Compute();
53 private:
55 // Context information.
56 cmTarget* Target;
57 cmMakefile* Makefile;
58 cmLocalGenerator* LocalGenerator;
59 cmGlobalGenerator* GlobalGenerator;
60 bool DebugMode;
62 // Configuration information.
63 const char* Config;
65 // Output information.
66 EntryVector FinalLinkEntries;
68 typedef cmTarget::LinkLibraryVectorType LinkLibraryVectorType;
70 std::map<cmStdString, int>::iterator
71 AllocateLinkEntry(std::string const& item);
72 int AddLinkEntry(std::string const& item);
73 void AddVarLinkEntries(int depender_index, const char* value);
74 void AddTargetLinkEntries(int depender_index,
75 LinkLibraryVectorType const& libs);
76 void AddLinkEntries(int depender_index,
77 std::vector<std::string> const& libs);
79 // One entry for each unique item.
80 std::vector<LinkEntry> EntryList;
81 std::map<cmStdString, int> LinkEntryIndex;
83 // BFS of initial dependencies.
84 struct BFSEntry
86 int Index;
87 const char* LibDepends;
89 std::queue<BFSEntry> BFSQueue;
90 void FollowLinkEntry(BFSEntry const&);
92 // Shared libraries that are included only because they are
93 // dependencies of other shared libraries, not because they are part
94 // of the interface.
95 struct SharedDepEntry
97 std::string Item;
98 int DependerIndex;
100 std::queue<SharedDepEntry> SharedDepQueue;
101 void QueueSharedDependencies(int depender_index,
102 std::vector<std::string> const& deps);
103 void HandleSharedDependency(SharedDepEntry const& dep);
105 // Dependency inferral for each link item.
106 struct DependSet: public std::set<int> {};
107 struct DependSetList: public std::vector<DependSet> {};
108 std::vector<DependSetList*> InferredDependSets;
109 void InferDependencies();
111 // Ordering constraint graph adjacency list.
112 struct EntryConstraintSet: public std::set<int> {};
113 std::vector<EntryConstraintSet> EntryConstraintGraph;
114 void DisplayConstraintGraph();
116 // Ordering algorithm.
117 std::vector<int> EntryVisited;
118 std::set<int> EntryEmitted;
119 int WalkId;
120 void OrderLinkEntires();
121 void VisitLinkEntry(unsigned int i);
122 void DisplayFinalEntries();
125 #endif