| 3487 | } |
| 3488 | |
| 3489 | int cmake::CheckBuildSystem() |
| 3490 | { |
| 3491 | // We do not need to rerun CMake. Check dependency integrity. |
| 3492 | bool const verbose = isCMakeVerbose(); |
| 3493 | |
| 3494 | // This method will check the integrity of the build system if the |
| 3495 | // option was given on the command line. It reads the given file to |
| 3496 | // determine whether CMake should rerun. |
| 3497 | |
| 3498 | // If no file is provided for the check, we have to rerun. |
| 3499 | if (this->CheckBuildSystemArgument.empty()) { |
| 3500 | if (verbose) { |
| 3501 | cmSystemTools::Stdout("Re-run cmake no build system arguments\n"); |
| 3502 | } |
| 3503 | return 1; |
| 3504 | } |
| 3505 | |
| 3506 | // If the file provided does not exist, we have to rerun. |
| 3507 | if (!cmSystemTools::FileExists(this->CheckBuildSystemArgument)) { |
| 3508 | if (verbose) { |
| 3509 | std::ostringstream msg; |
| 3510 | msg << "Re-run cmake missing file: " << this->CheckBuildSystemArgument |
| 3511 | << '\n'; |
| 3512 | cmSystemTools::Stdout(msg.str()); |
| 3513 | } |
| 3514 | return 1; |
| 3515 | } |
| 3516 | |
| 3517 | // Read the rerun check file and use it to decide whether to do the |
| 3518 | // global generate. |
| 3519 | // Actually, all we need is the `set` command. |
| 3520 | cmake cm(cmState::Role::Script); |
| 3521 | cm.GetCurrentSnapshot().SetDefaultDefinitions(); |
| 3522 | cmGlobalGenerator gg(&cm); |
| 3523 | cmMakefile mf(&gg, cm.GetCurrentSnapshot()); |
| 3524 | if (!mf.ReadListFile(this->CheckBuildSystemArgument) || |
| 3525 | cmSystemTools::GetErrorOccurredFlag()) { |
| 3526 | if (verbose) { |
| 3527 | std::ostringstream msg; |
| 3528 | msg << "Re-run cmake error reading : " << this->CheckBuildSystemArgument |
| 3529 | << '\n'; |
| 3530 | cmSystemTools::Stdout(msg.str()); |
| 3531 | } |
| 3532 | // There was an error reading the file. Just rerun. |
| 3533 | return 1; |
| 3534 | } |
| 3535 | |
| 3536 | if (this->ClearBuildSystem) { |
| 3537 | // Get the generator used for this build system. |
| 3538 | std::string genName = mf.GetSafeDefinition("CMAKE_DEPENDS_GENERATOR"); |
| 3539 | if (!cmNonempty(genName)) { |
| 3540 | genName = "Unix Makefiles"; |
| 3541 | } |
| 3542 | |
| 3543 | // Create the generator and use it to clear the dependencies. |
| 3544 | std::unique_ptr<cmGlobalGenerator> ggd = |
| 3545 | this->CreateGlobalGenerator(genName); |
| 3546 | if (ggd) { |
no test coverage detected