/src/CMake/Source/cmTest.h
Line | Count | Source |
1 | | /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying |
2 | | file LICENSE.rst or https://cmake.org/licensing for details. */ |
3 | | #pragma once |
4 | | |
5 | | #include "cmConfigure.h" // IWYU pragma: keep |
6 | | |
7 | | #include <cstddef> |
8 | | #include <string> |
9 | | #include <vector> |
10 | | |
11 | | #include "cmListFileCache.h" |
12 | | #include "cmPolicies.h" |
13 | | #include "cmPropertyMap.h" |
14 | | #include "cmValue.h" |
15 | | |
16 | | class cmMakefile; |
17 | | |
18 | | /** \class cmTest |
19 | | * \brief Represent a test |
20 | | * |
21 | | * cmTest is representation of a test. |
22 | | */ |
23 | | class cmTest |
24 | | { |
25 | | public: |
26 | | /** |
27 | | */ |
28 | | cmTest(cmMakefile* mf); |
29 | | ~cmTest(); |
30 | | |
31 | | //! Set the test name |
32 | | void SetName(std::string const& name); |
33 | 0 | std::string GetName() const { return this->Name; } |
34 | | |
35 | | void SetCommand(std::vector<std::string> const& command); |
36 | 0 | std::vector<std::string> const& GetCommand() const { return this->Command; } |
37 | | |
38 | | //! Set/Get a property of this source file |
39 | | void SetProperty(std::string const& prop, cmValue value); |
40 | | void SetProperty(std::string const& prop, std::nullptr_t) |
41 | 0 | { |
42 | 0 | this->SetProperty(prop, cmValue{ nullptr }); |
43 | 0 | } |
44 | | void SetProperty(std::string const& prop, std::string const& value) |
45 | 0 | { |
46 | 0 | this->SetProperty(prop, cmValue(value)); |
47 | 0 | } |
48 | | void AppendProperty(std::string const& prop, std::string const& value, |
49 | | bool asString = false); |
50 | | cmValue GetProperty(std::string const& prop) const; |
51 | | bool GetPropertyAsBool(std::string const& prop) const; |
52 | 0 | cmPropertyMap& GetProperties() { return this->Properties; } |
53 | | |
54 | | /** Get the cmMakefile instance that owns this test. */ |
55 | 0 | cmMakefile* GetMakefile() { return this->Makefile; } |
56 | | |
57 | | /** Get the backtrace of the command that created this test. */ |
58 | | cmListFileBacktrace const& GetBacktrace() const; |
59 | | |
60 | | /** Get/Set whether this is an old-style test. */ |
61 | 0 | bool GetOldStyle() const { return this->OldStyle; } |
62 | 0 | void SetOldStyle(bool b) { this->OldStyle = b; } |
63 | | |
64 | | /** Get if CMP0158 policy is NEW */ |
65 | | bool GetCMP0158IsNew() const |
66 | 0 | { |
67 | 0 | return this->PolicyStatusCMP0158 == cmPolicies::NEW; |
68 | 0 | } |
69 | | |
70 | | /** Get/Set the CMP0178 policy setting */ |
71 | | cmPolicies::PolicyStatus GetCMP0178() const |
72 | 0 | { |
73 | 0 | return this->PolicyStatusCMP0178; |
74 | 0 | } |
75 | | void SetCMP0178(cmPolicies::PolicyStatus p) |
76 | 0 | { |
77 | 0 | this->PolicyStatusCMP0178 = p; |
78 | 0 | } |
79 | | |
80 | | /** Set/Get whether lists in command lines should be expanded. */ |
81 | | bool GetCommandExpandLists() const; |
82 | | void SetCommandExpandLists(bool b); |
83 | | |
84 | | private: |
85 | | cmPropertyMap Properties; |
86 | | std::string Name; |
87 | | std::vector<std::string> Command; |
88 | | bool CommandExpandLists = false; |
89 | | |
90 | | bool OldStyle; |
91 | | |
92 | | cmMakefile* Makefile; |
93 | | cmListFileBacktrace Backtrace; |
94 | | cmPolicies::PolicyStatus PolicyStatusCMP0158; |
95 | | cmPolicies::PolicyStatus PolicyStatusCMP0178; |
96 | | }; |