cmTest.cxx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmTest.h"
  4. #include "cmMakefile.h"
  5. #include "cmProperty.h"
  6. #include "cmState.h"
  7. #include "cmStringAlgorithms.h"
  8. cmTest::cmTest(cmMakefile* mf)
  9. : CommandExpandLists(false)
  10. , Backtrace(mf->GetBacktrace())
  11. {
  12. this->Makefile = mf;
  13. this->OldStyle = true;
  14. }
  15. cmTest::~cmTest() = default;
  16. cmListFileBacktrace const& cmTest::GetBacktrace() const
  17. {
  18. return this->Backtrace;
  19. }
  20. void cmTest::SetName(const std::string& name)
  21. {
  22. this->Name = name;
  23. }
  24. void cmTest::SetCommand(std::vector<std::string> const& command)
  25. {
  26. this->Command = command;
  27. }
  28. const char* cmTest::GetProperty(const std::string& prop) const
  29. {
  30. const char* retVal = this->Properties.GetPropertyValue(prop);
  31. if (!retVal) {
  32. const bool chain =
  33. this->Makefile->GetState()->IsPropertyChained(prop, cmProperty::TEST);
  34. if (chain) {
  35. return this->Makefile->GetProperty(prop, chain);
  36. }
  37. }
  38. return retVal;
  39. }
  40. bool cmTest::GetPropertyAsBool(const std::string& prop) const
  41. {
  42. return cmIsOn(this->GetProperty(prop));
  43. }
  44. void cmTest::SetProperty(const std::string& prop, const char* value)
  45. {
  46. this->Properties.SetProperty(prop, value);
  47. }
  48. void cmTest::AppendProperty(const std::string& prop, const std::string& value,
  49. bool asString)
  50. {
  51. this->Properties.AppendProperty(prop, value, asString);
  52. }
  53. bool cmTest::GetCommandExpandLists() const
  54. {
  55. return this->CommandExpandLists;
  56. }
  57. void cmTest::SetCommandExpandLists(bool b)
  58. {
  59. this->CommandExpandLists = b;
  60. }