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

Function cmIncludeGuardCommand

Source/cmIncludeGuardCommand.cxx:49–104  ·  view source on GitHub ↗

cmIncludeGuardCommand

Source from the content-addressed store, hash-verified

47
48// cmIncludeGuardCommand
49bool cmIncludeGuardCommand(std::vector<std::string> const& args,
50 cmExecutionStatus& status)
51{
52 if (args.size() > 1) {
53 status.SetError(
54 "given an invalid number of arguments. The command takes at "
55 "most 1 argument.");
56 return false;
57 }
58
59 IncludeGuardScope scope = VARIABLE;
60
61 if (!args.empty()) {
62 std::string const& arg = args[0];
63 if (arg == "DIRECTORY") {
64 scope = DIRECTORY;
65 } else if (arg == "GLOBAL") {
66 scope = GLOBAL;
67 } else {
68 status.SetError("given an invalid scope: " + arg);
69 return false;
70 }
71 }
72
73 std::string includeGuardVar = GetIncludeGuardVariableName(
74 *status.GetMakefile().GetDefinition("CMAKE_CURRENT_LIST_FILE"));
75
76 cmMakefile* const mf = &status.GetMakefile();
77
78 switch (scope) {
79 case VARIABLE:
80 if (mf->IsDefinitionSet(includeGuardVar)) {
81 status.SetReturnInvoked();
82 return true;
83 }
84 mf->AddDefinitionBool(includeGuardVar, true);
85 break;
86 case DIRECTORY:
87 if (CheckIncludeGuardIsSet(mf, includeGuardVar)) {
88 status.SetReturnInvoked();
89 return true;
90 }
91 mf->SetProperty(includeGuardVar, "TRUE");
92 break;
93 case GLOBAL:
94 cmake* const cm = mf->GetCMakeInstance();
95 if (cm->GetProperty(includeGuardVar)) {
96 status.SetReturnInvoked();
97 return true;
98 }
99 cm->SetProperty(includeGuardVar, "TRUE");
100 break;
101 }
102
103 return true;
104}

Callers

nothing calls this directly

Calls 13

CheckIncludeGuardIsSetFunction · 0.85
IsDefinitionSetMethod · 0.80
SetReturnInvokedMethod · 0.80
AddDefinitionBoolMethod · 0.80
sizeMethod · 0.45
SetErrorMethod · 0.45
emptyMethod · 0.45
GetDefinitionMethod · 0.45
GetMakefileMethod · 0.45
SetPropertyMethod · 0.45
GetCMakeInstanceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…