KWSys Nightly Date Stamp
[cmake.git] / Source / cmComputeTargetDepends.h
blobd1a82c1e21ba6b20091258b4316bc07bfd0f5ac0
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmComputeTargetDepends.h,v $
5 Language: C++
6 Date: $Date: 2009-08-24 13:54:27 $
7 Version: $Revision: 1.4 $
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 cmComputeTargetDepends_h
18 #define cmComputeTargetDepends_h
20 #include "cmStandardIncludes.h"
22 #include "cmGraphAdjacencyList.h"
24 #include <stack>
26 class cmComputeComponentGraph;
27 class cmGlobalGenerator;
28 class cmTarget;
30 /** \class cmComputeTargetDepends
31 * \brief Compute global interdependencies among targets.
33 * Static libraries may form cycles in the target dependency graph.
34 * This class evaluates target dependencies globally and adjusts them
35 * to remove cycles while preserving a safe build order.
37 class cmComputeTargetDepends
39 public:
40 cmComputeTargetDepends(cmGlobalGenerator* gg);
41 ~cmComputeTargetDepends();
43 bool Compute();
45 std::vector<cmTarget*> const& GetTargets() const { return this->Targets; }
46 void GetTargetDirectDepends(cmTarget* t, std::set<cmTarget*>& deps);
47 private:
48 void CollectTargets();
49 void CollectDepends();
50 void CollectTargetDepends(int depender_index);
51 void AddTargetDepend(int depender_index, const char* dependee_name,
52 bool linking);
53 void ComputeFinalDepends(cmComputeComponentGraph const& ccg);
55 cmGlobalGenerator* GlobalGenerator;
56 bool DebugMode;
57 bool NoCycles;
59 // Collect all targets.
60 std::vector<cmTarget*> Targets;
61 std::map<cmTarget*, int> TargetIndex;
63 // Represent the target dependency graph. The entry at each
64 // top-level index corresponds to a depender whose dependencies are
65 // listed.
66 typedef cmGraphNodeList NodeList;
67 typedef cmGraphAdjacencyList Graph;
68 Graph InitialGraph;
69 Graph FinalGraph;
70 void DisplayGraph(Graph const& graph, const char* name);
72 // Deal with connected components.
73 void DisplayComponents(cmComputeComponentGraph const& ccg);
74 bool CheckComponents(cmComputeComponentGraph const& ccg);
75 void ComplainAboutBadComponent(cmComputeComponentGraph const& ccg, int c);
78 #endif