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

Method GetToolset

Source/cmGlobalGhsMultiGenerator.cxx:163–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161}
162
163void cmGlobalGhsMultiGenerator::GetToolset(cmMakefile* mf, std::string& tsp,
164 std::string const& ts)
165{
166 /* Determine tsp - full path of the toolset from ts (toolset hint via -T) */
167
168 std::string root = mf->GetSafeDefinition("GHS_TOOLSET_ROOT");
169
170 // Check if `-T` was set by user
171 if (ts.empty()) {
172 // Enter toolset search mode
173 std::vector<std::string> output;
174
175 // Make sure root exists...
176 if (!cmSystemTools::PathExists(root)) {
177 std::string msg =
178 "GHS_TOOLSET_ROOT directory \"" + root + "\" does not exist.";
179 mf->IssueMessage(MessageType::FATAL_ERROR, msg);
180 tsp = "";
181 return;
182 }
183
184 // Add a directory separator
185 if (root.back() != '/') {
186 root += "/";
187 }
188
189 // Get all compiler directories in toolset root
190 cmSystemTools::Glob(root, "comp_[^;]+", output);
191
192 if (output.empty()) {
193 // No compiler directories found
194 std::string msg =
195 "No GHS toolsets found in GHS_TOOLSET_ROOT \"" + root + "\".";
196 mf->IssueMessage(MessageType::FATAL_ERROR, msg);
197 tsp = "";
198 } else {
199 // Use latest? version
200 tsp = root + output.back();
201 }
202
203 } else {
204 // Toolset was provided by user
205 std::string tryPath;
206
207 // NOTE: CollapseFullPath() will determine if user toolset was full path or
208 // or relative path.
209 tryPath = cmSystemTools::CollapseFullPath(ts, root);
210 if (!cmSystemTools::FileExists(tryPath)) {
211 std::string msg = "GHS toolset \"" + tryPath + "\" does not exist.";
212 mf->IssueMessage(MessageType::FATAL_ERROR, msg);
213 tsp = "";
214 } else {
215 tsp = tryPath;
216 }
217 }
218}
219
220void cmGlobalGhsMultiGenerator::WriteFileHeader(std::ostream& fout)

Callers 1

SetGeneratorToolsetMethod · 0.95

Calls 4

FileExistsFunction · 0.50
emptyMethod · 0.45
IssueMessageMethod · 0.45
backMethod · 0.45

Tested by

no test coverage detected