MCPcopy Create free account
hub / github.com/Kitware/CMake / HandleFilesMode

Function HandleFilesMode

Source/cmInstallCommand.cxx:1540–1629  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1538}
1539
1540bool 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;

Callers

nothing calls this directly

Calls 15

GetRenameMethod · 0.80
MakeFilesFullPathMethod · 0.80
c_strMethod · 0.80
IsExportedTargetsFileMethod · 0.80
GetDestinationForTypeMethod · 0.80
AddInstallComponentMethod · 0.80
cmStrCatFunction · 0.70
BindMethod · 0.45
ParseMethod · 0.45
emptyMethod · 0.45
SetErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…