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

Function HandleGetCommand

Source/cmCMakePathCommand.cxx:124–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122}
123
124bool HandleGetCommand(std::vector<std::string> const& args,
125 cmExecutionStatus& status)
126{
127 static std::map<cm::string_view,
128 std::function<cmCMakePath(cmCMakePath const&, bool)>> const
129 actions{ { "ROOT_NAME"_s,
130 [](cmCMakePath const& path, bool) -> cmCMakePath {
131 return path.GetRootName();
132 } },
133 { "ROOT_DIRECTORY"_s,
134 [](cmCMakePath const& path, bool) -> cmCMakePath {
135 return path.GetRootDirectory();
136 } },
137 { "ROOT_PATH"_s,
138 [](cmCMakePath const& path, bool) -> cmCMakePath {
139 return path.GetRootPath();
140 } },
141 { "FILENAME"_s,
142 [](cmCMakePath const& path, bool) -> cmCMakePath {
143 return path.GetFileName();
144 } },
145 { "EXTENSION"_s,
146 [](cmCMakePath const& path, bool last_only) -> cmCMakePath {
147 if (last_only) {
148 return path.GetExtension();
149 }
150 return path.GetWideExtension();
151 } },
152 { "STEM"_s,
153 [](cmCMakePath const& path, bool last_only) -> cmCMakePath {
154 if (last_only) {
155 return path.GetStem();
156 }
157 return path.GetNarrowStem();
158 } },
159 { "RELATIVE_PART"_s,
160 [](cmCMakePath const& path, bool) -> cmCMakePath {
161 return path.GetRelativePath();
162 } },
163 { "PARENT_PATH"_s,
164 [](cmCMakePath const& path, bool) -> cmCMakePath {
165 return path.GetParentPath();
166 } } };
167
168 if (args.size() < 4) {
169 status.SetError("GET must be called with at least three arguments.");
170 return false;
171 }
172
173 auto const& action = args[2];
174
175 if (actions.find(action) == actions.end()) {
176 status.SetError(
177 cmStrCat("GET called with an unknown action: ", action, '.'));
178 return false;
179 }
180
181 struct Arguments

Callers

nothing calls this directly

Calls 15

getInputPathFunction · 0.85
GetRootNameMethod · 0.80
GetRootDirectoryMethod · 0.80
GetRootPathMethod · 0.80
GetExtensionMethod · 0.80
GetWideExtensionMethod · 0.80
GetStemMethod · 0.80
GetNarrowStemMethod · 0.80
GetParentPathMethod · 0.80
cmStrCatFunction · 0.70
GetFileNameMethod · 0.45
GetRelativePathMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…