| 1452 | } |
| 1453 | |
| 1454 | std::string cmCoreTryCompile::WriteSource(std::string const& filename, |
| 1455 | std::string const& content, |
| 1456 | char const* command) const |
| 1457 | { |
| 1458 | if (!cmSystemTools::GetFilenamePath(filename).empty()) { |
| 1459 | auto const& msg = |
| 1460 | cmStrCat(command, " given invalid filename \"", filename, '"'); |
| 1461 | this->Makefile->IssueMessage(MessageType::FATAL_ERROR, msg); |
| 1462 | return {}; |
| 1463 | } |
| 1464 | |
| 1465 | auto filepath = cmStrCat(this->BinaryDirectory, '/', filename); |
| 1466 | cmsys::ofstream file{ filepath.c_str(), std::ios::out }; |
| 1467 | if (!file) { |
| 1468 | auto const& msg = |
| 1469 | cmStrCat(command, " failed to open \"", filename, "\" for writing"); |
| 1470 | this->Makefile->IssueMessage(MessageType::FATAL_ERROR, msg); |
| 1471 | return {}; |
| 1472 | } |
| 1473 | |
| 1474 | file << content; |
| 1475 | if (!file) { |
| 1476 | auto const& msg = cmStrCat(command, " failed to write \"", filename, '"'); |
| 1477 | this->Makefile->IssueMessage(MessageType::FATAL_ERROR, msg); |
| 1478 | return {}; |
| 1479 | } |
| 1480 | |
| 1481 | file.close(); |
| 1482 | return filepath; |
| 1483 | } |
| 1484 | |
| 1485 | void cmCoreTryCompile::WriteTryCompileEventFields( |
| 1486 | cmConfigureLog& log, cmTryCompileResult const& compileResult) |
no test coverage detected