mpechner-mbp:Source michael.pechner$ diff cmGlobalXCodeGenerator.cxx ~/Desktop/cmake-2.8.7/Source/cmGlobalXCodeGenerator.cxx 150c150 < std::cerr << "CMake should be built with cmake to use XCode, " --- > std::cerr << "CMake should be built with cmake to use Xcode, " 168,174c168,177 < mf->AddCacheDefinition( < "CMAKE_CONFIGURATION_TYPES", < "Debug;Release;MinSizeRel;RelWithDebInfo", < "Semicolon separated list of supported configuration types, " < "only supports Debug, Release, MinSizeRel, and RelWithDebInfo, " < "anything else will be ignored.", < cmCacheManager::STRING); --- > if(!mf->GetDefinition("CMAKE_CONFIGURATION_TYPES")) > { > mf->AddCacheDefinition( > "CMAKE_CONFIGURATION_TYPES", > "Debug;Release;MinSizeRel;RelWithDebInfo", > "Semicolon separated list of supported configuration types, " > "only supports Debug, Release, MinSizeRel, and RelWithDebInfo, " > "anything else will be ignored.", > cmCacheManager::STRING); > } 322a326,343 > std::string > cmGlobalXCodeGenerator::PostBuildMakeTarget(std::string const& tName, > std::string const& configName) > { > std::string target = tName; > cmSystemTools::ReplaceString(target, " ", "_"); > std::string out = "PostBuild." + target; > if(this->XcodeVersion > 20) > { > out += "." + configName; > } > return out; > } > > //---------------------------------------------------------------------------- > #define CMAKE_CHECK_BUILD_SYSTEM_TARGET "ZERO_CHECK" > > //---------------------------------------------------------------------------- 351,353c372,384 < if(this->XcodeVersion > 20) < { < makecommand.push_back("all.$(CONFIGURATION)"); --- > makecommand.push_back(""); // placeholder, see below > > // Add ZERO_CHECK > bool regenerate = !mf->IsOn("CMAKE_SUPPRESS_REGENERATION"); > if (regenerate) > { > this->CreateReRunCMakeFile(root, gens); > std::string file = this->ConvertToRelativeForMake( > this->CurrentReRunCMakeMakefile.c_str()); > cmSystemTools::ReplaceString(file, "\\ ", " "); > mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, true, no_depends, > no_working_directory, > "make", "-f", file.c_str()); 355,358d385 < cmCustomCommandLines commandLines; < commandLines.push_back(makecommand); < // Add Re-Run CMake rules < this->CreateReRunCMakeFile(root, gens); 369a397 > 373a402,407 > > if (regenerate && (l->first != CMAKE_CHECK_BUILD_SYSTEM_TARGET)) > { > target.AddUtility(CMAKE_CHECK_BUILD_SYSTEM_TARGET); > } > 382a417,420 > makecommand[makecommand.size()-1] = > this->PostBuildMakeTarget(target.GetName(), "$(CONFIGURATION)"); > cmCustomCommandLines commandLines; > commandLines.push_back(makecommand); 389d426 < 390a428 > 423,424c461 < std::string dir = mf->GetHomeOutputDirectory(); < this->CurrentReRunCMakeMakefile = dir; --- > this->CurrentReRunCMakeMakefile = mf->GetStartOutputDirectory(); 455a493 > this->XCodeObjectIDs.clear(); 462a501,521 > void cmGlobalXCodeGenerator::addObject(cmXCodeObject *obj) > { > if(obj->GetType() == cmXCodeObject::OBJECT) > { > cmStdString id = obj->GetId(); > > // If this is a duplicate id, it's an error: > // > if(this->XCodeObjectIDs.count(id)) > { > cmSystemTools::Error( > "Xcode generator: duplicate object ids not allowed"); > } > > this->XCodeObjectIDs.insert(id); > } > > this->XCodeObjects.push_back(obj); > } > > //---------------------------------------------------------------------------- 475c534 < this->XCodeObjects.push_back(obj); --- > this->addObject(obj); 484c543 < this->XCodeObjects.push_back(obj); --- > this->addObject(obj); 526a586,592 > const char* srcfmt = sf->GetProperty("Fortran_FORMAT"); > switch(this->CurrentLocalGenerator->GetFortranFormat(srcfmt)) > { > case cmLocalGenerator::FortranFormatFixed: flags="-fixed "+flags; break; > case cmLocalGenerator::FortranFormatFree: flags="-free "+flags; break; > default: break; > } 580a647,652 > if(cmtarget.IsCFBundleOnApple()) > { > cmtarget.SetProperty("PREFIX", ""); > cmtarget.SetProperty("SUFFIX", ""); > } > 671,674d742 < else if(lang && strcmp(lang, "ASM") == 0) < { < sourcecode += ".asm"; < } 713c781,782 < tname == "install" || tname == "package" || tname == "RUN_TESTS" ) --- > tname == "install" || tname == "package" || tname == "RUN_TESTS" || > tname == CMAKE_CHECK_BUILD_SYSTEM_TARGET ) 818a888 > bool isCFBundleTarget = cmtarget.IsCFBundleOnApple(); 864c934,935 < if (!resourceFiles.empty() && (isFrameworkTarget || isBundleTarget)) --- > if (!resourceFiles.empty() && > (isFrameworkTarget || isBundleTarget || isCFBundleTarget)) 885c956 < if (isFrameworkTarget || isBundleTarget) --- > if (isFrameworkTarget || isBundleTarget || isCFBundleTarget) 959c1030 < // create list of build phases and create the XCode target --- > // create list of build phases and create the Xcode target 1097,1101d1167 < std::vector reruncom; < cmXCodeObject* cmakeReRunPhase = < this->CreateBuildPhase("CMake ReRun", "cmakeReRunPhase", < cmtarget, reruncom); < buildPhases->AddObject(cmakeReRunPhase); 1164a1231,1232 > // This function removes each occurence of the flag and returns the last one > // (i.e., the dominant flag in GCC) 1169,1170c1237,1239 < std::string::size_type pos = flags.find(flag); < if(pos != flags.npos && (pos ==0 || flags[pos-1]==' ')) --- > std::string::size_type pos = flags.rfind(flag); > bool saved = false; > while(pos != flags.npos) 1172c1241 < while(pos < flags.size() && flags[pos] != ' ') --- > if(pos == 0 || flags[pos-1]==' ') 1174,1176c1243,1251 < retFlag += flags[pos]; < flags[pos] = ' '; < pos++; --- > while(pos < flags.size() && flags[pos] != ' ') > { > if(!saved) > { > retFlag += flags[pos]; > } > flags[pos] = ' '; > pos++; > } 1177a1253,1254 > saved = true; > pos = flags.rfind(flag); 1190,1203d1266 < if(strcmp(name, "cmakeReRunPhase") == 0) < { < std::string cdir = this->CurrentMakefile->GetHomeOutputDirectory(); < cdir = this->ConvertToRelativeForMake(cdir.c_str()); < std::string makecmd = "make -C "; < makecmd += cdir; < makecmd += " -f "; < makecmd += < this->ConvertToRelativeForMake(this->CurrentReRunCMakeMakefile.c_str()); < cmSystemTools::ReplaceString(makecmd, "\\ ", "\\\\ "); < buildphase->AddAttribute("shellScript", < this->CreateString(makecmd.c_str())); < return; < } 1266a1330,1331 > buildphase->AddAttribute("showEnvVarsInLog", > this->CreateString("0")); 1463c1528,1529 < this->AppendDefines(ppDefs, "CMAKE_INTDIR=\"$(CONFIGURATION)\""); --- > this->AppendDefines(ppDefs, > "CMAKE_INTDIR=\"$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)\""); 1580,1582c1646,1651 < std::string pncdir = target.GetDirectory(configName); < buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR", < this->CreateString(pncdir.c_str())); --- > if(!target.UsesDefaultOutputDir(configName, false)) > { > std::string pncdir = target.GetDirectory(configName); > buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR", > this->CreateString(pncdir.c_str())); > } 1612c1681,1707 < if(this->XcodeVersion >= 22) --- > if (target.GetPropertyAsBool("BUNDLE")) > { > // It turns out that a BUNDLE is basically the same > // in many ways as an application bundle, as far as > // link flags go > std::string createFlags = > this->LookupFlags("CMAKE_SHARED_MODULE_CREATE_", lang, "_FLAGS", > "-bundle"); > if(!createFlags.empty()) > { > extraLinkOptions += " "; > extraLinkOptions += createFlags; > } > std::string plist = this->ComputeInfoPListLocation(target); > // Xcode will create the final version of Info.plist at build time, > // so let it replace the cfbundle name. This avoids creating > // a per-configuration Info.plist file. The cfbundle plist > // is very similar to the application bundle plist > this->CurrentLocalGenerator > ->GenerateAppleInfoPList(&target, "$(EXECUTABLE_NAME)", > plist.c_str()); > std::string path = > this->ConvertToRelativeForXCode(plist.c_str()); > buildSettings->AddAttribute("INFOPLIST_FILE", > this->CreateString(path.c_str())); > } > else if(this->XcodeVersion >= 22) 1651c1746 < // so let it replace the framework name. This avoids creating --- > // so let it replace the framework name. This avoids creating 1710c1805 < if(this->XcodeVersion >= 22) --- > if(this->XcodeVersion >= 22 && this->XcodeVersion < 40) 1800c1895,1905 < if(gflagc.size() ==0 && gflag.size() == 0) --- > // We can't set the Xcode flag differently depending on the language, > // so put them back in this case. > if( (lang && strcmp(lang, "CXX") == 0) && gflag != gflagc ) > { > cflags += " "; > cflags += gflagc; > flags += " "; > flags += gflag; > debugStr = "NO"; > } > if( gflag == "-g0" || gflag.size() == 0 ) 1832a1938,1952 > // Add Fortran source format attribute if property is set. > const char* format = 0; > const char* tgtfmt = target.GetProperty("Fortran_FORMAT"); > switch(this->CurrentLocalGenerator->GetFortranFormat(tgtfmt)) > { > case cmLocalGenerator::FortranFormatFixed: format = "fixed"; break; > case cmLocalGenerator::FortranFormatFree: format = "free"; break; > default: break; > } > if(format) > { > buildSettings->AddAttribute("IFORT_LANG_SRCFMT", > this->CreateString(format)); > } > 1852,1855d1971 < // -- move this line from below, on all targets, to here where it ONLY sets INSTALL_PATH in this case, < // which fixes a problem where XCode 4 won't "ARCHIVE" unless the component targets have an unset INSTALL_PATH < buildSettings->AddAttribute("INSTALL_PATH", < this->CreateString(install_name_dir.c_str())); 1857a1974,1975 > buildSettings->AddAttribute("INSTALL_PATH", > this->CreateString(install_name_dir.c_str())); 1950a2069,2071 > shellBuildPhase->AddAttribute("showEnvVarsInLog", > this->CreateString("0")); > 1993a2115,2117 > target->SetId(this->GetOrCreateId( > cmtarget.GetName(), target->GetId()).c_str()); > 2052c2176,2179 < return ((this->XcodeVersion >= 22)? --- > if (cmtarget.IsCFBundleOnApple()) > return "wrapper.plug-in"; > else > return ((this->XcodeVersion >= 22)? 2067,2072d2193 < // When producing certain types of bundles (front row appliances), they should also < // have a particular product type. < const char* productType = cmtarget.GetProperty("MACOSX_PRODUCT_TYPE"); < if (productType) < return productType; < 2078,2079c2199,2204 < return ((this->XcodeVersion >= 22)? "com.apple.product-type.tool" : < "com.apple.product-type.library.dynamic"); --- > if (cmtarget.IsCFBundleOnApple()) > return "com.apple.product-type.bundle"; > else > return ((this->XcodeVersion >= 22)? > "com.apple.product-type.tool" : > "com.apple.product-type.library.dynamic"); 2140a2266,2267 > target->SetId(this->GetOrCreateId( > cmtarget.GetName(), target->GetId()).c_str()); 2163a2291,2310 > std::string cmGlobalXCodeGenerator::GetOrCreateId(const char* name, > const char* id) > { > std::string guidStoreName = name; > guidStoreName += "_GUID_CMAKE"; > const char* storedGUID = > this->CMakeInstance->GetCacheDefinition(guidStoreName.c_str()); > > if(storedGUID) > { > return storedGUID; > } > > this->CMakeInstance->AddCacheEntry(guidStoreName.c_str(), > id, "Stored Xcode object GUID", cmCacheManager::INTERNAL); > > return id; > } > > //---------------------------------------------------------------------------- 2357c2504,2505 < // now add the same one but append $(CONFIGURATION) to it: --- > // Now add the same one but append > // $(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) to it: 2360c2508 < (*libDir + "/$(CONFIGURATION)").c_str()); --- > (*libDir + "/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)").c_str()); 2407a2556,2559 > if(li->Target && !li->Target->IsImported()) > { > target->AddDependTarget(configName, li->Target->GetName()); > } 2462c2614,2617 < sourceGroup.AssignSource( sf ); --- > cmXCodeObject* pbxgroup = > this->CreateOrGetPBXGroup(cmtarget, &sourceGroup); > cmStdString key = GetGroupMapKey(cmtarget, sf); > this->GroupMap[key] = pbxgroup; 2464,2470c2619 < // Create all of the groups that should be created for this target. < // Loop through every source group. < for(unsigned int i = 0; i < sourceGroups.size(); ++i) < { < CreateSourceGroup( sourceGroups[i], cmtarget, false ); < } < } --- > } 2474,2475c2623,2624 < cmXCodeObject* cmGlobalXCodeGenerator < ::CreateSourceGroup(cmSourceGroup& sg, cmTarget& cmtarget, bool child_group) --- > cmXCodeObject *cmGlobalXCodeGenerator > ::CreatePBXGroup(cmXCodeObject *parent, cmStdString name) 2477,2502c2626,2641 < // Only do something with the group if there are files or child groups < if( !sg.GetSourceFiles().empty() || !sg.GetGroupChildren().empty() ) < { < cmXCodeObject* pbxgroup = this->CreateOrGetPBXGroup(cmtarget, &sg, !child_group); < < std::vector& sources = sg.GetSourceFiles(); < // Get all the source files and add them to the GroupMap < for(std::vector::const_iterator s = sources.begin(); < s != sources.end(); s++) < { < cmStdString key = GetGroupMapKey(cmtarget, (cmSourceFile*)*s); < this->GroupMap[key] = pbxgroup; < } < < // Do the child groups < std::vector children = sg.GetGroupChildren(); < cmXCodeObject* groupChildren = pbxgroup->GetObject("children"); < < for(unsigned int i=0;iCreateSourceGroup( children[i], cmtarget, true ); < groupChildren->AddObject(group); < } < return pbxgroup; < } < return NULL; --- > cmXCodeObject* parentChildren = NULL; > if(parent) > parentChildren = parent->GetObject("children"); > cmXCodeObject* group = this->CreateObject(cmXCodeObject::PBXGroup); > cmXCodeObject* groupChildren = > this->CreateObject(cmXCodeObject::OBJECT_LIST); > group->AddAttribute("name", this->CreateString(name.c_str())); > group->AddAttribute("children", groupChildren); > if(this->XcodeVersion == 15) > { > group->AddAttribute("refType", this->CreateString("4")); > } > group->AddAttribute("sourceTree", this->CreateString("")); > if(parentChildren) > parentChildren->AddObject(group); > return group; 2505,2506d2643 < < 2509c2646 < ::CreateOrGetPBXGroup(cmTarget& cmtarget, cmSourceGroup* sg, bool target_child) --- > ::CreateOrGetPBXGroup(cmTarget& cmtarget, cmSourceGroup* sg) 2511,2512c2648,2656 < cmStdString s = cmtarget.GetName(); < s += "/"; --- > cmStdString s; > cmStdString target; > const char *targetFolder= cmtarget.GetProperty("FOLDER"); > if(targetFolder) { > target = targetFolder; > target += "/"; > } > target += cmtarget.GetName(); > s = target + "/"; 2514c2658 < std::map::iterator i = --- > std::map::iterator it = 2516c2660 < if(i != this->GroupNameMap.end()) --- > if(it != this->GroupNameMap.end()) 2518c2662 < return i->second; --- > return it->second; 2520c2664,2665 < i = this->TargetGroup.find(cmtarget.GetName()); --- > > it = this->TargetGroup.find(target); 2522c2667 < if(i != this->TargetGroup.end()) --- > if(it != this->TargetGroup.end()) 2524c2669 < tgroup = i->second; --- > tgroup = it->second; 2528,2536c2673,2694 < tgroup = this->CreateObject(cmXCodeObject::PBXGroup); < this->TargetGroup[cmtarget.GetName()] = tgroup; < cmXCodeObject* tgroupChildren = < this->CreateObject(cmXCodeObject::OBJECT_LIST); < tgroup->AddAttribute("name", this->CreateString(cmtarget.GetName())); < tgroup->AddAttribute("children", tgroupChildren); < if(this->XcodeVersion == 15) < { < tgroup->AddAttribute("refType", this->CreateString("4")); --- > std::vector tgt_folders = > cmSystemTools::tokenize(target, "/"); > cmStdString curr_tgt_folder; > for(std::vector::size_type i = 0; i < tgt_folders.size();i++) > { > curr_tgt_folder += tgt_folders[i]; > it = this->TargetGroup.find(curr_tgt_folder); > if(it == this->TargetGroup.end()) > { > tgroup = this->CreatePBXGroup(tgroup,tgt_folders[i]); > this->TargetGroup[curr_tgt_folder] = tgroup; > } > else > { > tgroup = it->second; > continue; > } > if(i == 0) > { > this->SourcesGroupChildren->AddObject(tgroup); > } > curr_tgt_folder += "/"; 2538,2539d2695 < tgroup->AddAttribute("sourceTree", this->CreateString("")); < this->SourcesGroupChildren->AddObject(tgroup); 2540a2697 > this->TargetGroup[target] = tgroup; 2545c2702 < if (cmStdString(sg->GetName()) == "") --- > if (cmStdString(sg->GetFullName()) == "") 2551,2556c2708,2709 < cmXCodeObject* group = this->CreateObject(cmXCodeObject::PBXGroup); < cmXCodeObject* groupChildren = < this->CreateObject(cmXCodeObject::OBJECT_LIST); < group->AddAttribute("name", this->CreateString(sg->GetName())); < group->AddAttribute("children", groupChildren); < if(this->XcodeVersion == 15) --- > //It's a recursive folder structure, let's find the real parent group > if(std::string(sg->GetFullName()) != std::string(sg->GetName())) 2558,2564c2711,2733 < group->AddAttribute("refType", this->CreateString("4")); < } < group->AddAttribute("sourceTree", this->CreateString("")); < if( target_child ) < { < cmXCodeObject* tgroupChildren = tgroup->GetObject("children"); < tgroupChildren->AddObject(group); --- > std::vector folders = > cmSystemTools::tokenize(sg->GetFullName(), "\\"); > cmStdString curr_folder = cmtarget.GetName(); > curr_folder += "/"; > for(std::vector::size_type i = 0; i < folders.size();i++) > { > curr_folder += folders[i]; > std::map::iterator i_folder = > this->GroupNameMap.find(curr_folder); > //Create new folder > if(i_folder == this->GroupNameMap.end()) > { > cmXCodeObject *group = this->CreatePBXGroup(tgroup,folders[i]); > this->GroupNameMap[curr_folder] = group; > tgroup = group; > } > else > { > tgroup = i_folder->second; > } > curr_folder = curr_folder + "\\"; > } > return tgroup; 2566c2735 < --- > cmXCodeObject *group = this->CreatePBXGroup(tgroup,sg->GetName()); 2669a2839,2844 > > std::string project_id = "PROJECT_"; > project_id += root->GetMakefile()->GetProjectName(); > this->RootObject->SetId(this->GetOrCreateId( > project_id.c_str(), this->RootObject->GetId()).c_str()); > 2893,2927c3068,3071 < makefileStream << "# up-to-date with anything they link to, avoiding a " < "bug in XCode 1.5\n"; < for(std::vector::const_iterator < ct = this->CurrentConfigurationTypes.begin(); < ct != this->CurrentConfigurationTypes.end(); ++ct) < { < if(this->XcodeVersion < 21 || ct->empty()) < { < makefileStream << "all: "; < } < else < { < makefileStream << "all." << *ct << ": "; < } < const char* configName = 0; < if(!ct->empty()) < { < configName = ct->c_str(); < } < for(std::vector::iterator i = targets.begin(); < i != targets.end(); ++i) < { < cmXCodeObject* target = *i; < cmTarget* t =target->GetTarget(); < if(t->GetType() == cmTarget::EXECUTABLE || < t->GetType() == cmTarget::SHARED_LIBRARY || < t->GetType() == cmTarget::MODULE_LIBRARY) < { < std::string tfull = t->GetFullPath(configName); < makefileStream << "\\\n\t" << < this->ConvertToRelativeForMake(tfull.c_str()); < } < } < makefileStream << "\n\n"; < } --- > makefileStream << "# up-to-date with anything they link to\n" > "default:\n" > "\techo \"Do not invoke directly\"\n" > "\n"; 2972a3117,3127 > > if(t->GetType() == cmTarget::EXECUTABLE || > t->GetType() == cmTarget::STATIC_LIBRARY || > t->GetType() == cmTarget::SHARED_LIBRARY || > t->GetType() == cmTarget::MODULE_LIBRARY) > { > // Declare an entry point for the target post-build phase. > makefileStream << this->PostBuildMakeTarget(t->GetName(), *ct) > << ":\n"; > } > 2977d3131 < // Create a rule for this target. 2979,2980c3133,3150 < makefileStream << this->ConvertToRelativeForMake(tfull.c_str()) < << ":"; --- > std::string trel = this->ConvertToRelativeForMake(tfull.c_str()); > > // Add this target to the post-build phases of its dependencies. > std::map::const_iterator > y = target->GetDependTargets().find(*ct); > if(y != target->GetDependTargets().end()) > { > std::vector const& deptgts = y->second; > for(std::vector::const_iterator d = deptgts.begin(); > d != deptgts.end(); ++d) > { > makefileStream << this->PostBuildMakeTarget(*d, *ct) << ": " > << trel << "\n"; > } > } > > // Create a rule for this target. > makefileStream << trel << ":"; 3072a3243,3247 > > // Since this call may have created new cache entries, save the cache: > // > root->GetMakefile()->GetCacheManager()->SaveCache( > root->GetMakefile()->GetHomeOutputDirectory()); 3115c3290,3291 < return this->XcodeVersion >= 21? "$(CONFIGURATION)" : "."; --- > return this->XcodeVersion >= 21 ? > "$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)" : "."; 3123c3299 < entry.Brief = "Generate XCode project files."; --- > entry.Brief = "Generate Xcode project files."; 3344c3520,3527 < flags += "\\\\'"; --- > if (this->XcodeVersion >= 40) > { > flags += "'\\\\''"; > } > else > { > flags += "\\\\'"; > } mpechner-mbp:Source michael.pechner$ diff cmGlobalXCodeGenerator.cxx ~/Desktop/cmake-2.8.7/Source/cmGlobalXCodeGenerator. cmGlobalXCodeGenerator.cxx cmGlobalXCodeGenerator.h mpechner-mbp:Source michael.pechner$ diff cmGlobalXCodeGenerator.cxx ~/Desktop/cmake-2.8.7/Source/cmGlobalXCodeGenerator.