Merge topic 'xcode-build-layout'

d0a6ebf57b Xcode: Fix "clean" operation under the "new build system"
dc5fc898f6 Xcode: Set object file locations using TARGET_TEMP_DIR
a7fb4bc475 Xcode: Set build product locations using CONFIGURATION_BUILD_DIR
6883b82124 cmGlobalXCodeGenerator: Remove unused local variable settings

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7730
This commit is contained in:
Brad King
2022-09-30 11:24:41 +00:00
committed by Kitware Robot
7 changed files with 34 additions and 48 deletions

View File

@@ -5454,9 +5454,6 @@ std::string cmGeneratorTarget::GetObjectDirectory(
std::string obj_dir =
this->GlobalGenerator->ExpandCFGIntDir(this->ObjectDirectory, config);
#if defined(__APPLE__)
// find and replace $(PROJECT_NAME) xcode placeholder
const std::string projectName = this->LocalGenerator->GetProjectName();
cmSystemTools::ReplaceString(obj_dir, "$(PROJECT_NAME)", projectName);
// Replace Xcode's placeholder for the object file directory since
// installation and export scripts need to know the real directory.
// Xcode has build-time settings (e.g. for sanitizers) that affect this,

View File

@@ -607,7 +607,6 @@ std::string cmGlobalXCodeGenerator::PostBuildMakeTarget(
}
#define CMAKE_CHECK_BUILD_SYSTEM_TARGET "ZERO_CHECK"
#define OBJECT_LIBRARY_ARTIFACT_DIR std::string()
void cmGlobalXCodeGenerator::AddExtraTargets(
cmLocalGenerator* root, std::vector<cmLocalGenerator*>& gens)
@@ -2518,18 +2517,28 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
soName += *soversion;
}
if (gtgt->CanCompileSources()) {
std::string tmpDir =
cmStrCat(gtgt->GetSupportDirectory(), '/', this->GetCMakeCFGIntDir());
buildSettings->AddAttribute("TARGET_TEMP_DIR", this->CreateString(tmpDir));
std::string outDir;
if (gtgt->GetType() == cmStateEnums::OBJECT_LIBRARY) {
// We cannot suppress the archive, so hide it with intermediate files.
outDir = tmpDir;
} else {
outDir = gtgt->GetDirectory(configName);
}
buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR",
this->CreateString(outDir));
}
// Set attributes to specify the proper name for the target.
std::string pndir = this->CurrentLocalGenerator->GetCurrentBinaryDirectory();
if (gtgt->GetType() == cmStateEnums::STATIC_LIBRARY ||
gtgt->GetType() == cmStateEnums::SHARED_LIBRARY ||
gtgt->GetType() == cmStateEnums::MODULE_LIBRARY ||
gtgt->GetType() == cmStateEnums::EXECUTABLE) {
if (!gtgt->UsesDefaultOutputDir(configName,
cmStateEnums::RuntimeBinaryArtifact)) {
std::string pncdir = gtgt->GetDirectory(configName);
buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR",
this->CreateString(pncdir));
}
if (gtgt->IsFrameworkOnApple() || gtgt->IsCFBundleOnApple()) {
pnprefix = "";
@@ -2539,20 +2548,10 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
this->CreateString(pnprefix));
buildSettings->AddAttribute("EXECUTABLE_SUFFIX",
this->CreateString(pnsuffix));
} else if (gtgt->GetType() == cmStateEnums::OBJECT_LIBRARY) {
pnprefix = "lib";
pnbase = gtgt->GetName();
pnsuffix = ".a";
std::string pncdir = this->GetObjectsDirectory(
this->CurrentProject, configName, gtgt, OBJECT_LIBRARY_ARTIFACT_DIR);
buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR",
this->CreateString(pncdir));
}
// Store the product name for all target types.
buildSettings->AddAttribute("PRODUCT_NAME", this->CreateString(realName));
buildSettings->AddAttribute("SYMROOT", this->CreateString(pndir));
// Handle settings for each target type.
switch (gtgt->GetType()) {
@@ -4465,16 +4464,6 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
return true;
}
std::string cmGlobalXCodeGenerator::GetObjectsDirectory(
const std::string& projName, const std::string& configName,
const cmGeneratorTarget* t, const std::string& variant) const
{
std::string dir = cmStrCat(
t->GetLocalGenerator()->GetCurrentBinaryDirectory(), '/', projName,
".build/", configName, '/', t->GetName(), ".build/", variant);
return dir;
}
void cmGlobalXCodeGenerator::ComputeArchitectures(cmMakefile* mf)
{
this->Architectures.clear();
@@ -4598,10 +4587,8 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackMakefile(
for (auto objLib : objlibs) {
const std::string objLibName = objLib->GetName();
std::string d = cmStrCat(
this->GetObjectsDirectory(this->CurrentProject, configName, objLib,
OBJECT_LIBRARY_ARTIFACT_DIR),
"lib", objLibName, ".a");
std::string d = cmStrCat(objLib->GetSupportDirectory(), '/',
configName, "/lib", objLibName, ".a");
std::string dependency = this->ConvertToRelativeForMake(d);
makefileStream << "\\\n\t" << dependency;
@@ -4615,8 +4602,8 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackMakefile(
// if building for more than one architecture
// then remove those executables as well
if (this->Architectures.size() > 1) {
std::string universal = this->GetObjectsDirectory(
this->CurrentProject, configName, gt, "$(OBJDIR)/");
std::string universal = cmStrCat(gt->GetSupportDirectory(), '/',
configName, "/$(OBJDIR)/");
for (const auto& architecture : this->Architectures) {
std::string universalFile = cmStrCat(universal, architecture, '/',
gt->GetFullName(configName));
@@ -5013,14 +5000,10 @@ bool cmGlobalXCodeGenerator::ShouldStripResourcePath(cmMakefile*) const
void cmGlobalXCodeGenerator::ComputeTargetObjectDirectory(
cmGeneratorTarget* gt) const
{
std::string configName = this->GetCMakeCFGIntDir();
auto objectDirArch = GetTargetObjectDirArch(*gt, this->ObjectDirArch);
std::string dir =
cmStrCat(this->GetObjectsDirectory("$(PROJECT_NAME)", configName, gt,
"$(OBJECT_FILE_DIR_normal:base)/"),
objectDirArch, '/');
gt->ObjectDirectory = dir;
gt->ObjectDirectory =
cmStrCat(gt->GetSupportDirectory(), '/', this->GetCMakeCFGIntDir(),
"/$(OBJECT_FILE_DIR_normal:base)/", objectDirArch, '/');
}
std::string cmGlobalXCodeGenerator::GetDeploymentPlatform(const cmMakefile* mf)

View File

@@ -339,11 +339,6 @@ private:
std::string GetLibraryOrFrameworkPath(const std::string& path) const;
std::string GetObjectsDirectory(const std::string& projName,
const std::string& configName,
const cmGeneratorTarget* t,
const std::string& variant) const;
static std::string GetDeploymentPlatform(const cmMakefile* mf);
void ComputeArchitectures(cmMakefile* mf);

View File

@@ -0,0 +1,2 @@
enable_language(C)
add_subdirectory(Clean)

View File

@@ -0,0 +1 @@
add_library(empty empty.c)

View File

@@ -1,5 +1,13 @@
include(RunCMake)
function(RunClean)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Clean-build)
run_cmake(Clean)
set(RunCMake_TEST_NO_CLEAN 1)
run_cmake_command(Clean-build xcodebuild clean)
endfunction()
RunClean()
run_cmake(ExplicitCMakeLists)
run_cmake(ImplicitCMakeLists)
run_cmake(InterfaceLibSources)