MCPcopy Create free account
hub / github.com/Kitware/CMake / ComputeDirectoryTargets

Method ComputeDirectoryTargets

Source/cmGlobalCommonGenerator.cxx:32–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30cmGlobalCommonGenerator::~cmGlobalCommonGenerator() = default;
31
32std::map<std::string, cmGlobalCommonGenerator::DirectoryTarget>
33cmGlobalCommonGenerator::ComputeDirectoryTargets() const
34{
35 std::map<std::string, DirectoryTarget> dirTargets;
36 for (auto const& lg : this->LocalGenerators) {
37 std::string currentBinaryDir =
38 lg->GetStateSnapshot().GetDirectory().GetCurrentBinary();
39 DirectoryTarget& dirTarget = dirTargets[currentBinaryDir];
40 dirTarget.LG = lg.get();
41 std::vector<std::string> const& configs =
42 static_cast<cmLocalCommonGenerator const*>(lg.get())->GetConfigNames();
43
44 // The directory-level rule should depend on the target-level rules
45 // for all targets in the directory.
46 for (auto const& gt : lg->GetGeneratorTargets()) {
47 cmStateEnums::TargetType const type = gt->GetType();
48 if (type == cmStateEnums::GLOBAL_TARGET || !gt->IsInBuildSystem()) {
49 continue;
50 }
51 DirectoryTarget::Target t;
52 t.GT = gt.get();
53 std::string const EXCLUDE_FROM_ALL("EXCLUDE_FROM_ALL");
54 if (cmValue exclude = gt->GetProperty(EXCLUDE_FROM_ALL)) {
55 for (std::string const& config : configs) {
56 cmGeneratorExpressionInterpreter genexInterpreter(lg.get(), config,
57 gt.get());
58 if (cmIsOn(genexInterpreter.Evaluate(*exclude, EXCLUDE_FROM_ALL))) {
59 // This target has been explicitly excluded.
60 t.ExcludedFromAllInConfigs.push_back(config);
61 }
62 }
63
64 if (t.ExcludedFromAllInConfigs.empty()) {
65 // This target has been explicitly un-excluded. The directory-level
66 // rule for every directory between this and the root should depend
67 // on the target-level rule for this target.
68 for (cmStateSnapshot dir =
69 lg->GetStateSnapshot().GetBuildsystemDirectoryParent();
70 dir.IsValid(); dir = dir.GetBuildsystemDirectoryParent()) {
71 std::string d = dir.GetDirectory().GetCurrentBinary();
72 dirTargets[d].Targets.emplace_back(t);
73 }
74 }
75 }
76 dirTarget.Targets.emplace_back(t);
77 }
78
79 // The directory-level rule should depend on the directory-level
80 // rules of the subdirectories.
81 for (cmStateSnapshot const& state : lg->GetStateSnapshot().GetChildren()) {
82 DirectoryTarget::Dir d;
83 d.Path = state.GetDirectory().GetCurrentBinary();
84 d.ExcludeFromAll =
85 state.GetDirectory().GetPropertyAsBool("EXCLUDE_FROM_ALL");
86 dirTarget.Children.emplace_back(std::move(d));
87 }
88 }
89

Callers 2

WriteFolderTargetsMethod · 0.80
WriteMainMakefile2Method · 0.80

Calls 15

cmIsOnFunction · 0.85
moveFunction · 0.85
IsInBuildSystemMethod · 0.80
push_backMethod · 0.80
emplace_backMethod · 0.80
GetChildrenMethod · 0.80
GetDirectoryMethod · 0.45
GetStateSnapshotMethod · 0.45
getMethod · 0.45
GetTypeMethod · 0.45
GetPropertyMethod · 0.45

Tested by

no test coverage detected