diff options
Diffstat (limited to 'Source/cmGlobalXCodeGenerator.cxx')
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 130 |
1 files changed, 89 insertions, 41 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 6628cfc..b4bc084 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -24,7 +24,7 @@ #include "cmXCodeObject.h" #include "cmake.h" -#include <cmsys/auto_ptr.hxx> +#include <cm_auto_ptr.hxx> #if defined(CMAKE_BUILD_WITH_CMAKE) #include "cmXMLParser.h" @@ -108,20 +108,21 @@ public: class cmGlobalXCodeGenerator::Factory : public cmGlobalGeneratorFactory { public: - virtual cmGlobalGenerator* CreateGlobalGenerator(const std::string& name, - cmake* cm) const; + cmGlobalGenerator* CreateGlobalGenerator(const std::string& name, + cmake* cm) const CM_OVERRIDE; - virtual void GetDocumentation(cmDocumentationEntry& entry) const + void GetDocumentation(cmDocumentationEntry& entry) const CM_OVERRIDE { cmGlobalXCodeGenerator::GetDocumentation(entry); } - virtual void GetGenerators(std::vector<std::string>& names) const + void GetGenerators(std::vector<std::string>& names) const CM_OVERRIDE { names.push_back(cmGlobalXCodeGenerator::GetActualName()); } - virtual bool SupportsToolset() const { return true; } + bool SupportsToolset() const CM_OVERRIDE { return true; } + bool SupportsPlatform() const CM_OVERRIDE { return false; } }; cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(cmake* cm, @@ -175,7 +176,7 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::Factory::CreateGlobalGenerator( parser.ParseFile( "/Developer/Applications/Xcode.app/Contents/version.plist"); } - cmsys::auto_ptr<cmGlobalXCodeGenerator> gg( + CM_AUTO_PTR<cmGlobalXCodeGenerator> gg( new cmGlobalXCodeGenerator(cm, parser.Version)); if (gg->XcodeVersion == 20) { cmSystemTools::Message("Xcode 2.0 not really supported by cmake, " @@ -659,7 +660,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile( // Add flags from target and source file properties. std::string flags; const char* srcfmt = sf->GetProperty("Fortran_FORMAT"); - switch (this->CurrentLocalGenerator->GetFortranFormat(srcfmt)) { + switch (cmOutputConverter::GetFortranFormat(srcfmt)) { case cmOutputConverter::FortranFormatFixed: flags = "-fixed " + flags; break; @@ -689,7 +690,8 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile( cmXCodeObject* fileRef = buildFile->GetObject("fileRef")->GetObject(); cmXCodeObject* settings = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); - settings->AddAttribute("COMPILER_FLAGS", this->CreateString(flags)); + settings->AddAttributeIfNotEmpty("COMPILER_FLAGS", + this->CreateString(flags)); // Is this a resource file in this target? Add it to the resources group... // @@ -698,23 +700,37 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile( gtgt->GetTargetSourceFileFlags(sf); bool isResource = tsFlags.Type == cmGeneratorTarget::SourceFileTypeResource; + cmXCodeObject* attrs = this->CreateObject(cmXCodeObject::OBJECT_LIST); + // Is this a "private" or "public" framework header file? // Set the ATTRIBUTES attribute appropriately... // if (gtgt->IsFrameworkOnApple()) { if (tsFlags.Type == cmGeneratorTarget::SourceFileTypePrivateHeader) { - cmXCodeObject* attrs = this->CreateObject(cmXCodeObject::OBJECT_LIST); attrs->AddObject(this->CreateString("Private")); - settings->AddAttribute("ATTRIBUTES", attrs); isResource = true; } else if (tsFlags.Type == cmGeneratorTarget::SourceFileTypePublicHeader) { - cmXCodeObject* attrs = this->CreateObject(cmXCodeObject::OBJECT_LIST); attrs->AddObject(this->CreateString("Public")); - settings->AddAttribute("ATTRIBUTES", attrs); isResource = true; } } + // Add user-specified file attributes. + const char* extraFileAttributes = sf->GetProperty("XCODE_FILE_ATTRIBUTES"); + if (extraFileAttributes) { + // Expand the list of attributes. + std::vector<std::string> attributes; + cmSystemTools::ExpandListArgument(extraFileAttributes, attributes); + + // Store the attributes. + for (std::vector<std::string>::const_iterator ai = attributes.begin(); + ai != attributes.end(); ++ai) { + attrs->AddObject(this->CreateString(*ai)); + } + } + + settings->AddAttributeIfNotEmpty("ATTRIBUTES", attrs); + // Add the fileRef to the top level Resources group/folder if it is not // already there. // @@ -723,7 +739,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile( this->ResourcesGroupChildren->AddObject(fileRef); } - buildFile->AddAttribute("settings", settings); + buildFile->AddAttributeIfNotEmpty("settings", settings); return buildFile; } @@ -772,6 +788,8 @@ std::string GetSourcecodeValueFromFileExtension(const std::string& _ext, sourcecode += ".asm"; } else if (ext == "metal") { sourcecode += ".metal"; + } else if (ext == "mig") { + sourcecode += ".mig"; } // else // { @@ -1544,7 +1562,7 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile( std::string echo_cmd = "echo "; echo_cmd += (this->CurrentLocalGenerator->EscapeForShell( comment, ccg.GetCC().GetEscapeAllowMakeVars())); - makefileStream << "\t" << echo_cmd.c_str() << "\n"; + makefileStream << "\t" << echo_cmd << "\n"; } // Add each command line to the set of commands. @@ -1562,7 +1580,7 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile( } cmd += cmd2; ccg.AppendArguments(c, cmd); - makefileStream << "\t" << cmd.c_str() << "\n"; + makefileStream << "\t" << cmd << "\n"; } } } @@ -1784,6 +1802,11 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, extraLinkOptions += " "; extraLinkOptions += createFlags; } + const char* ext = gtgt->GetProperty("BUNDLE_EXTENSION"); + if (ext) { + buildSettings->AddAttribute("WRAPPER_EXTENSION", + this->CreateString(ext)); + } std::string plist = this->ComputeInfoPListLocation(gtgt); // Xcode will create the final version of Info.plist at build time, // so let it replace the cfbundle name. This avoids creating @@ -1821,6 +1844,11 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, std::string fw_version = gtgt->GetFrameworkVersion(); buildSettings->AddAttribute("FRAMEWORK_VERSION", this->CreateString(fw_version)); + const char* ext = gtgt->GetProperty("BUNDLE_EXTENSION"); + if (ext) { + buildSettings->AddAttribute("WRAPPER_EXTENSION", + this->CreateString(ext)); + } std::string plist = this->ComputeInfoPListLocation(gtgt); // Xcode will create the final version of Info.plist at build time, @@ -1855,6 +1883,11 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, // Handle bundles and normal executables separately. if (gtgt->GetPropertyAsBool("MACOSX_BUNDLE")) { + const char* ext = gtgt->GetProperty("BUNDLE_EXTENSION"); + if (ext) { + buildSettings->AddAttribute("WRAPPER_EXTENSION", + this->CreateString(ext)); + } std::string plist = this->ComputeInfoPListLocation(gtgt); // Xcode will create the final version of Info.plist at build time, // so let it replace the executable name. This avoids creating @@ -1874,23 +1907,40 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, BuildObjectListOrString dirs(this, this->XcodeVersion >= 30); BuildObjectListOrString fdirs(this, this->XcodeVersion >= 30); - std::vector<std::string> includes; - this->CurrentLocalGenerator->GetIncludeDirectories(includes, gtgt, "C", - configName); std::set<std::string> emitted; emitted.insert("/System/Library/Frameworks"); - for (std::vector<std::string>::iterator i = includes.begin(); - i != includes.end(); ++i) { - if (this->NameResolvesToFramework(i->c_str())) { - std::string frameworkDir = *i; - frameworkDir += "/../"; - frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir); - if (emitted.insert(frameworkDir).second) { - fdirs.Add(this->XCodeEscapePath(frameworkDir)); + + if (this->XcodeVersion < 60) { + std::vector<std::string> includes; + this->CurrentLocalGenerator->GetIncludeDirectories(includes, gtgt, "C", + configName); + for (std::vector<std::string>::iterator i = includes.begin(); + i != includes.end(); ++i) { + if (this->NameResolvesToFramework(i->c_str())) { + std::string frameworkDir = *i; + frameworkDir += "/../"; + frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir); + if (emitted.insert(frameworkDir).second) { + fdirs.Add(this->XCodeEscapePath(frameworkDir)); + } + } else { + std::string incpath = this->XCodeEscapePath(*i); + dirs.Add(incpath); + } + } + } else { + for (std::set<std::string>::iterator li = languages.begin(); + li != languages.end(); ++li) { + std::vector<std::string> includes; + this->CurrentLocalGenerator->GetIncludeDirectories(includes, gtgt, *li, + configName); + std::string includeFlags = this->CurrentLocalGenerator->GetIncludeFlags( + includes, gtgt, *li, true, false, configName); + + std::string& flags = cflags[*li]; + if (!includeFlags.empty()) { + flags += " " + includeFlags; } - } else { - std::string incpath = this->XCodeEscapePath(*i); - dirs.Add(incpath); } } // Add framework search paths needed for linking. @@ -1975,13 +2025,16 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, this->CreateString(flags)); } else if (*li == "C") { buildSettings->AddAttribute("OTHER_CFLAGS", this->CreateString(flags)); + } else if (*li == "Swift") { + buildSettings->AddAttribute("OTHER_SWIFT_FLAGS", + this->CreateString(flags)); } } // Add Fortran source format attribute if property is set. const char* format = 0; const char* tgtfmt = gtgt->GetProperty("Fortran_FORMAT"); - switch (this->CurrentLocalGenerator->GetFortranFormat(tgtfmt)) { + switch (cmOutputConverter::GetFortranFormat(tgtfmt)) { case cmOutputConverter::FortranFormatFixed: format = "fixed"; break; @@ -2582,13 +2635,10 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target) } bool cmGlobalXCodeGenerator::CreateGroups( - cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators) + std::vector<cmLocalGenerator*>& generators) { for (std::vector<cmLocalGenerator*>::iterator i = generators.begin(); i != generators.end(); ++i) { - if (this->IsExcluded(root, *i)) { - continue; - } cmMakefile* mf = (*i)->GetMakefile(); std::vector<cmSourceGroup> sourceGroups = mf->GetSourceGroups(); std::vector<cmGeneratorTarget*> tgts = (*i)->GetGeneratorTargets(); @@ -2820,7 +2870,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( this->MainGroupChildren->AddObject(resourcesGroup); // now create the cmake groups - if (!this->CreateGroups(root, generators)) { + if (!this->CreateGroups(generators)) { return false; } @@ -2988,10 +3038,8 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( std::vector<cmXCodeObject*> targets; for (std::vector<cmLocalGenerator*>::iterator i = generators.begin(); i != generators.end(); ++i) { - if (!this->IsExcluded(root, *i)) { - if (!this->CreateXCodeTargets(*i, targets)) { - return false; - } + if (!this->CreateXCodeTargets(*i, targets)) { + return false; } } // loop over all targets and add link and depend info @@ -3437,7 +3485,7 @@ std::string cmGlobalXCodeGenerator::ComputeInfoPListLocation( // Return true if the generated build tree may contain multiple builds. // i.e. "Can I build Debug and Release in the same tree?" -bool cmGlobalXCodeGenerator::IsMultiConfig() +bool cmGlobalXCodeGenerator::IsMultiConfig() const { // Old Xcode 1.5 is single config: if (this->XcodeVersion == 15) { |