ENH: if Xcode21 is installed then create 21 compatible project files

This commit is contained in:
Bill Hoffman 2005-07-19 16:40:44 -04:00
parent 0ba0cb8a1a
commit a13713818c
5 changed files with 113 additions and 9 deletions

View File

@ -148,6 +148,9 @@ IF(APPLE)
SET(SRCS ${SRCS} SET(SRCS ${SRCS}
cmXCodeObject.cxx cmXCodeObject.cxx
cmGlobalXCodeGenerator.cxx cmGlobalXCodeGenerator.cxx
cmGlobalXCodeGenerator.h
cmGlobalXCode21Generator.cxx
cmGlobalXCode21Generator.h
cmLocalXCodeGenerator.cxx cmLocalXCodeGenerator.cxx
cmLocalXCodeGenerator.h) cmLocalXCodeGenerator.h)
ENDIF(APPLE) ENDIF(APPLE)

View File

@ -304,7 +304,8 @@ bool cmFileCommand::HandleInstallCommand(
{ {
extra_dir = build_type; extra_dir = build_type;
std::string btype = cmSystemTools::LowerCase(build_type); std::string btype = cmSystemTools::LowerCase(build_type);
if ( strncmp(btype.c_str(), "debug", strlen("debug")) == 0 ) if ( m_Makefile->GetDefinition("WIN32")
&& strncmp(btype.c_str(), "debug", strlen("debug")) == 0 )
{ {
debug = 1; debug = 1;
} }

View File

@ -14,6 +14,8 @@
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
#include "cmGlobalXCode21Generator.h"
cmGlobalXCode21Generator::cmGlobalXCode21Generator() cmGlobalXCode21Generator::cmGlobalXCode21Generator()
{ {
this->m_XcodeVersion = 21; this->m_XcodeVersion = 21;

View File

@ -15,6 +15,7 @@
=========================================================================*/ =========================================================================*/
#include "cmGlobalXCodeGenerator.h" #include "cmGlobalXCodeGenerator.h"
#include "cmGlobalXCode21Generator.h"
#include "cmLocalXCodeGenerator.h" #include "cmLocalXCodeGenerator.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmXCodeObject.h" #include "cmXCodeObject.h"
@ -22,6 +23,41 @@
#include "cmGeneratedFileStream.h" #include "cmGeneratedFileStream.h"
#include "cmSourceFile.h" #include "cmSourceFile.h"
#include "cmOrderLinkDirectories.h" #include "cmOrderLinkDirectories.h"
#include "cmXMLParser.h"
// parse the xml file storing the installed version of Xcode on
// the machine
class cmXcodeVersionParser : public cmXMLParser
{
public:
void StartElement(const char* name, const char** atts)
{
m_Data = "";
}
void EndElement(const char* name)
{
if(strcmp(name, "key") == 0)
{
m_Key = m_Data;
}
else if(strcmp(name, "string") == 0)
{
if(m_Key == "CFBundleShortVersionString")
{
m_Version = (int)(10.0 * atof(m_Data.c_str()));
}
}
}
void CharacterDataHandler(const char* data, int length)
{
m_Data.append(data, length);
}
int m_Version;
std::string m_Key;
std::string m_Data;
};
//TODO //TODO
// add OSX application stuff // add OSX application stuff
@ -35,6 +71,26 @@ cmGlobalXCodeGenerator::cmGlobalXCodeGenerator()
m_SourcesGroupChildren = 0; m_SourcesGroupChildren = 0;
m_CurrentMakefile = 0; m_CurrentMakefile = 0;
m_CurrentLocalGenerator = 0; m_CurrentLocalGenerator = 0;
m_XcodeVersion = 15;
}
//----------------------------------------------------------------------------
cmGlobalGenerator* cmGlobalXCodeGenerator::New()
{
cmXcodeVersionParser parser;
parser.ParseFile("/Developer/Applications/Xcode.app/Contents/version.plist");
if(parser.m_Version == 15)
{
return new cmGlobalXCodeGenerator;
}
else if (parser.m_Version == 20)
{
cmSystemTools::Message("Xcode 2.0 not really supported by cmake, "
"using Xcode 15 generator\n");
return new cmGlobalXCodeGenerator;
}
return new cmGlobalXCode21Generator;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -43,7 +99,14 @@ void cmGlobalXCodeGenerator::EnableLanguage(std::vector<std::string>const&
cmMakefile * mf) cmMakefile * mf)
{ {
mf->AddDefinition("XCODE","1"); mf->AddDefinition("XCODE","1");
mf->AddDefinition("CMAKE_CFG_INTDIR","."); if(m_XcodeVersion == 15)
{
mf->AddDefinition("CMAKE_CFG_INTDIR",".");
}
else
{
mf->AddDefinition("CMAKE_CFG_INTDIR","$(CONFIGURATION)");
}
mf->AddDefinition("CMAKE_GENERATOR_CC", "gcc"); mf->AddDefinition("CMAKE_GENERATOR_CC", "gcc");
mf->AddDefinition("CMAKE_GENERATOR_CXX", "g++"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "g++");
mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1"); mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1");
@ -97,7 +160,14 @@ std::string cmGlobalXCodeGenerator::GenerateBuildCommand(const char* makeProgram
{ {
makeCommand += "ALL_BUILD"; makeCommand += "ALL_BUILD";
} }
makeCommand += " -buildstyle Development "; if(m_XcodeVersion == 15)
{
makeCommand += " -buildstyle Development ";
}
else
{
makeCommand += " -configuration Debug";
}
return makeCommand; return makeCommand;
} }
@ -187,9 +257,20 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
cmTarget* allbuild = mf->FindTarget("ALL_BUILD"); cmTarget* allbuild = mf->FindTarget("ALL_BUILD");
// ADD install // ADD install
std::string cmake_command = mf->GetRequiredDefinition("CMAKE_COMMAND"); std::string cmake_command = mf->GetRequiredDefinition("CMAKE_COMMAND");
mf->AddUtilityCommand("install", false, no_output, no_depends, if(m_XcodeVersion == 15)
cmake_command.c_str(), {
"-P", "cmake_install.cmake"); mf->AddUtilityCommand("install", false, no_output, no_depends,
cmake_command.c_str(),
"-P", "cmake_install.cmake");
}
else
{
mf->AddUtilityCommand("install", false, no_output, no_depends,
cmake_command.c_str(),
"-DBUILD_TYPE=$(CONFIGURATION)",
"-P", "cmake_install.cmake");
}
const char* noall = const char* noall =
mf->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY"); mf->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY");
if(!noall || cmSystemTools::IsOff(noall)) if(!noall || cmSystemTools::IsOff(noall))
@ -753,7 +834,6 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase,
// if the depend is a target then make // if the depend is a target then make
// the target with the source that is a custom command // the target with the source that is a custom command
// depend on the that target via a AddUtility call // depend on the that target via a AddUtility call
std::cerr << "AddUtility " << target.GetName() << " " << *d << "\n";
target.AddUtility(d->c_str()); target.AddUtility(d->c_str());
} }
} }
@ -828,6 +908,10 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
m_CurrentLocalGenerator->AppendFlags(flags, m_CurrentLocalGenerator->AppendFlags(flags,
m_CurrentMakefile->GetDefineFlags()); m_CurrentMakefile->GetDefineFlags());
cmSystemTools::ReplaceString(flags, "\"", "\\\""); cmSystemTools::ReplaceString(flags, "\"", "\\\"");
if(m_XcodeVersion == 21)
{
flags += " -DCMAKE_INTDIR=\\\\\\\"$(CONFIGURATION)\\\\\\\" ";
}
productName = target.GetName(); productName = target.GetName();
switch(target.GetType()) switch(target.GetType())
@ -1183,6 +1267,11 @@ std::string cmGlobalXCodeGenerator::GetTargetFullPath(cmTarget* target)
cmXCodeObject* xtarget = this->FindXCodeTarget(target); cmXCodeObject* xtarget = this->FindXCodeTarget(target);
cmXCodeObject* bset = xtarget->GetObject("buildSettings"); cmXCodeObject* bset = xtarget->GetObject("buildSettings");
cmXCodeObject* spath = bset->GetObject("SYMROOT"); cmXCodeObject* spath = bset->GetObject("SYMROOT");
if(m_XcodeVersion == 21)
{
libPath += "$(CONFIGURATION)/";
}
libPath = spath->GetString(); libPath = spath->GetString();
libPath = libPath.substr(1, libPath.size()-2); libPath = libPath.substr(1, libPath.size()-2);
if(target->GetType() == cmTarget::STATIC_LIBRARY) if(target->GetType() == cmTarget::STATIC_LIBRARY)
@ -1250,6 +1339,13 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
{ {
if(libDir->size() && *libDir != "/usr/lib") if(libDir->size() && *libDir != "/usr/lib")
{ {
if(m_XcodeVersion == 21)
{
// now add the same one but append $(CONFIGURATION) to it:
linkDirs += " ";
linkDirs += this->XCodeEscapePath(libDir->c_str());
linkDirs += "/$(CONFIGURATION)";
}
linkDirs += " "; linkDirs += " ";
linkDirs += this->XCodeEscapePath(libDir->c_str()); linkDirs += this->XCodeEscapePath(libDir->c_str());
} }

View File

@ -34,12 +34,12 @@ class cmGlobalXCodeGenerator : public cmGlobalGenerator
{ {
public: public:
cmGlobalXCodeGenerator(); cmGlobalXCodeGenerator();
static cmGlobalGenerator* New() { return new cmGlobalXCodeGenerator; } static cmGlobalGenerator* New();
///! Get the name for the generator. ///! Get the name for the generator.
virtual const char* GetName() const { virtual const char* GetName() const {
return cmGlobalXCodeGenerator::GetActualName();} return cmGlobalXCodeGenerator::GetActualName();}
static const char* GetActualName() {return "Xcode15";} static const char* GetActualName() {return "Xcode";}
/** Get the documentation entry for this generator. */ /** Get the documentation entry for this generator. */
virtual void GetDocumentation(cmDocumentationEntry& entry) const; virtual void GetDocumentation(cmDocumentationEntry& entry) const;
@ -133,6 +133,8 @@ private:
cmTarget& cmtarget, cmTarget& cmtarget,
const std::vector<cmCustomCommand>&); const std::vector<cmCustomCommand>&);
void CreateReRunCMakeFile(cmLocalGenerator* root); void CreateReRunCMakeFile(cmLocalGenerator* root);
protected:
int m_XcodeVersion;
private: private:
std::vector<cmXCodeObject*> m_XCodeObjects; std::vector<cmXCodeObject*> m_XCodeObjects;
cmXCodeObject* m_RootObject; cmXCodeObject* m_RootObject;