فهرست منبع

Xcode: Add internal API to find xcodebuild

Teach the Xcode generator to compute the location of this tool or the
cmakexbuild wrapper.  Add internal APIs to get the locations on demand.

Use the "cmakexbuild" wrapper for Xcode < 4, and "xcodebuild" for modern
Xcode.
Brad King 11 سال پیش
والد
کامیت
e4055a6144
2فایلهای تغییر یافته به همراه36 افزوده شده و 0 حذف شده
  1. 31 0
      Source/cmGlobalXCodeGenerator.cxx
  2. 5 0
      Source/cmGlobalXCodeGenerator.h

+ 31 - 0
Source/cmGlobalXCodeGenerator.cxx

@@ -143,6 +143,7 @@ cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(std::string const& version)
   this->ResourcesGroupChildren = 0;
   this->ResourcesGroupChildren = 0;
   this->CurrentMakefile = 0;
   this->CurrentMakefile = 0;
   this->CurrentLocalGenerator = 0;
   this->CurrentLocalGenerator = 0;
+  this->XcodeBuildCommandInitialized = false;
 }
 }
 
 
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------
@@ -201,6 +202,36 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::Factory
 #endif
 #endif
 }
 }
 
 
+//----------------------------------------------------------------------------
+std::string const& cmGlobalXCodeGenerator::GetXcodeBuildCommand()
+{
+  if(!this->XcodeBuildCommandInitialized)
+    {
+    this->XcodeBuildCommandInitialized = true;
+    this->XcodeBuildCommand = this->FindXcodeBuildCommand();
+    }
+  return this->XcodeBuildCommand;
+}
+
+//----------------------------------------------------------------------------
+std::string cmGlobalXCodeGenerator::FindXcodeBuildCommand()
+{
+  if (this->XcodeVersion >= 40)
+    {
+    std::string makeProgram = cmSystemTools::FindProgram("xcodebuild");
+    if (makeProgram.empty())
+      {
+      makeProgram = "xcodebuild";
+      }
+    return makeProgram;
+    }
+  else
+    {
+    // Use cmakexbuild wrapper to suppress environment dump from output.
+    return cmSystemTools::GetCMakeCommand() + "xbuild";
+    }
+}
+
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------
 bool cmGlobalXCodeGenerator::SetGeneratorToolset(std::string const& ts,
 bool cmGlobalXCodeGenerator::SetGeneratorToolset(std::string const& ts,
                                                  cmMakefile* mf)
                                                  cmMakefile* mf)

+ 5 - 0
Source/cmGlobalXCodeGenerator.h

@@ -212,6 +212,11 @@ protected:
   std::vector<cmXCodeObject*> XCodeObjects;
   std::vector<cmXCodeObject*> XCodeObjects;
   cmXCodeObject* RootObject;
   cmXCodeObject* RootObject;
 private:
 private:
+  std::string const& GetXcodeBuildCommand();
+  std::string FindXcodeBuildCommand();
+  std::string XcodeBuildCommand;
+  bool XcodeBuildCommandInitialized;
+
   void PrintCompilerAdvice(std::ostream&, std::string const&,
   void PrintCompilerAdvice(std::ostream&, std::string const&,
                            const char*) const {}
                            const char*) const {}