cmConditionEvaluator.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #pragma once
  4. #include "cmConfigure.h" // IWYU pragma: keep
  5. #include <list>
  6. #include <string>
  7. #include <vector>
  8. #include <cmext/string_view>
  9. #include "cmExpandedCommandArgument.h"
  10. #include "cmListFileCache.h"
  11. #include "cmMessageType.h"
  12. #include "cmPolicies.h"
  13. #include "cmProperty.h"
  14. class cmMakefile;
  15. class cmConditionEvaluator
  16. {
  17. public:
  18. using cmArgumentList = std::list<cmExpandedCommandArgument>;
  19. cmConditionEvaluator(cmMakefile& makefile, cmListFileBacktrace bt);
  20. // this is a shared function for both If and Else to determine if the
  21. // arguments were valid, and if so, was the response true. If there is
  22. // an error, the errorString will be set.
  23. bool IsTrue(const std::vector<cmExpandedCommandArgument>& args,
  24. std::string& errorString, MessageType& status);
  25. private:
  26. // Filter the given variable definition based on policy CMP0054.
  27. cmProp GetDefinitionIfUnquoted(
  28. const cmExpandedCommandArgument& argument) const;
  29. cmProp GetVariableOrString(const cmExpandedCommandArgument& argument) const;
  30. bool IsKeyword(cm::string_view keyword,
  31. cmExpandedCommandArgument& argument) const;
  32. bool GetBooleanValue(cmExpandedCommandArgument& arg) const;
  33. bool GetBooleanValueOld(cmExpandedCommandArgument const& arg,
  34. bool one) const;
  35. bool GetBooleanValueWithAutoDereference(cmExpandedCommandArgument& newArg,
  36. std::string& errorString,
  37. MessageType& status,
  38. bool oneArg = false) const;
  39. bool HandleLevel0(cmArgumentList& newArgs, std::string& errorString,
  40. MessageType& status);
  41. bool HandleLevel1(cmArgumentList& newArgs, std::string&, MessageType&);
  42. bool HandleLevel2(cmArgumentList& newArgs, std::string& errorString,
  43. MessageType& status);
  44. bool HandleLevel3(cmArgumentList& newArgs, std::string& errorString,
  45. MessageType& status);
  46. bool HandleLevel4(cmArgumentList& newArgs, std::string& errorString,
  47. MessageType& status);
  48. cmMakefile& Makefile;
  49. cmListFileBacktrace Backtrace;
  50. cmPolicies::PolicyStatus Policy12Status;
  51. cmPolicies::PolicyStatus Policy54Status;
  52. cmPolicies::PolicyStatus Policy57Status;
  53. cmPolicies::PolicyStatus Policy64Status;
  54. };