cmTest.cxx 2.6 KB

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