cmIfCommand.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 cmIfCommand_h
  11. #define cmIfCommand_h
  12. #include "cmCommand.h"
  13. #include "cmFunctionBlocker.h"
  14. class cmIfFunctionBlocker : public cmFunctionBlocker
  15. {
  16. public:
  17. cmIfFunctionBlocker() {
  18. this->HasRun = false; this->ScopeDepth = 0; }
  19. virtual ~cmIfFunctionBlocker() {}
  20. virtual bool IsFunctionBlocked(const cmListFileFunction& lff,
  21. cmMakefile &mf,
  22. cmExecutionStatus &);
  23. virtual bool ShouldRemove(const cmListFileFunction& lff,
  24. cmMakefile &mf);
  25. std::vector<cmListFileArgument> Args;
  26. std::vector<cmListFileFunction> Functions;
  27. bool IsBlocking;
  28. bool HasRun;
  29. unsigned int ScopeDepth;
  30. };
  31. /// Starts an if block
  32. class cmIfCommand : public cmCommand
  33. {
  34. public:
  35. /**
  36. * This is a virtual constructor for the command.
  37. */
  38. virtual cmCommand* Clone()
  39. {
  40. return new cmIfCommand;
  41. }
  42. /**
  43. * This overrides the default InvokeInitialPass implementation.
  44. * It records the arguments before expansion.
  45. */
  46. virtual bool InvokeInitialPass(const std::vector<cmListFileArgument>& args,
  47. cmExecutionStatus &);
  48. /**
  49. * This is called when the command is first encountered in
  50. * the CMakeLists.txt file.
  51. */
  52. virtual bool InitialPass(std::vector<std::string> const&,
  53. cmExecutionStatus &) { return false;}
  54. /**
  55. * The name of the command as specified in CMakeList.txt.
  56. */
  57. virtual std::string GetName() const { return "if";}
  58. /**
  59. * This determines if the command is invoked when in script mode.
  60. */
  61. virtual bool IsScriptable() const { return true; }
  62. // Filter the given variable definition based on policy CMP0054.
  63. static const char* GetDefinitionIfUnquoted(
  64. const cmMakefile* mf, cmExpandedCommandArgument const& argument);
  65. cmTypeMacro(cmIfCommand, cmCommand);
  66. };
  67. #endif