| 3721 | } |
| 3722 | |
| 3723 | int cmake::GetSystemInformation(std::vector<std::string>& args) |
| 3724 | { |
| 3725 | // so create the directory |
| 3726 | std::string resultFile; |
| 3727 | std::string cwd = cmSystemTools::GetLogicalWorkingDirectory(); |
| 3728 | std::string destPath = cwd + "/__cmake_systeminformation"; |
| 3729 | cmSystemTools::RemoveADirectory(destPath); |
| 3730 | if (!cmSystemTools::MakeDirectory(destPath)) { |
| 3731 | std::cerr << "Error: --system-information must be run from a " |
| 3732 | "writable directory!\n"; |
| 3733 | return 1; |
| 3734 | } |
| 3735 | |
| 3736 | // process the arguments |
| 3737 | bool writeToStdout = true; |
| 3738 | for (unsigned int i = 1; i < args.size(); ++i) { |
| 3739 | std::string const& arg = args[i]; |
| 3740 | if (cmHasLiteralPrefix(arg, "-G")) { |
| 3741 | std::string value = arg.substr(2); |
| 3742 | if (value.empty()) { |
| 3743 | ++i; |
| 3744 | if (i >= args.size()) { |
| 3745 | cmSystemTools::Error("No generator specified for -G"); |
| 3746 | this->PrintGeneratorList(); |
| 3747 | return -1; |
| 3748 | } |
| 3749 | value = args[i]; |
| 3750 | } |
| 3751 | auto gen = this->CreateGlobalGenerator(value); |
| 3752 | if (!gen) { |
| 3753 | cmSystemTools::Error("Could not create named generator " + value); |
| 3754 | this->PrintGeneratorList(); |
| 3755 | } else { |
| 3756 | this->SetGlobalGenerator(std::move(gen)); |
| 3757 | } |
| 3758 | } |
| 3759 | // no option assume it is the output file |
| 3760 | else { |
| 3761 | if (!cmSystemTools::FileIsFullPath(arg)) { |
| 3762 | resultFile = cmStrCat(cwd, '/'); |
| 3763 | } |
| 3764 | resultFile += arg; |
| 3765 | writeToStdout = false; |
| 3766 | } |
| 3767 | } |
| 3768 | |
| 3769 | // we have to find the module directory, so we can copy the files |
| 3770 | this->AddCMakePaths(); |
| 3771 | std::string modulesPath = |
| 3772 | cmStrCat(cmSystemTools::GetCMakeRoot(), "/Modules"); |
| 3773 | std::string inFile = cmStrCat(modulesPath, "/SystemInformation.cmake"); |
| 3774 | std::string outFile = cmStrCat(destPath, "/CMakeLists.txt"); |
| 3775 | |
| 3776 | // Copy file |
| 3777 | if (!cmsys::SystemTools::CopyFileAlways(inFile, outFile)) { |
| 3778 | std::cerr << "Error copying file \"" << inFile << "\" to \"" << outFile |
| 3779 | << "\".\n"; |
| 3780 | return 1; |
no test coverage detected