| 645 | } |
| 646 | |
| 647 | bool cmGlobalGhsMultiGenerator::AddCheckTarget() |
| 648 | { |
| 649 | // Skip the target if no regeneration is to be done. |
| 650 | if (this->GlobalSettingIsOn("CMAKE_SUPPRESS_REGENERATION")) { |
| 651 | return false; |
| 652 | } |
| 653 | |
| 654 | // Get the generators. |
| 655 | std::vector<std::unique_ptr<cmLocalGenerator>> const& generators = |
| 656 | this->LocalGenerators; |
| 657 | auto& lg = |
| 658 | cm::static_reference_cast<cmLocalGhsMultiGenerator>(generators[0]); |
| 659 | |
| 660 | // The name of the output file for the custom command. |
| 661 | this->StampFile = lg.GetBinaryDirectory() + std::string("/CMakeFiles/") + |
| 662 | CHECK_BUILD_SYSTEM_TARGET; |
| 663 | |
| 664 | // Add a custom rule to re-run CMake if any input files changed. |
| 665 | { |
| 666 | // Collect the input files used to generate all targets in this |
| 667 | // project. |
| 668 | std::vector<std::string> listFiles; |
| 669 | for (auto const& gen : generators) { |
| 670 | cm::append(listFiles, gen->GetMakefile()->GetListFiles()); |
| 671 | } |
| 672 | |
| 673 | // Add the cache file. |
| 674 | listFiles.emplace_back(cmStrCat( |
| 675 | this->GetCMakeInstance()->GetHomeOutputDirectory(), "/CMakeCache.txt")); |
| 676 | |
| 677 | // Print not implemented warning. |
| 678 | if (this->GetCMakeInstance()->DoWriteGlobVerifyTarget()) { |
| 679 | std::ostringstream msg; |
| 680 | msg << "Any pre-check scripts, such as those generated for file(GLOB " |
| 681 | "CONFIGURE_DEPENDS), will not be run by gbuild."; |
| 682 | this->GetCMakeInstance()->IssueMessage(MessageType::AUTHOR_WARNING, |
| 683 | msg.str()); |
| 684 | } |
| 685 | |
| 686 | // Sort the list of input files and remove duplicates. |
| 687 | std::sort(listFiles.begin(), listFiles.end(), std::less<std::string>()); |
| 688 | auto newEnd = std::unique(listFiles.begin(), listFiles.end()); |
| 689 | listFiles.erase(newEnd, listFiles.end()); |
| 690 | |
| 691 | // Create a rule to re-run CMake and create output file. |
| 692 | cmCustomCommandLines commandLines; |
| 693 | commandLines.emplace_back( |
| 694 | cmMakeCommandLine({ cmSystemTools::GetCMakeCommand(), "-E", "rm", "-f", |
| 695 | this->StampFile })); |
| 696 | std::string argS = cmStrCat("-S", lg.GetSourceDirectory()); |
| 697 | std::string argB = cmStrCat("-B", lg.GetBinaryDirectory()); |
| 698 | commandLines.emplace_back( |
| 699 | cmMakeCommandLine({ cmSystemTools::GetCMakeCommand(), argS, argB })); |
| 700 | commandLines.emplace_back(cmMakeCommandLine( |
| 701 | { cmSystemTools::GetCMakeCommand(), "-E", "touch", this->StampFile })); |
| 702 | |
| 703 | /* Create the target(Exclude from ALL_BUILD). |
| 704 | * |
no test coverage detected