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

Method GenerateBuildCommand

Source/cmGlobalXCodeGenerator.cxx:566–671  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

564}
565
566std::vector<cmGlobalGenerator::GeneratedMakeCommand>
567cmGlobalXCodeGenerator::GenerateBuildCommand(
568 std::string const& makeProgram, std::string const& projectName,
569 std::string const& /*projectDir*/,
570 std::vector<std::string> const& targetNames, std::string const& config,
571 int jobs, bool /*verbose*/, cmBuildOptions /*buildOptions*/,
572 std::vector<std::string> const& makeOptions,
573 BuildTryCompile /*isInTryCompile */)
574{
575 std::string const xcodebuild =
576 this->SelectMakeProgram(makeProgram, this->GetXcodeBuildCommand());
577
578 // Note that projectName can be empty, such as from a command like this one:
579 // ctest --build-and-test . build --build-generator Xcode
580 // If projectName is empty, then isWorkspace set further below will always
581 // be false because workspacePath will never point to a valid workspace file.
582 // And if projectName is empty, we don't add any -workspace or -project
583 // option to the xcodebuild command line because we don't know what to put
584 // after either option. For that scenario, we rely on xcodebuild finding
585 // exactly one .xcodeproj file in the working directory.
586
587 std::string const workspacePath = cmStrCat(projectName, ".xcworkspace");
588 std::string const projectPath = cmStrCat(projectName, ".xcodeproj");
589
590 // If an external tool created a workspace then build it instead.
591 bool const isWorkspace = cmSystemTools::FileIsDirectory(workspacePath);
592
593 std::string const targetFlag = isWorkspace ? "-scheme" : "-target";
594
595 std::vector<std::string> requiredArgs;
596
597 if (isWorkspace) {
598 requiredArgs.insert(requiredArgs.end(), { "-workspace", workspacePath });
599 } else if (!projectName.empty()) {
600 requiredArgs.insert(requiredArgs.end(), { "-project", projectPath });
601 }
602
603 bool const isCleanBuild = cm::contains(targetNames, "clean");
604 bool const isTargetEmpty = targetNames.empty() ||
605 ((targetNames.size() == 1) && targetNames.front().empty());
606
607 if (isCleanBuild) {
608 requiredArgs.push_back("clean");
609 } else {
610 requiredArgs.push_back("build");
611 }
612
613 requiredArgs.insert(requiredArgs.end(),
614 { "-configuration", config.empty() ? "Debug" : config });
615
616 if (isWorkspace) {
617 requiredArgs.insert(
618 requiredArgs.end(),
619 { "-destination",
620 cmStrCat("generic/platform=", this->GetAppleSpecificPlatformName()) });
621 }
622
623 if ((this->XcodeBuildSystem >= BuildSystem::Twelve) ||

Callers

nothing calls this directly

Calls 15

to_stringFunction · 0.85
moveFunction · 0.85
SelectMakeProgramMethod · 0.80
push_backMethod · 0.80
cbeginMethod · 0.80
cendMethod · 0.80
emplace_backMethod · 0.80
cmStrCatFunction · 0.70
insertMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected