cmGeneratorExpression.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. #include "cmStandardIncludes.h"
  11. #include <stack>
  12. #include <cmsys/RegularExpression.hxx>
  13. class cmTarget;
  14. class cmMakefile;
  15. class cmListFileBacktrace;
  16. struct cmGeneratorExpressionEvaluator;
  17. class cmCompiledGeneratorExpression;
  18. /** \class cmGeneratorExpression
  19. * \brief Evaluate generate-time query expression syntax.
  20. *
  21. * cmGeneratorExpression instances are used by build system generator
  22. * implementations to evaluate the $<> generator expression syntax.
  23. * Generator expressions are evaluated just before the generate step
  24. * writes strings into the build system. They have knowledge of the
  25. * build configuration which is not available at configure time.
  26. */
  27. class cmGeneratorExpression
  28. {
  29. public:
  30. /** Construct. */
  31. cmGeneratorExpression(cmListFileBacktrace const& backtrace);
  32. ~cmGeneratorExpression();
  33. const cmCompiledGeneratorExpression& Parse(std::string const& input);
  34. const cmCompiledGeneratorExpression& Parse(const char* input);
  35. private:
  36. cmGeneratorExpression(const cmGeneratorExpression &);
  37. void operator=(const cmGeneratorExpression &);
  38. cmListFileBacktrace const& Backtrace;
  39. cmCompiledGeneratorExpression *CompiledExpression;
  40. };
  41. class cmCompiledGeneratorExpression
  42. {
  43. public:
  44. const char* Evaluate(cmMakefile* mf, const char* config,
  45. bool quiet = false) const;
  46. /** Get set of targets found during evaluations. */
  47. std::set<cmTarget*> const& GetTargets() const
  48. { return this->Targets; }
  49. ~cmCompiledGeneratorExpression();
  50. private:
  51. cmCompiledGeneratorExpression(cmListFileBacktrace const& backtrace,
  52. const std::vector<cmGeneratorExpressionEvaluator*> &evaluators,
  53. const char *input, bool needsParsing);
  54. friend class cmGeneratorExpression;
  55. cmCompiledGeneratorExpression(const cmCompiledGeneratorExpression &);
  56. void operator=(const cmCompiledGeneratorExpression &);
  57. cmListFileBacktrace const& Backtrace;
  58. const std::vector<cmGeneratorExpressionEvaluator*> Evaluators;
  59. const char* const Input;
  60. const bool NeedsParsing;
  61. mutable std::set<cmTarget*> Targets;
  62. mutable std::string Output;
  63. };