Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmComputeTargetDepends.h
blobfc07c687247f9adfc2d3c9c5a6d8ce07216388b8
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmComputeTargetDepends.h,v $
5 Language: C++
6 <<<<<<< cmComputeTargetDepends.h
7 Date: $Date: 2008/02/07 21:14:05 $
8 Version: $Revision: 1.2 $
9 =======
10 Date: $Date: 2008-08-06 21:48:53 $
11 Version: $Revision: 1.3 $
12 >>>>>>> 1.3
14 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
15 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
17 This software is distributed WITHOUT ANY WARRANTY; without even
18 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
19 PURPOSE. See the above copyright notices for more information.
21 =========================================================================*/
22 #ifndef cmComputeTargetDepends_h
23 #define cmComputeTargetDepends_h
25 #include "cmStandardIncludes.h"
27 #include "cmGraphAdjacencyList.h"
29 #include <stack>
31 class cmComputeComponentGraph;
32 class cmGlobalGenerator;
33 class cmTarget;
35 /** \class cmComputeTargetDepends
36 * \brief Compute global interdependencies among targets.
38 * Static libraries may form cycles in the target dependency graph.
39 * This class evaluates target dependencies globally and adjusts them
40 * to remove cycles while preserving a safe build order.
42 class cmComputeTargetDepends
44 public:
45 cmComputeTargetDepends(cmGlobalGenerator* gg);
46 ~cmComputeTargetDepends();
48 bool Compute();
50 std::vector<cmTarget*> const& GetTargets() const { return this->Targets; }
51 void GetTargetDirectDepends(cmTarget* t, std::set<cmTarget*>& deps);
52 private:
53 void CollectTargets();
54 void CollectDepends();
55 void CollectTargetDepends(int depender_index);
56 void AddTargetDepend(int depender_index, const char* dependee_name,
57 bool linking);
58 void ComputeFinalDepends(cmComputeComponentGraph const& ccg);
60 cmGlobalGenerator* GlobalGenerator;
61 bool DebugMode;
63 // Collect all targets.
64 std::vector<cmTarget*> Targets;
65 std::map<cmTarget*, int> TargetIndex;
67 // Represent the target dependency graph. The entry at each
68 // top-level index corresponds to a depender whose dependencies are
69 // listed.
70 typedef cmGraphNodeList NodeList;
71 typedef cmGraphAdjacencyList Graph;
72 Graph InitialGraph;
73 Graph FinalGraph;
74 void DisplayGraph(Graph const& graph, const char* name);
76 // Deal with connected components.
77 void DisplayComponents(cmComputeComponentGraph const& ccg);
78 bool CheckComponents(cmComputeComponentGraph const& ccg);
79 void ComplainAboutBadComponent(cmComputeComponentGraph const& ccg, int c);
82 #endif