cmForEachCommand.h 1.5 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 cmForEachCommand_h
  4. #define cmForEachCommand_h
  5. #include "cmConfigure.h" // IWYU pragma: keep
  6. #include <string>
  7. #include <vector>
  8. #include "cm_memory.hxx"
  9. #include "cmCommand.h"
  10. #include "cmFunctionBlocker.h"
  11. #include "cmListFileCache.h"
  12. class cmExecutionStatus;
  13. class cmMakefile;
  14. class cmForEachFunctionBlocker : public cmFunctionBlocker
  15. {
  16. public:
  17. cmForEachFunctionBlocker(cmMakefile* mf);
  18. ~cmForEachFunctionBlocker() override;
  19. bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf,
  20. cmExecutionStatus&) override;
  21. bool ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) override;
  22. std::vector<std::string> Args;
  23. std::vector<cmListFileFunction> Functions;
  24. private:
  25. cmMakefile* Makefile;
  26. int Depth;
  27. };
  28. /// Starts foreach() ... endforeach() block
  29. class cmForEachCommand : public cmCommand
  30. {
  31. public:
  32. /**
  33. * This is a virtual constructor for the command.
  34. */
  35. std::unique_ptr<cmCommand> Clone() override
  36. {
  37. return cm::make_unique<cmForEachCommand>();
  38. }
  39. /**
  40. * This is called when the command is first encountered in
  41. * the CMakeLists.txt file.
  42. */
  43. bool InitialPass(std::vector<std::string> const& args,
  44. cmExecutionStatus& status) override;
  45. private:
  46. bool HandleInMode(std::vector<std::string> const& args);
  47. };
  48. #endif