1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmComputeTargetDepends.h,v $
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"
26 class cmComputeComponentGraph
;
27 class cmGlobalGenerator
;
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
40 cmComputeTargetDepends(cmGlobalGenerator
* gg
);
41 ~cmComputeTargetDepends();
45 std::vector
<cmTarget
*> const& GetTargets() const { return this->Targets
; }
46 void GetTargetDirectDepends(cmTarget
* t
, std::set
<cmTarget
*>& deps
);
48 void CollectTargets();
49 void CollectDepends();
50 void CollectTargetDepends(int depender_index
);
51 void AddTargetDepend(int depender_index
, const char* dependee_name
,
53 void ComputeFinalDepends(cmComputeComponentGraph
const& ccg
);
55 cmGlobalGenerator
* GlobalGenerator
;
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
66 typedef cmGraphNodeList NodeList
;
67 typedef cmGraphAdjacencyList Graph
;
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
);