Coverage Report

Created: 2026-04-29 07:01

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/CMake/Source/cmFileSetMetadata.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 <set>
6
#include <utility>
7
#include <vector>
8
9
#include <cm/optional>
10
#include <cm/string_view>
11
12
class cmMakefile;
13
14
namespace cm {
15
namespace FileSetMetadata {
16
enum class Visibility
17
{
18
  Private,
19
  Public,
20
  Interface
21
};
22
23
cm::string_view VisibilityToName(Visibility vis);
24
Visibility VisibilityFromName(cm::string_view name, cmMakefile* mf);
25
26
bool VisibilityIsForSelf(Visibility vis);
27
bool VisibilityIsForInterface(Visibility vis);
28
29
// Pre-defined FileSet types
30
extern cm::string_view const HEADERS;
31
extern cm::string_view const SOURCES;
32
extern cm::string_view const CXX_MODULES;
33
34
enum class FileSetLookup
35
{
36
  // Search for file sets attached to the target
37
  Target,
38
  // Search also file sets inherited from link libraries
39
  Dependencies
40
};
41
42
// Define the various modes regarding graph dependency for
43
// the generated files (Ninja specific)
44
// items must be kept in this order: "Lower" modes are "stronger" in that they
45
// have more restrictions (and therefore allow for more build graph
46
// optimization).
47
// std::set rely on it.
48
enum class DependencyMode
49
{
50
  IndependentFiles, // files in the file set are independent from each other
51
  Includables,      // files can be used by another source during compilation
52
};
53
using DependencySet = std::set<DependencyMode>;
54
55
enum class FrameworkCompatible
56
{
57
  No,
58
  Yes
59
};
60
61
struct FileSetDescriptor
62
{
63
  FileSetDescriptor(cm::string_view type, FileSetLookup lookup,
64
                    DependencySet dependencies,
65
                    DependencyMode defaultDependency,
66
                    FrameworkCompatible frameworkSupported)
67
12
    : Type(type)
68
12
    , Lookup(lookup)
69
12
    , SupportedDependencies(std::move(dependencies))
70
12
    , DefaultDependency(defaultDependency)
71
12
    , FrameworkSupported(frameworkSupported)
72
12
  {
73
12
  }
74
75
  FileSetDescriptor(FileSetLookup lookup)
76
0
    : Type()
77
0
    , Lookup(lookup)
78
0
    , SupportedDependencies({ DependencyMode::Includables })
79
0
    , DefaultDependency(DependencyMode::Includables)
80
0
    , FrameworkSupported(FrameworkCompatible::No)
81
0
  {
82
0
  }
83
84
  cm::string_view const Type;
85
  FileSetLookup const Lookup;
86
  DependencySet const SupportedDependencies;
87
  DependencyMode const DefaultDependency;
88
  FrameworkCompatible const FrameworkSupported;
89
};
90
91
cm::optional<FileSetDescriptor> GetFileSetDescriptor(cm::string_view type);
92
DependencyMode GetDependencyMode(cm::string_view type);
93
DependencyMode GetDependencyMode(cm::string_view type,
94
                                 DependencyMode requestedMode);
95
bool IsFrameworkSupported(cm::string_view type);
96
97
std::vector<cm::string_view> const& GetKnownTypes();
98
bool IsKnownType(cm::string_view type);
99
100
// check validity of a user's file set name
101
bool IsValidName(cm::string_view type);
102
}
103
}