diff options
author | Brad King <brad.king@kitware.com> | 2022-09-29 18:31:26 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-09-29 19:04:07 (GMT) |
commit | dc5fc898f68846b24723b5702731ee2efb94f603 (patch) | |
tree | 61c6698b4d6eed2d3e9506efc8a47063435fa1f4 /Source/cmGlobalXCodeGenerator.cxx | |
parent | a7fb4bc4750ed2d8f4eb6e2aca312cc35b8e96cc (diff) | |
download | CMake-dc5fc898f68846b24723b5702731ee2efb94f603.zip CMake-dc5fc898f68846b24723b5702731ee2efb94f603.tar.gz CMake-dc5fc898f68846b24723b5702731ee2efb94f603.tar.bz2 |
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/cmGlobalXCodeGenerator.cxx')
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 6f82cb5..fab5120 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) |