/src/CMake/Source/cmFileSet.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 <cstddef> |
6 | | #include <map> |
7 | | #include <memory> |
8 | | #include <string> |
9 | | #include <vector> |
10 | | |
11 | | #include <cm/string_view> |
12 | | #include <cmext/string_view> |
13 | | |
14 | | #include "cmListFileCache.h" |
15 | | #include "cmPropertyMap.h" |
16 | | #include "cmValue.h" |
17 | | |
18 | | namespace cm { |
19 | | namespace GenEx { |
20 | | struct Context; |
21 | | } |
22 | | } |
23 | | |
24 | | class cmCompiledGeneratorExpression; |
25 | | struct cmGeneratorExpressionDAGChecker; |
26 | | class cmGeneratorTarget; |
27 | | class cmMakefile; |
28 | | |
29 | | enum class cmFileSetVisibility |
30 | | { |
31 | | Private, |
32 | | Public, |
33 | | Interface, |
34 | | }; |
35 | | cm::static_string_view cmFileSetVisibilityToName(cmFileSetVisibility vis); |
36 | | cmFileSetVisibility cmFileSetVisibilityFromName(cm::string_view name, |
37 | | cmMakefile* mf); |
38 | | bool cmFileSetVisibilityIsForSelf(cmFileSetVisibility vis); |
39 | | bool cmFileSetVisibilityIsForInterface(cmFileSetVisibility vis); |
40 | | |
41 | | bool cmFileSetTypeCanBeIncluded(std::string const& type); |
42 | | |
43 | | class cmFileSet |
44 | | { |
45 | | public: |
46 | | cmFileSet(cmMakefile* makefile, std::string name, std::string type, |
47 | | cmFileSetVisibility visibility); |
48 | | |
49 | 0 | std::string const& GetName() const { return this->Name; } |
50 | 0 | std::string const& GetType() const { return this->Type; } |
51 | 0 | cmFileSetVisibility GetVisibility() const { return this->Visibility; } |
52 | | |
53 | 0 | cmMakefile* GetMakefile() const { return this->Makefile; } |
54 | | |
55 | | void CopyEntries(cmFileSet const* fs); |
56 | | |
57 | | void ClearDirectoryEntries(); |
58 | | void AddDirectoryEntry(BT<std::string> directories); |
59 | | std::vector<BT<std::string>> const& GetDirectoryEntries() const |
60 | 0 | { |
61 | 0 | return this->DirectoryEntries; |
62 | 0 | } |
63 | | |
64 | | void ClearFileEntries(); |
65 | | void AddFileEntry(BT<std::string> files); |
66 | | std::vector<BT<std::string>> const& GetFileEntries() const |
67 | 0 | { |
68 | 0 | return this->FileEntries; |
69 | 0 | } |
70 | | |
71 | | std::vector<std::unique_ptr<cmCompiledGeneratorExpression>> |
72 | | CompileFileEntries() const; |
73 | | |
74 | | std::vector<std::unique_ptr<cmCompiledGeneratorExpression>> |
75 | | CompileDirectoryEntries() const; |
76 | | |
77 | | std::vector<std::string> EvaluateDirectoryEntries( |
78 | | std::vector<std::unique_ptr<cmCompiledGeneratorExpression>> const& cges, |
79 | | cm::GenEx::Context const& context, cmGeneratorTarget const* target, |
80 | | cmGeneratorExpressionDAGChecker* dagChecker = nullptr) const; |
81 | | |
82 | | void EvaluateFileEntry( |
83 | | std::vector<std::string> const& dirs, |
84 | | std::map<std::string, std::vector<std::string>>& filesPerDir, |
85 | | std::unique_ptr<cmCompiledGeneratorExpression> const& cge, |
86 | | cm::GenEx::Context const& context, cmGeneratorTarget const* target, |
87 | | cmGeneratorExpressionDAGChecker* dagChecker = nullptr) const; |
88 | | |
89 | | static bool IsValidName(std::string const& name); |
90 | | |
91 | | //! Set/Get a property of this file set |
92 | | void SetProperty(std::string const& prop, cmValue value); |
93 | | void SetProperty(std::string const& prop, std::nullptr_t) |
94 | 0 | { |
95 | 0 | this->SetProperty(prop, cmValue{ nullptr }); |
96 | 0 | } |
97 | | void RemoveProperty(std::string const& prop) |
98 | 0 | { |
99 | 0 | this->SetProperty(prop, cmValue{ nullptr }); |
100 | 0 | } |
101 | | void SetProperty(std::string const& prop, std::string const& value) |
102 | 0 | { |
103 | 0 | this->SetProperty(prop, cmValue{ value }); |
104 | 0 | } |
105 | | void AppendProperty(std::string const& prop, std::string const& value, |
106 | | bool asString = false); |
107 | | cmValue GetProperty(std::string const& prop) const; |
108 | | |
109 | | private: |
110 | | cmMakefile* Makefile; |
111 | | std::string Name; |
112 | | std::string Type; |
113 | | cmFileSetVisibility Visibility; |
114 | | std::vector<BT<std::string>> DirectoryEntries; |
115 | | std::vector<BT<std::string>> FileEntries; |
116 | | cmPropertyMap Properties; |
117 | | std::vector<BT<std::string>> CompileOptions; |
118 | | std::vector<BT<std::string>> CompileDefinitions; |
119 | | std::vector<BT<std::string>> IncludeDirectories; |
120 | | |
121 | | static std::string const propCOMPILE_DEFINITIONS; |
122 | | static std::string const propCOMPILE_OPTIONS; |
123 | | static std::string const propINCLUDE_DIRECTORIES; |
124 | | }; |