cmComputeTargetDepends.h 2.4 KB

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