| 1538 | } |
| 1539 | |
| 1540 | bool HandleFilesMode(std::vector<std::string> const& args, |
| 1541 | cmExecutionStatus& status) |
| 1542 | { |
| 1543 | Helper helper(status); |
| 1544 | |
| 1545 | // This is the FILES mode. |
| 1546 | bool programs = (args[0] == "PROGRAMS"); |
| 1547 | cmInstallCommandArguments ica(helper.DefaultComponentName, *helper.Makefile); |
| 1548 | ArgumentParser::MaybeEmpty<std::vector<std::string>> files; |
| 1549 | ica.Bind(programs ? "PROGRAMS"_s : "FILES"_s, files); |
| 1550 | std::vector<std::string> unknownArgs; |
| 1551 | ica.Parse(args, &unknownArgs); |
| 1552 | |
| 1553 | if (!unknownArgs.empty()) { |
| 1554 | // Unknown argument. |
| 1555 | status.SetError( |
| 1556 | cmStrCat(args[0], " given unknown argument \"", unknownArgs[0], "\".")); |
| 1557 | return false; |
| 1558 | } |
| 1559 | |
| 1560 | std::string type = ica.GetType(); |
| 1561 | if (!type.empty() && allowedTypes.count(type) == 0) { |
| 1562 | status.SetError( |
| 1563 | cmStrCat(args[0], " given non-type \"", type, "\" with TYPE argument.")); |
| 1564 | return false; |
| 1565 | } |
| 1566 | |
| 1567 | std::vector<std::string> const& filesVector = files; |
| 1568 | |
| 1569 | // Check if there is something to do. |
| 1570 | if (filesVector.empty()) { |
| 1571 | return true; |
| 1572 | } |
| 1573 | |
| 1574 | if (!ica.GetRename().empty() && filesVector.size() > 1) { |
| 1575 | // The rename option works only with one file. |
| 1576 | status.SetError( |
| 1577 | cmStrCat(args[0], " given RENAME option with more than one file.")); |
| 1578 | return false; |
| 1579 | } |
| 1580 | |
| 1581 | std::vector<std::string> absFiles; |
| 1582 | if (!helper.MakeFilesFullPath(args[0].c_str(), filesVector, absFiles)) { |
| 1583 | return false; |
| 1584 | } |
| 1585 | |
| 1586 | cmGlobalGenerator* gg = helper.Makefile->GetGlobalGenerator(); |
| 1587 | for (std::string const& file : filesVector) { |
| 1588 | if (gg->IsExportedTargetsFile(file)) { |
| 1589 | helper.Makefile->IssueMessage( |
| 1590 | MessageType::FATAL_ERROR, |
| 1591 | cmStrCat("The file\n ", file, |
| 1592 | "\n" |
| 1593 | "was generated by the export() command. " |
| 1594 | "It may not be installed with the install() command. " |
| 1595 | "Use the install(EXPORT) mechanism instead. " |
| 1596 | "See the cmake-packages(7) manual for more.")); |
| 1597 | return false; |
nothing calls this directly
no test coverage detected
searching dependent graphs…