Jelajahi Sumber

Xcode: Place object library artifacts outside Objects-normal directory

The `CONFIGURATION_BUILD_DIR` value in the Xcode project file specifies
where to place the library artifact.  For object libraries we've used
the `Objects-normal` directory to hide away the `.a` that we otherwise
cannot stop Xcode from producing.  The parent of this directory is also
specific to the target and does not vary with Xcode's sanitizer
features, so move the artifact there.

Issue: #16289
Brad King 6 tahun lalu
induk
melakukan
eff9c69740
2 mengubah file dengan 18 tambahan dan 15 penghapusan
  1. 14 12
      Source/cmGlobalXCodeGenerator.cxx
  2. 4 3
      Source/cmGlobalXCodeGenerator.h

+ 14 - 12
Source/cmGlobalXCodeGenerator.cxx

@@ -485,6 +485,7 @@ std::string cmGlobalXCodeGenerator::PostBuildMakeTarget(
 }
 }
 
 
 #define CMAKE_CHECK_BUILD_SYSTEM_TARGET "ZERO_CHECK"
 #define CMAKE_CHECK_BUILD_SYSTEM_TARGET "ZERO_CHECK"
+#define OBJECT_LIBRARY_ARTIFACT_DIR std::string()
 
 
 void cmGlobalXCodeGenerator::AddExtraTargets(
 void cmGlobalXCodeGenerator::AddExtraTargets(
   cmLocalGenerator* root, std::vector<cmLocalGenerator*>& gens)
   cmLocalGenerator* root, std::vector<cmLocalGenerator*>& gens)
@@ -1968,8 +1969,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
     pnbase = gtgt->GetName();
     pnbase = gtgt->GetName();
     pnsuffix = ".a";
     pnsuffix = ".a";
 
 
-    std::string pncdir =
-      this->GetObjectsNormalDirectory(this->CurrentProject, configName, gtgt);
+    std::string pncdir = this->GetObjectsDirectory(
+      this->CurrentProject, configName, gtgt, OBJECT_LIBRARY_ARTIFACT_DIR);
     buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR",
     buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR",
                                 this->CreateString(pncdir));
                                 this->CreateString(pncdir));
   }
   }
@@ -3199,9 +3200,9 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
   return true;
   return true;
 }
 }
 
 
-std::string cmGlobalXCodeGenerator::GetObjectsNormalDirectory(
+std::string cmGlobalXCodeGenerator::GetObjectsDirectory(
   const std::string& projName, const std::string& configName,
   const std::string& projName, const std::string& configName,
-  const cmGeneratorTarget* t) const
+  const cmGeneratorTarget* t, const std::string& variant) const
 {
 {
   std::string dir = t->GetLocalGenerator()->GetCurrentBinaryDirectory();
   std::string dir = t->GetLocalGenerator()->GetCurrentBinaryDirectory();
   dir += "/";
   dir += "/";
@@ -3210,8 +3211,8 @@ std::string cmGlobalXCodeGenerator::GetObjectsNormalDirectory(
   dir += configName;
   dir += configName;
   dir += "/";
   dir += "/";
   dir += t->GetName();
   dir += t->GetName();
-  dir += ".build/Objects-normal/";
-
+  dir += ".build/";
+  dir += variant;
   return dir;
   return dir;
 }
 }
 
 
@@ -3338,8 +3339,9 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
         for (auto objLib : objlibs) {
         for (auto objLib : objlibs) {
 
 
           const std::string objLibName = objLib->GetName();
           const std::string objLibName = objLib->GetName();
-          std::string d = this->GetObjectsNormalDirectory(this->CurrentProject,
-                                                          configName, objLib);
+          std::string d =
+            this->GetObjectsDirectory(this->CurrentProject, configName, objLib,
+                                      OBJECT_LIBRARY_ARTIFACT_DIR);
           d += "lib";
           d += "lib";
           d += objLibName;
           d += objLibName;
           d += ".a";
           d += ".a";
@@ -3356,8 +3358,8 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
         // if building for more than one architecture
         // if building for more than one architecture
         // then remove those executables as well
         // then remove those executables as well
         if (this->Architectures.size() > 1) {
         if (this->Architectures.size() > 1) {
-          std::string universal = this->GetObjectsNormalDirectory(
-            this->CurrentProject, configName, gt);
+          std::string universal = this->GetObjectsDirectory(
+            this->CurrentProject, configName, gt, "Objects-normal/");
           for (const auto& architecture : this->Architectures) {
           for (const auto& architecture : this->Architectures) {
             std::string universalFile = universal;
             std::string universalFile = universal;
             universalFile += architecture;
             universalFile += architecture;
@@ -3761,8 +3763,8 @@ void cmGlobalXCodeGenerator::ComputeTargetObjectDirectory(
   cmGeneratorTarget* gt) const
   cmGeneratorTarget* gt) const
 {
 {
   std::string configName = this->GetCMakeCFGIntDir();
   std::string configName = this->GetCMakeCFGIntDir();
-  std::string dir =
-    this->GetObjectsNormalDirectory("$(PROJECT_NAME)", configName, gt);
+  std::string dir = this->GetObjectsDirectory("$(PROJECT_NAME)", configName,
+                                              gt, "Objects-normal/");
   dir += this->ObjectDirArch;
   dir += this->ObjectDirArch;
   dir += "/";
   dir += "/";
   gt->ObjectDirectory = dir;
   gt->ObjectDirectory = dir;

+ 4 - 3
Source/cmGlobalXCodeGenerator.h

@@ -264,9 +264,10 @@ private:
   {
   {
   }
   }
 
 
-  std::string GetObjectsNormalDirectory(const std::string& projName,
-                                        const std::string& configName,
-                                        const cmGeneratorTarget* t) 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);
   static std::string GetDeploymentPlatform(const cmMakefile* mf);