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

Function cmConfigureFileCommand

Source/cmConfigureFileCommand.cxx:22–214  ·  view source on GitHub ↗

cmConfigureFileCommand

Source from the content-addressed store, hash-verified

20
21// cmConfigureFileCommand
22bool cmConfigureFileCommand(std::vector<std::string> const& args,
23 cmExecutionStatus& status)
24{
25 if (args.size() < 2) {
26 status.SetError("called with incorrect number of arguments, expected 2");
27 return false;
28 }
29
30 std::string const& inFile = args[0];
31 std::string const inputFile = cmSystemTools::CollapseFullPath(
32 inFile, status.GetMakefile().GetCurrentSourceDirectory());
33
34 // If the input location is a directory, error out.
35 if (cmSystemTools::FileIsDirectory(inputFile)) {
36 status.SetError(cmStrCat("input location\n ", inputFile,
37 "\n"
38 "is a directory but a file was expected."));
39 return false;
40 }
41
42 std::string const& outFile = args[1];
43 std::string outputFile = cmSystemTools::CollapseFullPath(
44 outFile, status.GetMakefile().GetCurrentBinaryDirectory());
45
46 // If the output location is already a directory put the file in it.
47 if (cmSystemTools::FileIsDirectory(outputFile)) {
48 outputFile += "/";
49 outputFile += cmSystemTools::GetFilenameName(inFile);
50 }
51
52 if (!status.GetMakefile().CanIWriteThisFile(outputFile)) {
53 std::string e = "attempted to configure a file: " + outputFile +
54 " into a source directory.";
55 status.SetError(e);
56 cmSystemTools::SetFatalErrorOccurred();
57 return false;
58 }
59 std::string errorMessage;
60 cmNewLineStyle newLineStyle;
61 if (!newLineStyle.ReadFromArguments(args, errorMessage)) {
62 status.SetError(errorMessage);
63 return false;
64 }
65 bool copyOnly = false;
66 bool escapeQuotes = false;
67 bool useSourcePermissions = false;
68 bool noSourcePermissions = false;
69 bool filePermissions = false;
70 std::vector<std::string> filePermissionOptions;
71
72 enum class Doing
73 {
74 DoingNone,
75 DoingFilePermissions,
76 DoneFilePermissions
77 };
78
79 Doing doing = Doing::DoingNone;

Callers

nothing calls this directly

Calls 14

CanIWriteThisFileMethod · 0.80
ReadFromArgumentsMethod · 0.80
push_backMethod · 0.80
strMethod · 0.80
cmStrCatFunction · 0.70
sizeMethod · 0.45
SetErrorMethod · 0.45
GetMakefileMethod · 0.45
IsValidMethod · 0.45
findMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…