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

Method Build

Source/cmGlobalGenerator.cxx:2319–2442  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2317}
2318
2319int cmGlobalGenerator::Build(cmBuildArgs const& buildArgs,
2320 std::vector<std::string> const& targets,
2321 std::ostream& ostr,
2322 std::string const& makeCommandCSTR,
2323 std::string const& config,
2324 cmBuildOptions buildOptions, cmDuration timeout,
2325 cmSystemTools::OutputOption outputMode,
2326 std::vector<std::string> const& nativeOptions,
2327 BuildTryCompile isInTryCompile)
2328{
2329 bool hideconsole = cmSystemTools::GetRunCommandHideConsole();
2330
2331 /**
2332 * Run an executable command and put the stdout in output.
2333 */
2334 cmWorkingDirectory workdir(buildArgs.binaryDir);
2335 ostr << "Change Dir: '" << buildArgs.binaryDir << '\'' << std::endl;
2336 if (workdir.Failed()) {
2337 cmSystemTools::SetRunCommandHideConsole(hideconsole);
2338 std::string const& err = workdir.GetError();
2339 cmSystemTools::Error(err);
2340 ostr << err << std::endl;
2341 return 1;
2342 }
2343 std::string realConfig = config;
2344 if (realConfig.empty()) {
2345 realConfig = this->GetDefaultBuildConfig();
2346 }
2347
2348 int retVal = 0;
2349 cmSystemTools::SetRunCommandHideConsole(true);
2350
2351 // Capture build command output when outputMode == OUTPUT_NONE.
2352 std::string outputBuf;
2353
2354 std::vector<GeneratedMakeCommand> makeCommand = this->GenerateBuildCommand(
2355 makeCommandCSTR, buildArgs.projectName, buildArgs.binaryDir, targets,
2356 realConfig, buildArgs.jobs, buildArgs.verbose, buildOptions, nativeOptions,
2357 isInTryCompile);
2358
2359 // Workaround to convince some commands to produce output.
2360 if (outputMode == cmSystemTools::OUTPUT_PASSTHROUGH &&
2361 makeCommand.back().RequiresOutputForward) {
2362 outputMode = cmSystemTools::OUTPUT_FORWARD;
2363 }
2364
2365 // should we do a clean first?
2366 if (buildOptions.Clean) {
2367 std::vector<GeneratedMakeCommand> cleanCommand =
2368 this->GenerateBuildCommand(makeCommandCSTR, buildArgs.projectName,
2369 buildArgs.binaryDir, { "clean" }, realConfig,
2370 buildArgs.jobs, buildArgs.verbose,
2371 buildOptions);
2372 ostr << "\nRun Clean Command: " << cleanCommand.front().QuotedPrintable()
2373 << std::endl;
2374 if (cleanCommand.size() != 1) {
2375 this->GetCMakeInstance()->IssueMessage(MessageType::INTERNAL_ERROR,
2376 "The generator did not produce "

Callers 1

TryCompileMethod · 0.95

Calls 15

GetDefaultBuildConfigMethod · 0.95
GenerateBuildCommandMethod · 0.95
GetCMakeInstanceMethod · 0.95
FailedMethod · 0.80
QuotedPrintableMethod · 0.80
UseWatcomWMakeMethod · 0.80
PrintableMethod · 0.80
ErrorClass · 0.70
cmStrCatFunction · 0.70
GetErrorMethod · 0.45
emptyMethod · 0.45
backMethod · 0.45

Tested by

no test coverage detected