cmTargetDepend.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #pragma once
  4. #include "cmConfigure.h" // IWYU pragma: keep
  5. #include <set>
  6. #include "cmListFileCache.h"
  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 bool Cross;
  18. mutable cmListFileBacktrace Backtrace;
  19. public:
  20. cmTargetDepend(cmGeneratorTarget const* t)
  21. : Target(t)
  22. , Link(false)
  23. , Util(false)
  24. , Cross(false)
  25. {
  26. }
  27. operator cmGeneratorTarget const*() const { return this->Target; }
  28. cmGeneratorTarget const* operator->() const { return this->Target; }
  29. cmGeneratorTarget const& operator*() const { return *this->Target; }
  30. friend bool operator<(cmTargetDepend const& l, cmTargetDepend const& r)
  31. {
  32. return l.Target < r.Target;
  33. }
  34. void SetType(bool strong) const
  35. {
  36. if (strong) {
  37. this->Util = true;
  38. } else {
  39. this->Link = true;
  40. }
  41. }
  42. void SetCross(bool cross) const { this->Cross = cross; }
  43. void SetBacktrace(cmListFileBacktrace const& bt) const
  44. {
  45. this->Backtrace = bt;
  46. }
  47. bool IsLink() const { return this->Link; }
  48. bool IsUtil() const { return this->Util; }
  49. bool IsCross() const { return this->Cross; }
  50. cmListFileBacktrace const& GetBacktrace() const { return this->Backtrace; }
  51. };
  52. /** Unordered set of (direct) dependencies of a target. */
  53. class cmTargetDependSet : public std::set<cmTargetDepend>
  54. {
  55. };