ENH: fixes for Xcode 2.2

This commit is contained in:
Bill Hoffman 2005-11-18 14:12:09 -05:00
parent c0ee3a13a5
commit 47622dde01
2 changed files with 154 additions and 131 deletions

View File

@ -1,17 +1,17 @@
/*========================================================================= /*=========================================================================
Program: CMake - Cross-Platform Makefile Generator Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$ Module: $RCSfile$
Language: C++ Language: C++
Date: $Date$ Date: $Date$
Version: $Revision$ Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
#include "cmGlobalXCodeGenerator.h" #include "cmGlobalXCodeGenerator.h"
@ -93,8 +93,9 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::New()
"using Xcode 15 generator\n"); "using Xcode 15 generator\n");
return new cmGlobalXCodeGenerator; return new cmGlobalXCodeGenerator;
} }
cmGlobalXCodeGenerator* ret = new cmGlobalXCode21Generator;
return new cmGlobalXCode21Generator; ret->SetVersion(parser.m_Version);
return ret;
#else #else
std::cerr std::cerr
<< "CMake should be built with cmake to use XCode, default to Xcode 1.5\n"; << "CMake should be built with cmake to use XCode, default to Xcode 1.5\n";
@ -517,9 +518,6 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg,
this->CreateString(sourcecode.c_str())); this->CreateString(sourcecode.c_str()));
std::string path = std::string path =
this->ConvertToRelativeForXCode(sf->GetFullPath().c_str()); this->ConvertToRelativeForXCode(sf->GetFullPath().c_str());
// std::string file =
// cmSystemTools::RelativePath(m_CurrentMakefile->GetHomeDirectory(),
// sf->GetFullPath().c_str());
std::string dir; std::string dir;
std::string file; std::string file;
cmSystemTools::SplitProgramPath(sf->GetFullPath().c_str(), cmSystemTools::SplitProgramPath(sf->GetFullPath().c_str(),
@ -998,7 +996,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
cmSystemTools::ReplaceString(defFlags, "\"", "\\\""); cmSystemTools::ReplaceString(defFlags, "\"", "\\\"");
cmSystemTools::ReplaceString(flags, "\"", "\\\""); cmSystemTools::ReplaceString(flags, "\"", "\\\"");
cmSystemTools::ReplaceString(cflags, "\"", "\\\""); cmSystemTools::ReplaceString(cflags, "\"", "\\\"");
if(m_XcodeVersion == 21) if(m_XcodeVersion > 15)
{ {
defFlags += " -DCMAKE_INTDIR=\\\\\\\"$(CONFIGURATION)\\\\\\\" "; defFlags += " -DCMAKE_INTDIR=\\\\\\\"$(CONFIGURATION)\\\\\\\" ";
} }
@ -1044,10 +1042,31 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
std::string t = "lib"; std::string t = "lib";
t += productName; t += productName;
productName = t; productName = t;
if(m_XcodeVersion >= 22)
{
buildSettings->AddAttribute("MACH_O_TYPE",
this->CreateString("mh_bundle"));
buildSettings->AddAttribute("GCC_DYNAMIC_NO_PIC",
this->CreateString("NO"));
buildSettings->AddAttribute("GCC_SYMBOLS_PRIVATE_EXTERN",
this->CreateString("NO"));
buildSettings->AddAttribute("GCC_INLINES_ARE_PRIVATE_EXTERN",
this->CreateString("NO"));
std::string outflag = "-o \\\"$(CONFIGURATION_BUILD_DIR)/";
outflag += productName;
outflag += "\\\"";
buildSettings->AddAttribute("OTHER_LDFLAGS",
this->CreateString(outflag.c_str()));
productType = "com.apple.product-type.tool";
fileType = "compiled.mach-o.executable";
}
else
{
buildSettings->AddAttribute("OTHER_LDFLAGS", buildSettings->AddAttribute("OTHER_LDFLAGS",
this->CreateString("-bundle")); this->CreateString("-bundle"));
productType = "com.apple.product-type.library.dynamic"; productType = "com.apple.product-type.library.dynamic";
fileType = "compiled.mach-o.dylib"; fileType = "compiled.mach-o.dylib";
}
break; break;
} }
case cmTarget::SHARED_LIBRARY: case cmTarget::SHARED_LIBRARY:
@ -1199,8 +1218,11 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
buildSettings->AddAttribute("OTHER_CFLAGS", buildSettings->AddAttribute("OTHER_CFLAGS",
this->CreateString(flags.c_str())); this->CreateString(flags.c_str()));
} }
if(!buildSettings->GetObject("OTHER_LDFLAGS"))
{
buildSettings->AddAttribute("OTHER_LDFLAGS", buildSettings->AddAttribute("OTHER_LDFLAGS",
this->CreateString("")); this->CreateString(""));
}
buildSettings->AddAttribute("OTHER_REZFLAGS", buildSettings->AddAttribute("OTHER_REZFLAGS",
this->CreateString("")); this->CreateString(""));
buildSettings->AddAttribute("SECTORDER_FLAGS", buildSettings->AddAttribute("SECTORDER_FLAGS",
@ -1523,7 +1545,7 @@ 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) if(m_XcodeVersion > 15)
{ {
libPath += "$(CONFIGURATION)/"; libPath += "$(CONFIGURATION)/";
} }
@ -1601,7 +1623,7 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
{ {
if(libDir->size() && *libDir != "/usr/lib") if(libDir->size() && *libDir != "/usr/lib")
{ {
if(m_XcodeVersion == 21) if(m_XcodeVersion > 15)
{ {
// now add the same one but append $(CONFIGURATION) to it: // now add the same one but append $(CONFIGURATION) to it:
linkDirs += " "; linkDirs += " ";

View File

@ -36,6 +36,7 @@ public:
cmGlobalXCodeGenerator(); cmGlobalXCodeGenerator();
static cmGlobalGenerator* New(); static cmGlobalGenerator* New();
void SetVersion(int v) { m_XcodeVersion = v;}
///! 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();}