Remove cmGlobalXCode21Generator subclass

This subclass of cmGlobalXCodeGenerator only provided two virtual method
overrides, and it made construction of the Xcode generator instance
complicated.  This commit removes it and replaces the virtual methods
with tests of the Xcode version.  The change removes duplicate code.
This commit is contained in:
Brad King 2009-09-19 12:00:09 -04:00
parent 180c60a86f
commit d4cfb77ffe
5 changed files with 30 additions and 111 deletions

View File

@ -251,8 +251,6 @@ IF(APPLE)
cmXCode21Object.cxx
cmGlobalXCodeGenerator.cxx
cmGlobalXCodeGenerator.h
cmGlobalXCode21Generator.cxx
cmGlobalXCode21Generator.h
cmLocalXCodeGenerator.cxx
cmLocalXCodeGenerator.h)
ENDIF(APPLE)

View File

@ -1,52 +0,0 @@
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "cmGlobalXCode21Generator.h"
#include "cmXCode21Object.h"
//----------------------------------------------------------------------------
cmGlobalXCode21Generator::cmGlobalXCode21Generator()
{
this->XcodeVersion = 21;
}
//----------------------------------------------------------------------------
void
cmGlobalXCode21Generator::WriteXCodePBXProj(std::ostream& fout,
cmLocalGenerator* ,
std::vector<cmLocalGenerator*>& )
{
fout << "// !$*UTF8*$!\n";
fout << "{\n";
cmXCode21Object::Indent(1, fout);
fout << "archiveVersion = 1;\n";
cmXCode21Object::Indent(1, fout);
fout << "classes = {\n";
cmXCode21Object::Indent(1, fout);
fout << "};\n";
cmXCode21Object::Indent(1, fout);
if (this->XcodeVersion >= 31)
fout << "objectVersion = 45;\n";
else if (this->XcodeVersion >= 30)
fout << "objectVersion = 44;\n";
else
fout << "objectVersion = 42;\n";
cmXCode21Object::PrintList(this->XCodeObjects, fout);
cmXCode21Object::Indent(1, fout);
fout << "rootObject = " << this->RootObject->GetId()
<< " /* Project object */;\n";
fout << "}\n";
}

View File

@ -1,41 +0,0 @@
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef cmGlobalXCode21Generator_h
#define cmGlobalXCode21Generator_h
#include "cmGlobalXCodeGenerator.h"
/** \class cmGlobalXCode21Generator
* \brief Write Mac XCode projects
*
* cmGlobalXCode21Generator manages UNIX build process for a tree
*/
class cmGlobalXCode21Generator : public cmGlobalXCodeGenerator
{
public:
cmGlobalXCode21Generator();
static cmGlobalGenerator* New() { return new cmGlobalXCode21Generator; }
virtual void WriteXCodePBXProj(std::ostream& fout,
cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators);
///! What is the configurations directory variable called?
virtual const char* GetCMakeCFGInitDirectory() {
return "$(CONFIGURATION)"; }
};
#endif

View File

@ -15,7 +15,6 @@ PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "cmGlobalXCodeGenerator.h"
#include "cmGlobalXCode21Generator.h"
#include "cmLocalXCodeGenerator.h"
#include "cmMakefile.h"
#include "cmXCodeObject.h"
@ -25,6 +24,8 @@ PURPOSE. See the above copyright notices for more information.
#include "cmComputeLinkInformation.h"
#include "cmSourceFile.h"
#include <cmsys/auto_ptr.hxx>
//----------------------------------------------------------------------------
#if defined(CMAKE_BUILD_WITH_CMAKE)
#include "cmXMLParser.h"
@ -133,19 +134,14 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::New()
cmXcodeVersionParser parser;
parser.ParseFile
("/Developer/Applications/Xcode.app/Contents/version.plist");
if(parser.Version == 15)
{
return new cmGlobalXCodeGenerator;
}
else if (parser.Version == 20)
cmsys::auto_ptr<cmGlobalXCodeGenerator> gg(new cmGlobalXCodeGenerator);
if (parser.Version == 20)
{
cmSystemTools::Message("Xcode 2.0 not really supported by cmake, "
"using Xcode 15 generator\n");
return new cmGlobalXCodeGenerator;
}
cmGlobalXCodeGenerator* ret = new cmGlobalXCode21Generator;
ret->SetVersion(parser.Version);
return ret;
gg->SetVersion(parser.Version);
return gg.release();
#else
std::cerr << "CMake should be built with cmake to use XCode, "
"default to Xcode 1.5\n";
@ -2998,13 +2994,32 @@ cmGlobalXCodeGenerator::WriteXCodePBXProj(std::ostream& fout,
cmXCodeObject::Indent(1, fout);
fout << "};\n";
cmXCodeObject::Indent(1, fout);
fout << "objectVersion = 39;\n";
cmXCodeObject::PrintList(this->XCodeObjects, fout);
if(this->XcodeVersion >= 21)
{
if (this->XcodeVersion >= 31)
fout << "objectVersion = 45;\n";
else if (this->XcodeVersion >= 30)
fout << "objectVersion = 44;\n";
else
fout << "objectVersion = 42;\n";
cmXCode21Object::PrintList(this->XCodeObjects, fout);
}
else
{
fout << "objectVersion = 39;\n";
cmXCodeObject::PrintList(this->XCodeObjects, fout);
}
cmXCodeObject::Indent(1, fout);
fout << "rootObject = " << this->RootObject->GetId() << ";\n";
fout << "}\n";
}
//----------------------------------------------------------------------------
const char* cmGlobalXCodeGenerator::GetCMakeCFGInitDirectory()
{
return this->XcodeVersion >= 21? "$(CONFIGURATION)" : ".";
}
//----------------------------------------------------------------------------
void cmGlobalXCodeGenerator::GetDocumentation(cmDocumentationEntry& entry)
const

View File

@ -80,7 +80,7 @@ public:
std::string& dir);
///! What is the configurations directory variable called?
virtual const char* GetCMakeCFGInitDirectory() { return "."; }
virtual const char* GetCMakeCFGInitDirectory();
void GetTargetObjectFileDirectories(cmTarget* target,
std::vector<std::string>&
@ -149,9 +149,8 @@ private:
std::vector<cmLocalGenerator*>& generators);
void OutputXCodeProject(cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators);
virtual void WriteXCodePBXProj(std::ostream& fout,
cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators);
void WriteXCodePBXProj(std::ostream& fout, cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators);
cmXCodeObject* CreateXCodeFileReference(cmSourceFile* sf,
cmTarget& cmtarget);
cmXCodeObject* CreateXCodeSourceFile(cmLocalGenerator* gen,