cmake/Source/cmTest.cxx

76 lines
1.7 KiB
C++
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmTest.h"
2016-07-09 11:21:54 +02:00
#include "cmMakefile.h"
2016-10-30 18:24:19 +01:00
#include "cmProperty.h"
#include "cmState.h"
2021-11-20 13:41:27 +01:00
#include "cmValue.h"
2009-10-04 10:30:41 +03:00
cmTest::cmTest(cmMakefile* mf)
2022-08-04 22:12:04 +02:00
: Backtrace(mf->GetBacktrace())
2024-04-14 22:45:38 +02:00
, PolicyStatusCMP0158(mf->GetPolicyStatus(cmPolicies::CMP0158))
{
2009-10-04 10:30:41 +03:00
this->Makefile = mf;
this->OldStyle = true;
}
2019-11-11 23:01:05 +01:00
cmTest::~cmTest() = default;
2009-10-04 10:30:41 +03:00
cmListFileBacktrace const& cmTest::GetBacktrace() const
{
2015-04-27 22:25:09 +02:00
return this->Backtrace;
2009-10-04 10:30:41 +03:00
}
2015-04-27 22:25:09 +02:00
void cmTest::SetName(const std::string& name)
{
this->Name = name;
}
2009-10-04 10:30:41 +03:00
void cmTest::SetCommand(std::vector<std::string> const& command)
{
this->Command = command;
}
2021-11-20 13:41:27 +01:00
cmValue cmTest::GetProperty(const std::string& prop) const
{
2021-11-20 13:41:27 +01:00
cmValue retVal = this->Properties.GetPropertyValue(prop);
2016-07-09 11:21:54 +02:00
if (!retVal) {
const bool chain =
this->Makefile->GetState()->IsPropertyChained(prop, cmProperty::TEST);
if (chain) {
2021-11-20 13:41:27 +01:00
if (cmValue p = this->Makefile->GetProperty(prop, chain)) {
return p;
2020-08-30 11:54:41 +02:00
}
}
2020-08-30 11:54:41 +02:00
return nullptr;
2016-07-09 11:21:54 +02:00
}
2021-11-20 13:41:27 +01:00
return retVal;
}
2015-04-27 22:25:09 +02:00
bool cmTest::GetPropertyAsBool(const std::string& prop) const
{
2020-02-01 23:06:01 +01:00
return cmIsOn(this->GetProperty(prop));
}
2021-11-20 13:41:27 +01:00
void cmTest::SetProperty(const std::string& prop, cmValue value)
{
this->Properties.SetProperty(prop, value);
}
2020-08-30 11:54:41 +02:00
void cmTest::AppendProperty(const std::string& prop, const std::string& value,
2016-07-09 11:21:54 +02:00
bool asString)
{
2015-11-17 17:22:37 +01:00
this->Properties.AppendProperty(prop, value, asString);
}
2020-02-01 23:06:01 +01:00
bool cmTest::GetCommandExpandLists() const
{
return this->CommandExpandLists;
}
void cmTest::SetCommandExpandLists(bool b)
{
this->CommandExpandLists = b;
}