cmForEachCommand.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 cmForEachCommand_h
  11. #define cmForEachCommand_h
  12. #include "cmCommand.h"
  13. #include "cmFunctionBlocker.h"
  14. #include "cmListFileCache.h"
  15. class cmForEachFunctionBlocker : public cmFunctionBlocker
  16. {
  17. public:
  18. cmForEachFunctionBlocker() {this->Depth = 0;}
  19. virtual ~cmForEachFunctionBlocker() {}
  20. virtual bool IsFunctionBlocked(const cmListFileFunction& lff,
  21. cmMakefile &mf,
  22. cmExecutionStatus &);
  23. virtual bool ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf);
  24. std::vector<std::string> Args;
  25. std::vector<cmListFileFunction> Functions;
  26. private:
  27. int Depth;
  28. };
  29. /// Starts foreach() ... endforeach() block
  30. class cmForEachCommand : public cmCommand
  31. {
  32. public:
  33. /**
  34. * This is a virtual constructor for the command.
  35. */
  36. virtual cmCommand* Clone()
  37. {
  38. return new cmForEachCommand;
  39. }
  40. /**
  41. * This is called when the command is first encountered in
  42. * the CMakeLists.txt file.
  43. */
  44. virtual bool InitialPass(std::vector<std::string> const& args,
  45. cmExecutionStatus &status);
  46. /**
  47. * This determines if the command is invoked when in script mode.
  48. */
  49. virtual bool IsScriptable() const { return true; }
  50. /**
  51. * The name of the command as specified in CMakeList.txt.
  52. */
  53. virtual const char* GetName() const { return "foreach";}
  54. cmTypeMacro(cmForEachCommand, cmCommand);
  55. private:
  56. bool HandleInMode(std::vector<std::string> const& args);
  57. };
  58. #endif