cmForEachCommand.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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(cmMakefile* mf);
  19. ~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. cmMakefile* Makefile;
  28. int Depth;
  29. };
  30. /// Starts foreach() ... endforeach() block
  31. class cmForEachCommand : public cmCommand
  32. {
  33. public:
  34. /**
  35. * This is a virtual constructor for the command.
  36. */
  37. virtual cmCommand* Clone()
  38. {
  39. return new cmForEachCommand;
  40. }
  41. /**
  42. * This is called when the command is first encountered in
  43. * the CMakeLists.txt file.
  44. */
  45. virtual bool InitialPass(std::vector<std::string> const& args,
  46. cmExecutionStatus &status);
  47. /**
  48. * This determines if the command is invoked when in script mode.
  49. */
  50. virtual bool IsScriptable() const { return true; }
  51. /**
  52. * The name of the command as specified in CMakeList.txt.
  53. */
  54. virtual std::string GetName() const { return "foreach";}
  55. cmTypeMacro(cmForEachCommand, cmCommand);
  56. private:
  57. bool HandleInMode(std::vector<std::string> const& args);
  58. };
  59. #endif