cmGetTestPropertyCommand.cxx 923 B

12345678910111213141516171819202122232425262728293031323334
  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 "cmGetTestPropertyCommand.h"
  4. #include "cmExecutionStatus.h"
  5. #include "cmMakefile.h"
  6. #include "cmTest.h"
  7. #include "cmValue.h"
  8. bool cmGetTestPropertyCommand(std::vector<std::string> const& args,
  9. cmExecutionStatus& status)
  10. {
  11. if (args.size() < 3) {
  12. status.SetError("called with incorrect number of arguments");
  13. return false;
  14. }
  15. std::string const& testName = args[0];
  16. std::string const& var = args[2];
  17. cmMakefile& mf = status.GetMakefile();
  18. cmTest* test = mf.GetTest(testName);
  19. if (test) {
  20. cmValue prop;
  21. if (!args[1].empty()) {
  22. prop = test->GetProperty(args[1]);
  23. }
  24. if (prop) {
  25. mf.AddDefinition(var, prop);
  26. return true;
  27. }
  28. }
  29. mf.AddDefinition(var, "NOTFOUND");
  30. return true;
  31. }