[Cmake-commits] [cmake-commits] king committed cmGlobalXCodeGenerator.cxx 1.212 1.213 cmGlobalXCodeGenerator.h 1.57 1.58

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Jul 2 14:13:48 EDT 2009


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv20185/Source

Modified Files:
	cmGlobalXCodeGenerator.cxx cmGlobalXCodeGenerator.h 
Log Message:
ENH: Simplify Xcode CreateBuildSettings method

The cmGlobalXCodeGenerator::CreateBuildSettings had the three arguments
productName, productType, and fileType that returned information used by only
one of the call sites.  This change refactors that information into separate
methods named accordingly.


Index: cmGlobalXCodeGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalXCodeGenerator.cxx,v
retrieving revision 1.212
retrieving revision 1.213
diff -C 2 -d -r1.212 -r1.213
*** cmGlobalXCodeGenerator.cxx	2 Jul 2009 18:13:12 -0000	1.212
--- cmGlobalXCodeGenerator.cxx	2 Jul 2009 18:13:46 -0000	1.213
***************
*** 1376,1382 ****
  void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
                                                   cmXCodeObject* buildSettings,
-                                                  std::string& fileType,
-                                                  std::string& productType,
-                                                  std::string& productName,
                                                   const char* configName)
  {
--- 1376,1379 ----
***************
*** 1458,1464 ****
      }
  
-   // The product name is the full name of the target for this configuration.
-   productName = target.GetFullName(configName);
- 
    // Get the product name components.
    std::string pnprefix;
--- 1455,1458 ----
***************
*** 1491,1497 ****
      case cmTarget::STATIC_LIBRARY:
      {
-     fileType = "archive.ar";
-     productType = "com.apple.product-type.library.static";
- 
      buildSettings->AddAttribute("LIBRARY_STYLE", 
                                  this->CreateString("STATIC"));
--- 1485,1488 ----
***************
*** 1505,1511 ****
      if(this->XcodeVersion >= 22)
        {
-       fileType = "compiled.mach-o.executable";
-       productType = "com.apple.product-type.tool";
- 
        buildSettings->AddAttribute("MACH_O_TYPE", 
                                    this->CreateString("mh_bundle"));
--- 1496,1499 ----
***************
*** 1523,1529 ****
      else
        {
-       fileType = "compiled.mach-o.dylib";
-       productType = "com.apple.product-type.library.dynamic";
- 
        // Add the flags to create a module.
        std::string createFlags =
--- 1511,1514 ----
***************
*** 1542,1548 ****
      if(target.GetPropertyAsBool("FRAMEWORK"))
        {
-       fileType = "wrapper.framework";
-       productType = "com.apple.product-type.framework";
- 
        std::string version = target.GetFrameworkVersion();
        buildSettings->AddAttribute("FRAMEWORK_VERSION",
--- 1527,1530 ----
***************
*** 1563,1569 ****
      else
        {
-       fileType = "compiled.mach-o.dylib";
-       productType = "com.apple.product-type.library.dynamic";
- 
        // Add the flags to create a shared library.
        std::string createFlags =
--- 1545,1548 ----
***************
*** 1583,1588 ****
      case cmTarget::EXECUTABLE:
      {
-     fileType = "compiled.mach-o.executable";
- 
      // Add the flags to create an executable.
      std::string createFlags =
--- 1562,1565 ----
***************
*** 1597,1601 ****
      if(target.GetPropertyAsBool("MACOSX_BUNDLE"))
        {
-       productType = "com.apple.product-type.application";
        std::string plist = this->ComputeInfoPListLocation(target);
        // Xcode will create the final version of Info.plist at build time,
--- 1574,1577 ----
***************
*** 1611,1618 ****
  
        }
-     else
-       {
-       productType = "com.apple.product-type.tool";
-       }
      }
      break;
--- 1587,1590 ----
***************
*** 1755,1759 ****
        // link flags to create an install_name with just the library soname.
        extraLinkOptions += " -install_name ";
!       extraLinkOptions += productName;
        }
      else
--- 1727,1731 ----
        // link flags to create an install_name with just the library soname.
        extraLinkOptions += " -install_name ";
!       extraLinkOptions += target.GetFullName(configName);
        }
      else
***************
*** 1870,1876 ****
    cmXCodeObject* buildSettings =
      this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
-   std::string fileTypeString;
-   std::string productTypeString;
-   std::string productName;
    const char* globalConfig = 0;
    if(this->XcodeVersion > 20)
--- 1842,1845 ----
***************
*** 1882,1888 ****
      globalConfig = this->CurrentMakefile->GetDefinition("CMAKE_BUILD_TYPE");  
      }
!   this->CreateBuildSettings(cmtarget, 
!                             buildSettings, fileTypeString, 
!                             productTypeString, productName, globalConfig);
    target->AddAttribute("buildSettings", buildSettings);
    cmXCodeObject* dependencies = 
--- 1851,1855 ----
      globalConfig = this->CurrentMakefile->GetDefinition("CMAKE_BUILD_TYPE");  
      }
!   this->CreateBuildSettings(cmtarget, buildSettings, globalConfig);
    target->AddAttribute("buildSettings", buildSettings);
    cmXCodeObject* dependencies = 
***************
*** 1940,1949 ****
      cmXCodeObject* buildSettings =
        this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
!     std::string fileTypeString;
!     std::string productTypeString;
!     std::string productName;
!     this->CreateBuildSettings(cmtarget, 
!                               buildSettings, fileTypeString, 
!                               productTypeString, productName,
                                configVector[i].c_str());
      config->AddAttribute("name", this->CreateString(configVector[i].c_str()));
--- 1907,1911 ----
      cmXCodeObject* buildSettings =
        this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
!     this->CreateBuildSettings(cmtarget, buildSettings,
                                configVector[i].c_str());
      config->AddAttribute("name", this->CreateString(configVector[i].c_str()));
***************
*** 1961,1964 ****
--- 1923,1969 ----
  
  //----------------------------------------------------------------------------
+ const char* cmGlobalXCodeGenerator::GetTargetFileType(cmTarget& cmtarget)
+ {
+   switch(cmtarget.GetType())
+     {
+     case cmTarget::STATIC_LIBRARY:
+       return "archive.ar";
+     case cmTarget::MODULE_LIBRARY:
+       return ((this->XcodeVersion >= 22)?
+               "compiled.mach-o.executable" : "compiled.mach-o.dylib");
+     case cmTarget::SHARED_LIBRARY:
+       return (cmtarget.GetPropertyAsBool("FRAMEWORK")?
+               "wrapper.framework" : "compiled.mach-o.dylib");
+     case cmTarget::EXECUTABLE:
+       return "compiled.mach-o.executable";
+     default: break;
+     }
+   return 0;
+ }
+ 
+ //----------------------------------------------------------------------------
+ const char* cmGlobalXCodeGenerator::GetTargetProductType(cmTarget& cmtarget)
+ {
+   switch(cmtarget.GetType())
+     {
+     case cmTarget::STATIC_LIBRARY:
+       return "com.apple.product-type.library.static";
+     case cmTarget::MODULE_LIBRARY:
+       return ((this->XcodeVersion >= 22)? "com.apple.product-type.tool" :
+               "com.apple.product-type.library.dynamic");
+     case cmTarget::SHARED_LIBRARY:
+       return (cmtarget.GetPropertyAsBool("FRAMEWORK")?
+               "com.apple.product-type.framework" :
+               "com.apple.product-type.library.dynamic");
+     case cmTarget::EXECUTABLE:
+       return (cmtarget.GetPropertyAsBool("MACOSX_BUNDLE")?
+               "com.apple.product-type.application" :
+               "com.apple.product-type.tool");
+     default: break;
+     }
+   return 0;
+ }
+ 
+ //----------------------------------------------------------------------------
  cmXCodeObject*
  cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget,
***************
*** 1972,1978 ****
    cmXCodeObject* buildSettings =
      this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
-   std::string fileTypeString;
-   std::string productTypeString;
-   std::string productName;
    const char* globalConfig = 0;
    if(this->XcodeVersion > 20)
--- 1977,1980 ----
***************
*** 1984,1990 ****
      globalConfig = this->CurrentMakefile->GetDefinition("CMAKE_BUILD_TYPE");  
      }
!   this->CreateBuildSettings(cmtarget, 
!                             buildSettings, fileTypeString, 
!                             productTypeString, productName, globalConfig);
    target->AddAttribute("buildSettings", buildSettings);
    cmXCodeObject* dependencies = 
--- 1986,1990 ----
      globalConfig = this->CurrentMakefile->GetDefinition("CMAKE_BUILD_TYPE");  
      }
!   this->CreateBuildSettings(cmtarget, buildSettings, globalConfig);
    target->AddAttribute("buildSettings", buildSettings);
    cmXCodeObject* dependencies = 
***************
*** 1996,2002 ****
    cmXCodeObject* fileRef = 
      this->CreateObject(cmXCodeObject::PBXFileReference);
!   fileRef->AddAttribute("explicitFileType", 
!                         this->CreateString(fileTypeString.c_str()));
!   fileRef->AddAttribute("path", this->CreateString(productName.c_str()));
    fileRef->AddAttribute("refType", this->CreateString("0"));
    fileRef->AddAttribute("sourceTree",
--- 1996,2005 ----
    cmXCodeObject* fileRef = 
      this->CreateObject(cmXCodeObject::PBXFileReference);
!   if(const char* fileType = this->GetTargetFileType(cmtarget))
!     {
!     fileRef->AddAttribute("explicitFileType", this->CreateString(fileType));
!     }
!   std::string fullName = cmtarget.GetFullName(globalConfig);
!   fileRef->AddAttribute("path", this->CreateString(fullName.c_str()));
    fileRef->AddAttribute("refType", this->CreateString("0"));
    fileRef->AddAttribute("sourceTree",
***************
*** 2005,2010 ****
    target->AddAttribute("productReference", 
                         this->CreateObjectReference(fileRef));
!   target->AddAttribute("productType", 
!                        this->CreateString(productTypeString.c_str()));
    target->SetTarget(&cmtarget);
    return target;
--- 2008,2015 ----
    target->AddAttribute("productReference", 
                         this->CreateObjectReference(fileRef));
!   if(const char* productType = this->GetTargetProductType(cmtarget))
!     {
!     target->AddAttribute("productType", this->CreateString(productType));
!     }
    target->SetTarget(&cmtarget);
    return target;

Index: cmGlobalXCodeGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalXCodeGenerator.h,v
retrieving revision 1.57
retrieving revision 1.58
diff -C 2 -d -r1.57 -r1.58
*** cmGlobalXCodeGenerator.h	29 Jun 2009 17:02:05 -0000	1.57
--- cmGlobalXCodeGenerator.h	2 Jul 2009 18:13:46 -0000	1.58
***************
*** 129,132 ****
--- 129,134 ----
    cmXCodeObject* CreateXCodeTarget(cmTarget& target,
                                     cmXCodeObject* buildPhases);
+   const char* GetTargetFileType(cmTarget& cmtarget);
+   const char* GetTargetProductType(cmTarget& cmtarget);
    void AddConfigurations(cmXCodeObject* target,
                           cmTarget& cmtarget);
***************
*** 139,145 ****
    void CreateBuildSettings(cmTarget& target,
                             cmXCodeObject* buildSettings,
-                            std::string& fileType,
-                            std::string& productType,
-                            std::string& projectName,
                             const char* buildType);
    std::string ExtractFlag(const char* flag, std::string& flags);
--- 141,144 ----



More information about the Cmake-commits mailing list