cmTargetDepend.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #ifndef cmTargetDepend_h
  4. #define cmTargetDepend_h
  5. #include "cmConfigure.h" // IWYU pragma: keep
  6. #include <set>
  7. class cmGeneratorTarget;
  8. /** One edge in the global target dependency graph.
  9. It may be marked as a 'link' or 'util' edge or both. */
  10. class cmTargetDepend
  11. {
  12. cmGeneratorTarget const* Target;
  13. // The set order depends only on the Target, so we use
  14. // mutable members to achieve a map with set syntax.
  15. mutable bool Link;
  16. mutable bool Util;
  17. mutable cmListFileBacktrace Backtrace;
  18. public:
  19. cmTargetDepend(cmGeneratorTarget const* t)
  20. : Target(t)
  21. , Link(false)
  22. , Util(false)
  23. {
  24. }
  25. operator cmGeneratorTarget const*() const { return this->Target; }
  26. cmGeneratorTarget const* operator->() const { return this->Target; }
  27. cmGeneratorTarget const& operator*() const { return *this->Target; }
  28. friend bool operator<(cmTargetDepend const& l, cmTargetDepend const& r)
  29. {
  30. return l.Target < r.Target;
  31. }
  32. void SetType(bool strong) const
  33. {
  34. if (strong) {
  35. this->Util = true;
  36. } else {
  37. this->Link = true;
  38. }
  39. }
  40. void SetBacktrace(cmListFileBacktrace const& bt) const
  41. {
  42. this->Backtrace = bt;
  43. }
  44. bool IsLink() const { return this->Link; }
  45. bool IsUtil() const { return this->Util; }
  46. cmListFileBacktrace const& GetBacktrace() const { return this->Backtrace; }
  47. };
  48. /** Unordered set of (direct) dependencies of a target. */
  49. class cmTargetDependSet : public std::set<cmTargetDepend>
  50. {
  51. };
  52. #endif