diff options
Diffstat (limited to 'Source/cmGlobalXCodeGenerator.cxx')
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 72 |
1 files changed, 39 insertions, 33 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index bc05aea..ea1b1a0 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -787,14 +787,16 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg, // Is this a resource file in this target? Add it to the resources group... // + + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); cmGeneratorTarget::SourceFileFlags tsFlags = - this->GetGeneratorTarget(&cmtarget)->GetTargetSourceFileFlags(sf); + gtgt->GetTargetSourceFileFlags(sf); bool isResource = tsFlags.Type == cmGeneratorTarget::SourceFileTypeResource; // Is this a "private" or "public" framework header file? // Set the ATTRIBUTES attribute appropriately... // - if(cmtarget.IsFrameworkOnApple()) + if(gtgt->IsFrameworkOnApple()) { if(tsFlags.Type == cmGeneratorTarget::SourceFileTypePrivateHeader) { @@ -1193,9 +1195,9 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, } // some build phases only apply to bundles and/or frameworks - bool isFrameworkTarget = cmtarget.IsFrameworkOnApple(); + bool isFrameworkTarget = gtgt->IsFrameworkOnApple(); bool isBundleTarget = cmtarget.GetPropertyAsBool("MACOSX_BUNDLE"); - bool isCFBundleTarget = cmtarget.IsCFBundleOnApple(); + bool isCFBundleTarget = gtgt->IsCFBundleOnApple(); cmXCodeObject* buildFiles = 0; @@ -1289,7 +1291,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, copyFilesBuildPhase->AddAttribute("dstSubfolderSpec", this->CreateString("6")); std::ostringstream ostr; - if (cmtarget.IsFrameworkOnApple()) + if (gtgt->IsFrameworkOnApple()) { // dstPath in frameworks is relative to Versions/<version> ostr << mit->first; @@ -1467,8 +1469,10 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, std::vector<cmCustomCommand> postbuild = cmtarget.GetPostBuildCommands(); + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); + if(cmtarget.GetType() == cmState::SHARED_LIBRARY && - !cmtarget.IsFrameworkOnApple()) + !gtgt->IsFrameworkOnApple()) { cmCustomCommandLines cmd; cmd.resize(1); @@ -1500,7 +1504,6 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, } std::vector<cmSourceFile*> classes; - cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); if (!gtgt->GetConfigCommonSourceFiles(classes)) { return; @@ -1814,14 +1817,14 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->CurrentLocalGenerator->AddLanguageFlags(flags, lang, configName); // Add shared-library flags if needed. - this->CurrentLocalGenerator->AddCMP0018Flags(flags, &target, + this->CurrentLocalGenerator->AddCMP0018Flags(flags, gtgt, lang, configName); - this->CurrentLocalGenerator->AddVisibilityPresetFlags(flags, &target, + this->CurrentLocalGenerator->AddVisibilityPresetFlags(flags, gtgt, lang); this->CurrentLocalGenerator-> - AddCompileOptions(flags, &target, lang, configName); + AddCompileOptions(flags, gtgt, lang, configName); } std::string llang = gtgt->GetLinkerLanguage(configName); @@ -1884,7 +1887,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->CurrentLocalGenerator ->GetStaticLibraryFlags(extraLinkOptions, cmSystemTools::UpperCase(configName), - &target); + gtgt); } else { @@ -1943,7 +1946,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, const char* version = target.GetProperty("VERSION"); const char* soversion = target.GetProperty("SOVERSION"); - if(!gtgt->HasSOName(configName) || target.IsFrameworkOnApple()) + if(!gtgt->HasSOName(configName) || gtgt->IsFrameworkOnApple()) { version = 0; soversion = 0; @@ -1990,7 +1993,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, pndir = gtgt->GetDirectory(configName); } - if(target.IsFrameworkOnApple() || target.IsCFBundleOnApple()) + if(gtgt->IsFrameworkOnApple() || gtgt->IsCFBundleOnApple()) { pnprefix = ""; } @@ -2043,7 +2046,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, { buildSettings->AddAttribute("LIBRARY_STYLE", this->CreateString("BUNDLE")); - if (target.IsCFBundleOnApple()) + if (gtgt->IsCFBundleOnApple()) { // It turns out that a BUNDLE is basically the same // in many ways as an application bundle, as far as @@ -2062,7 +2065,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // a per-configuration Info.plist file. The cfbundle plist // is very similar to the application bundle plist this->CurrentLocalGenerator - ->GenerateAppleInfoPList(&target, "$(EXECUTABLE_NAME)", + ->GenerateAppleInfoPList(gtgt, "$(EXECUTABLE_NAME)", plist.c_str()); std::string path = this->ConvertToRelativeForXCode(plist.c_str()); @@ -2111,7 +2114,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // so let it replace the framework name. This avoids creating // a per-configuration Info.plist file. this->CurrentLocalGenerator - ->GenerateFrameworkInfoPList(&target, "$(EXECUTABLE_NAME)", + ->GenerateFrameworkInfoPList(gtgt, "$(EXECUTABLE_NAME)", plist.c_str()); std::string path = this->ConvertToRelativeForXCode(plist.c_str()); @@ -2154,7 +2157,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // so let it replace the executable name. This avoids creating // a per-configuration Info.plist file. this->CurrentLocalGenerator - ->GenerateAppleInfoPList(&target, "$(EXECUTABLE_NAME)", + ->GenerateAppleInfoPList(gtgt, "$(EXECUTABLE_NAME)", plist.c_str()); std::string path = this->ConvertToRelativeForXCode(plist.c_str()); @@ -2422,7 +2425,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, int patch; // VERSION -> current_version - target.GetTargetVersion(false, major, minor, patch); + gtgt->GetTargetVersion(false, major, minor, patch); std::ostringstream v; // Xcode always wants at least 1.0.0 or nothing @@ -2434,7 +2437,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->CreateString(v.str().c_str())); // SOVERSION -> compatibility_version - target.GetTargetVersion(true, major, minor, patch); + gtgt->GetTargetVersion(true, major, minor, patch); std::ostringstream vso; // Xcode always wants at least 1.0.0 or nothing @@ -2639,23 +2642,24 @@ cmGlobalXCodeGenerator::GetTargetLinkFlagsVar(cmTarget const& cmtarget) const } //---------------------------------------------------------------------------- -const char* cmGlobalXCodeGenerator::GetTargetFileType(cmTarget& cmtarget) +const char* cmGlobalXCodeGenerator::GetTargetFileType( + cmGeneratorTarget* target) { - switch(cmtarget.GetType()) + switch(target->GetType()) { case cmState::OBJECT_LIBRARY: case cmState::STATIC_LIBRARY: return "archive.ar"; case cmState::MODULE_LIBRARY: - if (cmtarget.IsXCTestOnApple()) + if (target->IsXCTestOnApple()) return "wrapper.cfbundle"; - else if (cmtarget.IsCFBundleOnApple()) + else if (target->IsCFBundleOnApple()) return "wrapper.plug-in"; else return ((this->XcodeVersion >= 22)? "compiled.mach-o.executable" : "compiled.mach-o.dylib"); case cmState::SHARED_LIBRARY: - return (cmtarget.GetPropertyAsBool("FRAMEWORK")? + return (target->GetPropertyAsBool("FRAMEWORK")? "wrapper.framework" : "compiled.mach-o.dylib"); case cmState::EXECUTABLE: return "compiled.mach-o.executable"; @@ -2665,28 +2669,29 @@ const char* cmGlobalXCodeGenerator::GetTargetFileType(cmTarget& cmtarget) } //---------------------------------------------------------------------------- -const char* cmGlobalXCodeGenerator::GetTargetProductType(cmTarget& cmtarget) +const char* cmGlobalXCodeGenerator::GetTargetProductType( + cmGeneratorTarget* target) { - switch(cmtarget.GetType()) + switch(target->GetType()) { case cmState::OBJECT_LIBRARY: case cmState::STATIC_LIBRARY: return "com.apple.product-type.library.static"; case cmState::MODULE_LIBRARY: - if (cmtarget.IsXCTestOnApple()) + if (target->IsXCTestOnApple()) return "com.apple.product-type.bundle.unit-test"; - else if (cmtarget.IsCFBundleOnApple()) + else if (target->IsCFBundleOnApple()) return "com.apple.product-type.bundle"; else return ((this->XcodeVersion >= 22)? "com.apple.product-type.tool" : "com.apple.product-type.library.dynamic"); case cmState::SHARED_LIBRARY: - return (cmtarget.GetPropertyAsBool("FRAMEWORK")? + return (target->GetPropertyAsBool("FRAMEWORK")? "com.apple.product-type.framework" : "com.apple.product-type.library.dynamic"); case cmState::EXECUTABLE: - return (cmtarget.GetPropertyAsBool("MACOSX_BUNDLE")? + return (target->GetPropertyAsBool("MACOSX_BUNDLE")? "com.apple.product-type.application" : "com.apple.product-type.tool"); default: break; @@ -2727,9 +2732,11 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, target->AddAttribute("name", this->CreateString(cmtarget.GetName())); target->AddAttribute("productName",this->CreateString(cmtarget.GetName())); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&cmtarget); + cmXCodeObject* fileRef = this->CreateObject(cmXCodeObject::PBXFileReference); - if(const char* fileType = this->GetTargetFileType(cmtarget)) + if(const char* fileType = this->GetTargetFileType(gtgt)) { fileRef->AddAttribute("explicitFileType", this->CreateString(fileType)); } @@ -2742,7 +2749,6 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, } else { - cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&cmtarget); fullName = gtgt->GetFullName(defConfig.c_str()); } fileRef->AddAttribute("path", this->CreateString(fullName.c_str())); @@ -2752,7 +2758,7 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, fileRef->SetComment(cmtarget.GetName().c_str()); target->AddAttribute("productReference", this->CreateObjectReference(fileRef)); - if(const char* productType = this->GetTargetProductType(cmtarget)) + if(const char* productType = this->GetTargetProductType(gtgt)) { target->AddAttribute("productType", this->CreateString(productType)); } |