1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmComputeLinkDepends.h,v $
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"
25 class cmGlobalGenerator
;
26 class cmLocalGenerator
;
30 /** \class cmComputeLinkDepends
31 * \brief Compute link dependencies for targets.
33 class cmComputeLinkDepends
36 cmComputeLinkDepends(cmTarget
* target
, const char* config
);
37 ~cmComputeLinkDepends();
39 // Basic information about each link item.
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();
55 // Context information.
58 cmLocalGenerator
* LocalGenerator
;
59 cmGlobalGenerator
* GlobalGenerator
;
62 // Configuration information.
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.
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
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
;
120 void OrderLinkEntires();
121 void VisitLinkEntry(unsigned int i
);
122 void DisplayFinalEntries();