cmTest.cxx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 "cmSystemTools.h"
  8. cmTest::cmTest(cmMakefile* mf)
  9. : Backtrace(mf->GetBacktrace())
  10. {
  11. this->Makefile = mf;
  12. this->OldStyle = true;
  13. }
  14. cmTest::~cmTest()
  15. {
  16. }
  17. cmListFileBacktrace const& cmTest::GetBacktrace() const
  18. {
  19. return this->Backtrace;
  20. }
  21. void cmTest::SetName(const std::string& name)
  22. {
  23. this->Name = name;
  24. }
  25. void cmTest::SetCommand(std::vector<std::string> const& command)
  26. {
  27. this->Command = command;
  28. }
  29. const char* cmTest::GetProperty(const std::string& prop) const
  30. {
  31. const char* retVal = this->Properties.GetPropertyValue(prop);
  32. if (!retVal) {
  33. const bool chain =
  34. this->Makefile->GetState()->IsPropertyChained(prop, cmProperty::TEST);
  35. if (chain) {
  36. return this->Makefile->GetProperty(prop, chain);
  37. }
  38. }
  39. return retVal;
  40. }
  41. bool cmTest::GetPropertyAsBool(const std::string& prop) const
  42. {
  43. return cmSystemTools::IsOn(this->GetProperty(prop));
  44. }
  45. void cmTest::SetProperty(const std::string& prop, const char* value)
  46. {
  47. this->Properties.SetProperty(prop, value);
  48. }
  49. void cmTest::AppendProperty(const std::string& prop, const char* value,
  50. bool asString)
  51. {
  52. this->Properties.AppendProperty(prop, value, asString);
  53. }