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

Method FindOutputFile

Source/cmCoreTryCompile.cxx:1414–1452  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1412}
1413
1414void cmCoreTryCompile::FindOutputFile(std::string const& targetName)
1415{
1416 this->FindErrorMessage.clear();
1417 this->OutputFile.clear();
1418 std::string tmpOutputFile = "/";
1419 tmpOutputFile += targetName;
1420
1421 if (this->Makefile->GetGlobalGenerator()->IsMultiConfig()) {
1422 std::string const tcConfig =
1423 this->Makefile->GetSafeDefinition("CMAKE_TRY_COMPILE_CONFIGURATION");
1424 std::string const cfg = !tcConfig.empty()
1425 ? cmSystemTools::UpperCase(tcConfig)
1426 : TryCompileDefaultConfig;
1427 tmpOutputFile = cmStrCat(tmpOutputFile, '_', cfg);
1428 }
1429 tmpOutputFile += "_loc";
1430
1431 std::string command = cmStrCat(this->BinaryDirectory, tmpOutputFile);
1432 if (!cmSystemTools::FileExists(command)) {
1433 std::ostringstream emsg;
1434 emsg << "Unable to find the recorded try_compile output location:\n";
1435 emsg << cmStrCat(" ", command, '\n');
1436 this->FindErrorMessage = emsg.str();
1437 return;
1438 }
1439
1440 std::string outputFileLocation;
1441 cmsys::ifstream ifs(command.c_str());
1442 cmSystemTools::GetLineFromStream(ifs, outputFileLocation);
1443 if (!cmSystemTools::FileExists(outputFileLocation)) {
1444 std::ostringstream emsg;
1445 emsg << "Recorded try_compile output location doesn't exist:\n";
1446 emsg << cmStrCat(" ", outputFileLocation, '\n');
1447 this->FindErrorMessage = emsg.str();
1448 return;
1449 }
1450
1451 this->OutputFile = cmSystemTools::CollapseFullPath(outputFileLocation);
1452}
1453
1454std::string cmCoreTryCompile::WriteSource(std::string const& filename,
1455 std::string const& content,

Callers 1

TryCompileCodeMethod · 0.95

Calls 8

strMethod · 0.80
c_strMethod · 0.80
cmStrCatFunction · 0.70
FileExistsFunction · 0.50
clearMethod · 0.45
IsMultiConfigMethod · 0.45
GetGlobalGeneratorMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected