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