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

Method TryRunCode

Source/cmTryRunCommand.cxx:99–261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97};
98
99bool TryRunCommandImpl::TryRunCode(std::vector<std::string> const& argv)
100{
101 this->RunResultVariable = argv[0];
102 cmCoreTryCompile::Arguments arguments =
103 this->ParseArgs(cmMakeRange(argv).advance(1), true);
104 if (!arguments) {
105 return true;
106 }
107 this->NoCache = arguments.NoCache;
108
109 // although they could be used together, don't allow it, because
110 // using OUTPUT_VARIABLE makes crosscompiling harder
111 if (arguments.OutputVariable &&
112 (arguments.CompileOutputVariable || arguments.RunOutputVariable ||
113 arguments.RunOutputStdOutVariable ||
114 arguments.RunOutputStdErrVariable)) {
115 cmSystemTools::Error(
116 "You cannot use OUTPUT_VARIABLE together with COMPILE_OUTPUT_VARIABLE "
117 ", RUN_OUTPUT_VARIABLE, RUN_OUTPUT_STDOUT_VARIABLE or "
118 "RUN_OUTPUT_STDERR_VARIABLE. "
119 "Please use only COMPILE_OUTPUT_VARIABLE, RUN_OUTPUT_VARIABLE, "
120 "RUN_OUTPUT_STDOUT_VARIABLE "
121 "and/or RUN_OUTPUT_STDERR_VARIABLE.");
122 return false;
123 }
124
125 if ((arguments.RunOutputStdOutVariable ||
126 arguments.RunOutputStdErrVariable) &&
127 arguments.RunOutputVariable) {
128 cmSystemTools::Error(
129 "You cannot use RUN_OUTPUT_STDOUT_VARIABLE or "
130 "RUN_OUTPUT_STDERR_VARIABLE together "
131 "with RUN_OUTPUT_VARIABLE. Please use only COMPILE_OUTPUT_VARIABLE or "
132 "RUN_OUTPUT_STDOUT_VARIABLE and/or RUN_OUTPUT_STDERR_VARIABLE.");
133 return false;
134 }
135
136 if (arguments.RunWorkingDirectory) {
137 if (!cmSystemTools::MakeDirectory(*arguments.RunWorkingDirectory)) {
138 cmSystemTools::Error(cmStrCat("Error creating working directory \"",
139 *arguments.RunWorkingDirectory, "\"."));
140 return false;
141 }
142 }
143
144 bool captureRunOutput = false;
145 if (arguments.OutputVariable) {
146 captureRunOutput = true;
147 } else if (arguments.CompileOutputVariable) {
148 arguments.OutputVariable = arguments.CompileOutputVariable;
149 }
150
151 // Capture the split output for the configure log unless the caller
152 // requests combined output to be captured by a variable.
153 bool captureRunOutputStdOutErr = true;
154 if (!arguments.RunOutputStdOutVariable &&
155 !arguments.RunOutputStdErrVariable) {
156 if (arguments.RunOutputVariable) {

Callers 1

cmTryRunCommandFunction · 0.80

Calls 15

DoNotRunExecutableMethod · 0.95
RunExecutableMethod · 0.95
cmMakeRangeFunction · 0.85
WriteTryRunEventFunction · 0.85
ParseArgsMethod · 0.80
TryCompileCodeMethod · 0.80
IsDefinitionSetMethod · 0.80
GetConfigureLogMethod · 0.80
GetDebugTryCompileMethod · 0.80
CleanupFilesMethod · 0.80
ErrorClass · 0.70
cmStrCatFunction · 0.70

Tested by

no test coverage detected