summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-09-29 14:31:26 -0400
committerBrad King <brad.king@kitware.com>2022-09-29 15:04:07 -0400
commitdc5fc898f68846b24723b5702731ee2efb94f603 (patch)
tree61c6698b4d6eed2d3e9506efc8a47063435fa1f4 /Source
parenta7fb4bc4750ed2d8f4eb6e2aca312cc35b8e96cc (diff)
downloadcmake-dc5fc898f68846b24723b5702731ee2efb94f603.tar.gz
Xcode: Set object file locations using TARGET_TEMP_DIR
This avoids relying on `SYMROOT` to locate the object files. Issue: #22550
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGeneratorTarget.cxx3
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx38
-rw-r--r--Source/cmGlobalXCodeGenerator.h5
3 files changed, 12 insertions, 34 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 7f1e426381..53cb03069a 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -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,
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 6f82cb50a3..fab5120208 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -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)
@@ -2519,11 +2518,14 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
}
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 = this->GetObjectsDirectory(this->CurrentProject, configName,
- gtgt, OBJECT_LIBRARY_ARTIFACT_DIR);
+ outDir = tmpDir;
} else {
outDir = gtgt->GetDirectory(configName);
}
@@ -4463,16 +4465,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();
@@ -4596,10 +4588,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;
@@ -4613,8 +4603,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));
@@ -5011,14 +5001,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)
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index 92e45280d1..e924169404 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -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);