Merge branch 'release-3.29'
[kiteware-cmake.git] / Source / cmTest.h
blob480966a8181f1980b380f981d844414616117918
1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
3 #pragma once
5 #include "cmConfigure.h" // IWYU pragma: keep
7 #include <cstddef>
8 #include <string>
9 #include <vector>
11 #include "cmListFileCache.h"
12 #include "cmPolicies.h"
13 #include "cmPropertyMap.h"
14 #include "cmValue.h"
16 class cmMakefile;
18 /** \class cmTest
19 * \brief Represent a test
21 * cmTest is representation of a test.
23 class cmTest
25 public:
26 /**
28 cmTest(cmMakefile* mf);
29 ~cmTest();
31 //! Set the test name
32 void SetName(const std::string& name);
33 std::string GetName() const { return this->Name; }
35 void SetCommand(std::vector<std::string> const& command);
36 std::vector<std::string> const& GetCommand() const { return this->Command; }
38 //! Set/Get a property of this source file
39 void SetProperty(const std::string& prop, cmValue value);
40 void SetProperty(const std::string& prop, std::nullptr_t)
42 this->SetProperty(prop, cmValue{ nullptr });
44 void SetProperty(const std::string& prop, const std::string& value)
46 this->SetProperty(prop, cmValue(value));
48 void AppendProperty(const std::string& prop, const std::string& value,
49 bool asString = false);
50 cmValue GetProperty(const std::string& prop) const;
51 bool GetPropertyAsBool(const std::string& prop) const;
52 cmPropertyMap& GetProperties() { return this->Properties; }
54 /** Get the cmMakefile instance that owns this test. */
55 cmMakefile* GetMakefile() { return this->Makefile; }
57 /** Get the backtrace of the command that created this test. */
58 cmListFileBacktrace const& GetBacktrace() const;
60 /** Get/Set whether this is an old-style test. */
61 bool GetOldStyle() const { return this->OldStyle; }
62 void SetOldStyle(bool b) { this->OldStyle = b; }
64 /** Get/Set if CMP0158 policy is NEW */
65 bool GetCMP0158IsNew() const
67 return this->PolicyStatusCMP0158 == cmPolicies::NEW;
70 /** Set/Get whether lists in command lines should be expanded. */
71 bool GetCommandExpandLists() const;
72 void SetCommandExpandLists(bool b);
74 private:
75 cmPropertyMap Properties;
76 std::string Name;
77 std::vector<std::string> Command;
78 bool CommandExpandLists = false;
80 bool OldStyle;
82 cmMakefile* Makefile;
83 cmListFileBacktrace Backtrace;
84 cmPolicies::PolicyStatus PolicyStatusCMP0158;