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

Function cmGetDirectoryPropertyCommand

Source/cmGetDirectoryPropertyCommand.cxx:17–79  ·  view source on GitHub ↗

cmGetDirectoryPropertyCommand

Source from the content-addressed store, hash-verified

15
16// cmGetDirectoryPropertyCommand
17bool cmGetDirectoryPropertyCommand(std::vector<std::string> const& args,
18 cmExecutionStatus& status)
19{
20 if (args.size() < 2) {
21 status.SetError("called with incorrect number of arguments");
22 return false;
23 }
24
25 auto i = args.begin();
26 std::string const& variable = *i;
27 ++i;
28
29 // get the directory argument if there is one
30 cmMakefile* dir = &status.GetMakefile();
31 if (*i == "DIRECTORY") {
32 ++i;
33 if (i == args.end()) {
34 status.SetError(
35 "DIRECTORY argument provided without subsequent arguments");
36 return false;
37 }
38 std::string sd = cmSystemTools::CollapseFullPath(
39 *i, status.GetMakefile().GetCurrentSourceDirectory());
40
41 // lookup the makefile from the directory name
42 dir = status.GetMakefile().GetGlobalGenerator()->FindMakefile(sd);
43 if (!dir) {
44 status.SetError(
45 "DIRECTORY argument provided but requested directory not found. "
46 "This could be because the directory argument was invalid or, "
47 "it is valid but has not been processed yet.");
48 return false;
49 }
50 ++i;
51 if (i == args.end()) {
52 status.SetError("called with incorrect number of arguments");
53 return false;
54 }
55 }
56
57 // OK, now we have the directory to process, we just get the requested
58 // information out of it
59
60 if (*i == "DEFINITION") {
61 ++i;
62 if (i == args.end()) {
63 status.SetError("A request for a variable definition was made without "
64 "providing the name of the variable to get.");
65 return false;
66 }
67 std::string const& output = dir->GetSafeDefinition(*i);
68 status.GetMakefile().AddDefinition(variable, output);
69 return true;
70 }
71
72 if (i->empty()) {
73 status.SetError("given empty string for the property name to get");
74 return false;

Callers

nothing calls this directly

Calls 11

FindMakefileMethod · 0.80
StoreResultFunction · 0.70
sizeMethod · 0.45
SetErrorMethod · 0.45
beginMethod · 0.45
GetMakefileMethod · 0.45
endMethod · 0.45
GetGlobalGeneratorMethod · 0.45
AddDefinitionMethod · 0.45
emptyMethod · 0.45
GetPropertyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…