summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalXCodeGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-01-30 14:42:02 (GMT)
committerBrad King <brad.king@kitware.com>2019-01-30 15:28:40 (GMT)
commit8a7f93d000f1676d6051027b0608ca7658c8f00e (patch)
tree501fddfe78d4df3720624a4dd8e320e1d3de6d14 /Source/cmGlobalXCodeGenerator.cxx
parenteff9c69740d5d4a26025a89f517a612e446077c0 (diff)
downloadCMake-8a7f93d000f1676d6051027b0608ca7658c8f00e.zip
CMake-8a7f93d000f1676d6051027b0608ca7658c8f00e.tar.gz
CMake-8a7f93d000f1676d6051027b0608ca7658c8f00e.tar.bz2
Xcode: Fix object library builds with sanitizers enabled
Using `xcodebuild -enableAddressSanitizer YES ...` causes object files to be placed in a different directory name. Xcode provides a placeholder for this that we can use in `OTHER_LDFLAGS` to reference object files for linking the dependents of object libraries. However, CMake's features for installing and exporting object libraries depend on knowing the real path with no placeholders. For these cases, use the default object directory. Users will then have to choose between sanitizers and the installation and export features, but both will work individually. Fixes: #16289
Diffstat (limited to 'Source/cmGlobalXCodeGenerator.cxx')
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx8
1 files changed, 5 insertions, 3 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index cc5ddb8..0bd0580 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -510,6 +510,7 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
makeHelper.push_back(dir);
makeHelper.push_back("-f");
makeHelper.push_back(this->CurrentXCodeHackMakefile);
+ makeHelper.push_back("OBJDIR=$(OBJDIR)");
makeHelper.push_back(""); // placeholder, see below
// Add ZERO_CHECK
@@ -1662,6 +1663,7 @@ void cmGlobalXCodeGenerator::AddCommandsToBuildPhase(
makecmd += cdir;
makecmd += " -f ";
makecmd += this->ConvertToRelativeForMake((makefile + "$CONFIGURATION"));
+ makecmd += " OBJDIR=$(basename \"$OBJECT_FILE_DIR_normal\")";
makecmd += " all";
buildphase->AddAttribute("shellScript", this->CreateString(makecmd));
buildphase->AddAttribute("showEnvVarsInLog", this->CreateString("0"));
@@ -3359,7 +3361,7 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
// then remove those executables as well
if (this->Architectures.size() > 1) {
std::string universal = this->GetObjectsDirectory(
- this->CurrentProject, configName, gt, "Objects-normal/");
+ this->CurrentProject, configName, gt, "$(OBJDIR)/");
for (const auto& architecture : this->Architectures) {
std::string universalFile = universal;
universalFile += architecture;
@@ -3763,8 +3765,8 @@ void cmGlobalXCodeGenerator::ComputeTargetObjectDirectory(
cmGeneratorTarget* gt) const
{
std::string configName = this->GetCMakeCFGIntDir();
- std::string dir = this->GetObjectsDirectory("$(PROJECT_NAME)", configName,
- gt, "Objects-normal/");
+ std::string dir = this->GetObjectsDirectory(
+ "$(PROJECT_NAME)", configName, gt, "$(OBJECT_FILE_DIR_normal:base)/");
dir += this->ObjectDirArch;
dir += "/";
gt->ObjectDirectory = dir;