cmIfCommand.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 const char* 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. // this is a shared function for both If and Else to determine if the
  63. // arguments were valid, and if so, was the response true. If there is
  64. // an error, the errorString will be set.
  65. static bool IsTrue(const std::vector<std::string> &args,
  66. std::string &errorString, cmMakefile *mf,
  67. cmake::MessageType &status);
  68. // Get a definition from the makefile. If it doesn't exist,
  69. // return the original string.
  70. static const char* GetVariableOrString(const char* str,
  71. const cmMakefile* mf);
  72. cmTypeMacro(cmIfCommand, cmCommand);
  73. };
  74. #endif