cmGeneratorExpression.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. /** \class cmGeneratorExpression
  17. * \brief Evaluate generate-time query expression syntax.
  18. *
  19. * cmGeneratorExpression instances are used by build system generator
  20. * implementations to evaluate the $<> generator expression syntax.
  21. * Generator expressions are evaluated just before the generate step
  22. * writes strings into the build system. They have knowledge of the
  23. * build configuration which is not available at configure time.
  24. */
  25. class cmGeneratorExpression
  26. {
  27. public:
  28. /** Construct with an evaluation context and configuration. */
  29. cmGeneratorExpression(cmMakefile* mf, const char* config,
  30. cmListFileBacktrace const& backtrace,
  31. bool quiet = false);
  32. /** Evaluate generator expressions in a string. */
  33. const char* Process(std::string const& input);
  34. const char* Process(const char* input);
  35. /** Get set of targets found during evaluations. */
  36. std::set<cmTarget*> const& GetTargets() const
  37. { return this->Targets; }
  38. private:
  39. cmMakefile* Makefile;
  40. const char* Config;
  41. cmListFileBacktrace const& Backtrace;
  42. bool Quiet;
  43. std::vector<char> Data;
  44. std::stack<size_t> Barriers;
  45. cmsys::RegularExpression TargetInfo;
  46. cmsys::RegularExpression TestConfig;
  47. std::set<cmTarget*> Targets;
  48. bool Evaluate();
  49. bool Evaluate(const char* expr, std::string& result);
  50. bool EvaluateTargetInfo(std::string& result);
  51. };