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. */
|
2008-10-12 18:41:06 +02:00
|
|
|
#include "cmGetTestPropertyCommand.h"
|
|
|
|
|
2020-02-01 23:06:01 +01:00
|
|
|
#include "cmExecutionStatus.h"
|
2017-04-14 19:02:05 +02:00
|
|
|
#include "cmMakefile.h"
|
2008-10-12 18:41:06 +02:00
|
|
|
#include "cmTest.h"
|
2021-11-20 13:41:27 +01:00
|
|
|
#include "cmValue.h"
|
2017-04-14 19:02:05 +02:00
|
|
|
|
2020-02-01 23:06:01 +01:00
|
|
|
bool cmGetTestPropertyCommand(std::vector<std::string> const& args,
|
|
|
|
cmExecutionStatus& status)
|
2008-10-12 18:41:06 +02:00
|
|
|
{
|
2016-07-09 11:21:54 +02:00
|
|
|
if (args.size() < 3) {
|
2020-02-01 23:06:01 +01:00
|
|
|
status.SetError("called with incorrect number of arguments");
|
2008-10-12 18:41:06 +02:00
|
|
|
return false;
|
2016-07-09 11:21:54 +02:00
|
|
|
}
|
2008-10-12 18:41:06 +02:00
|
|
|
|
2017-07-20 19:35:53 +02:00
|
|
|
std::string const& testName = args[0];
|
|
|
|
std::string const& var = args[2];
|
2020-02-01 23:06:01 +01:00
|
|
|
cmMakefile& mf = status.GetMakefile();
|
|
|
|
cmTest* test = mf.GetTest(testName);
|
2016-07-09 11:21:54 +02:00
|
|
|
if (test) {
|
2021-11-20 13:41:27 +01:00
|
|
|
cmValue prop;
|
2016-07-09 11:21:54 +02:00
|
|
|
if (!args[1].empty()) {
|
2015-11-17 17:22:37 +01:00
|
|
|
prop = test->GetProperty(args[1]);
|
2016-07-09 11:21:54 +02:00
|
|
|
}
|
|
|
|
if (prop) {
|
2021-11-20 13:41:27 +01:00
|
|
|
mf.AddDefinition(var, prop->c_str());
|
2008-10-12 18:41:06 +02:00
|
|
|
return true;
|
|
|
|
}
|
2016-07-09 11:21:54 +02:00
|
|
|
}
|
2020-02-01 23:06:01 +01:00
|
|
|
mf.AddDefinition(var, "NOTFOUND");
|
2008-10-12 18:41:06 +02:00
|
|
|
return true;
|
|
|
|
}
|