cmComputeTargetDepends.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef cmComputeTargetDepends_h
  11. #define cmComputeTargetDepends_h
  12. #include "cmStandardIncludes.h"
  13. #include "cmGraphAdjacencyList.h"
  14. #include <stack>
  15. class cmComputeComponentGraph;
  16. class cmGlobalGenerator;
  17. class cmTarget;
  18. /** \class cmComputeTargetDepends
  19. * \brief Compute global interdependencies among targets.
  20. *
  21. * Static libraries may form cycles in the target dependency graph.
  22. * This class evaluates target dependencies globally and adjusts them
  23. * to remove cycles while preserving a safe build order.
  24. */
  25. class cmComputeTargetDepends
  26. {
  27. public:
  28. cmComputeTargetDepends(cmGlobalGenerator* gg);
  29. ~cmComputeTargetDepends();
  30. bool Compute();
  31. std::vector<cmTarget*> const& GetTargets() const { return this->Targets; }
  32. void GetTargetDirectDepends(cmTarget* t, std::set<cmTarget*>& deps);
  33. private:
  34. void CollectTargets();
  35. void CollectDepends();
  36. void CollectTargetDepends(int depender_index);
  37. void AddTargetDepend(int depender_index, const char* dependee_name,
  38. bool linking);
  39. void ComputeFinalDepends(cmComputeComponentGraph const& ccg);
  40. cmGlobalGenerator* GlobalGenerator;
  41. bool DebugMode;
  42. bool NoCycles;
  43. // Collect all targets.
  44. std::vector<cmTarget*> Targets;
  45. std::map<cmTarget*, int> TargetIndex;
  46. // Represent the target dependency graph. The entry at each
  47. // top-level index corresponds to a depender whose dependencies are
  48. // listed.
  49. typedef cmGraphNodeList NodeList;
  50. typedef cmGraphAdjacencyList Graph;
  51. Graph InitialGraph;
  52. Graph FinalGraph;
  53. void DisplayGraph(Graph const& graph, const char* name);
  54. // Deal with connected components.
  55. void DisplayComponents(cmComputeComponentGraph const& ccg);
  56. bool CheckComponents(cmComputeComponentGraph const& ccg);
  57. void ComplainAboutBadComponent(cmComputeComponentGraph const& ccg, int c);
  58. };
  59. #endif