mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-19 11:18:40 +08:00
xcode: Restore ctest --build-and-test without --build-project
Previously, it used to be possible to execute ctest --build-and-test without specifying --build-project. When used with the Xcode generator, this would work as long as there was only one .xcodeproj file in the directory, where xcodebuild would then default to using that project. The recent changes to support .xcworkspace files broke that logic, placing a malformed pair of options "-project .xcodeproj" on the command line instead of omitting the "-project" option altogether. Fixes: #27090
This commit is contained in:

committed by
Craig Scott

parent
fa3978fa85
commit
0b7d8e4ad6
@@ -551,6 +551,15 @@ cmGlobalXCodeGenerator::GenerateBuildCommand(
|
||||
std::string const xcodebuild =
|
||||
this->SelectMakeProgram(makeProgram, this->GetXcodeBuildCommand());
|
||||
|
||||
// Note that projectName can be empty, such as from a command like this one:
|
||||
// ctest --build-and-test . build --build-generator Xcode
|
||||
// If projectName is empty, then isWorkspace set further below will always
|
||||
// be false because workspacePath will never point to a valid workspace file.
|
||||
// And if projectName is empty, we don't add any -workspace or -project
|
||||
// option to the xcodebuild command line because we don't know what to put
|
||||
// after either option. For that scenario, we rely on xcodebuild finding
|
||||
// exactly one .xcodeproj file in the working directory.
|
||||
|
||||
std::string const workspacePath = cmStrCat(projectName, ".xcworkspace");
|
||||
std::string const projectPath = cmStrCat(projectName, ".xcodeproj");
|
||||
|
||||
@@ -563,7 +572,7 @@ cmGlobalXCodeGenerator::GenerateBuildCommand(
|
||||
|
||||
if (isWorkspace) {
|
||||
requiredArgs.insert(requiredArgs.end(), { "-workspace", workspacePath });
|
||||
} else {
|
||||
} else if (!projectName.empty()) {
|
||||
requiredArgs.insert(requiredArgs.end(), { "-project", projectPath });
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user