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

Method GetCompilerFeatures

Source/cmQtAutoGenGlobalInitializer.cxx:218–322  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216}
217
218cmQtAutoGen::ConfigStrings<cmQtAutoGen::CompilerFeaturesHandle>
219cmQtAutoGenGlobalInitializer::GetCompilerFeatures(
220 std::string const& generator, cmQtAutoGen::ConfigString const& executable,
221 std::string& error, bool const isMultiConfig, bool const UseBetterGraph)
222{
223 cmQtAutoGen::ConfigStrings<cmQtAutoGen::CompilerFeaturesHandle> res;
224 if (isMultiConfig && UseBetterGraph) {
225 for (auto const& config : executable.Config) {
226 auto const exe = config.second;
227 // Check if we have cached features
228 {
229 auto it = this->CompilerFeatures_.Config[config.first].find(exe);
230 if (it != this->CompilerFeatures_.Config[config.first].end()) {
231 res.Config[config.first] = it->second;
232 continue;
233 }
234 }
235
236 // Check if the executable exists
237 if (!cmSystemTools::FileExists(exe, true)) {
238 error = cmStrCat("The \"", generator, "\" executable ",
239 cmQtAutoGen::Quoted(exe), " does not exist.");
240 res.Config[config.first] = {};
241 continue;
242 }
243
244 // Test the executable
245 std::string stdOut;
246 {
247 std::string stdErr;
248 std::vector<std::string> command;
249 command.emplace_back(exe);
250 command.emplace_back("-h");
251 int retVal = 0;
252 bool const runResult = cmSystemTools::RunSingleCommand(
253 command, &stdOut, &stdErr, &retVal, nullptr,
254 cmSystemTools::OUTPUT_NONE, cmDuration::zero(),
255 cmProcessOutput::Auto);
256 if (!runResult) {
257 error = cmStrCat("Test run of \"", generator, "\" executable ",
258 cmQtAutoGen::Quoted(exe), " failed.\n",
259 cmQtAutoGen::QuotedCommand(command), '\n', stdOut,
260 '\n', stdErr);
261 res.Config[config.first] = {};
262 continue;
263 }
264 }
265
266 // Create valid handle
267 res.Config[config.first] =
268 std::make_shared<cmQtAutoGen::CompilerFeatures>();
269 res.Config[config.first]->HelpOutput = std::move(stdOut);
270
271 // Register compiler features
272 this->CompilerFeatures_.Config[config.first].emplace(
273 exe, res.Config[config.first]);
274 }
275 return res;

Callers 1

GetQtExecutableMethod · 0.80

Calls 7

moveFunction · 0.85
emplace_backMethod · 0.80
emplaceMethod · 0.80
cmStrCatFunction · 0.70
FileExistsFunction · 0.50
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected