diff options
Diffstat (limited to 'Source/cmGlobalXCodeGenerator.cxx')
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 473 |
1 files changed, 245 insertions, 228 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 05c6848..1395865 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -18,6 +18,7 @@ #include "cmGeneratedFileStream.h" #include "cmComputeLinkInformation.h" #include "cmSourceFile.h" +#include "cmCustomCommandGenerator.h" #include <cmsys/auto_ptr.hxx> @@ -131,8 +132,8 @@ cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(std::string const& version) //---------------------------------------------------------------------------- cmGlobalGenerator* cmGlobalXCodeGenerator::New() -{ -#if defined(CMAKE_BUILD_WITH_CMAKE) +{ +#if defined(CMAKE_BUILD_WITH_CMAKE) cmXcodeVersionParser parser; parser.ParseFile ("/Developer/Applications/Xcode.app/Contents/version.plist"); @@ -156,7 +157,7 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::New() void cmGlobalXCodeGenerator::EnableLanguage(std::vector<std::string>const& lang, cmMakefile * mf, bool optional) -{ +{ mf->AddDefinition("XCODE","1"); mf->AddDefinition("XCODE_VERSION", this->VersionString.c_str()); if(this->XcodeVersion == 15) @@ -175,12 +176,12 @@ void cmGlobalXCodeGenerator::EnableLanguage(std::vector<std::string>const& mf->AddDefinition("CMAKE_GENERATOR_CC", "gcc"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "g++"); mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1"); - // initialize Architectures so it can be used by + // initialize Architectures so it can be used by // GetTargetObjectFileDirectories this->cmGlobalGenerator::EnableLanguage(lang, mf, optional); - const char* osxArch = + const char* osxArch = mf->GetDefinition("CMAKE_OSX_ARCHITECTURES"); - const char* sysroot = + const char* sysroot = mf->GetDefinition("CMAKE_OSX_SYSROOT"); if(osxArch && sysroot) { @@ -193,10 +194,10 @@ void cmGlobalXCodeGenerator::EnableLanguage(std::vector<std::string>const& //---------------------------------------------------------------------------- std::string cmGlobalXCodeGenerator ::GenerateBuildCommand(const char* makeProgram, - const char *projectName, - const char* additionalOptions, + const char *projectName, + const char* additionalOptions, const char *targetName, - const char* config, + const char* config, bool ignoreErrors, bool) { @@ -210,7 +211,7 @@ std::string cmGlobalXCodeGenerator "Generator cannot find the appropriate make command."); return ""; } - std::string makeCommand = + std::string makeCommand = cmSystemTools::ConvertToOutputPath(makeProgram); std::string lowerCaseCommand = makeCommand; cmSystemTools::LowerCase(lowerCaseCommand); @@ -284,7 +285,7 @@ void cmGlobalXCodeGenerator::Generate() // make sure extra targets are added before calling // the parent generate which will call trace depends for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it) - { + { cmLocalGenerator* root = it->second[0]; this->SetGenerationRoot(root); // add ALL_BUILD, INSTALL, etc @@ -293,7 +294,7 @@ void cmGlobalXCodeGenerator::Generate() this->ForceLinkerLanguages(); this->cmGlobalGenerator::Generate(); for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it) - { + { cmLocalGenerator* root = it->second[0]; this->SetGenerationRoot(root); // now create the project @@ -319,8 +320,8 @@ void cmGlobalXCodeGenerator::SetGenerationRoot(cmLocalGenerator* root) } //---------------------------------------------------------------------------- -void -cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, +void +cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, std::vector<cmLocalGenerator*>& gens) { cmMakefile* mf = root->GetMakefile(); @@ -339,7 +340,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, listfile += "CMakeLists.txt"; allbuild->AddSource(listfile.c_str()); - // Add XCODE depend helper + // Add XCODE depend helper std::string dir = mf->GetCurrentOutputDirectory(); cmCustomCommandLine makecommand; makecommand.push_back("make"); @@ -354,14 +355,14 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, cmCustomCommandLines commandLines; commandLines.push_back(makecommand); // Add Re-Run CMake rules - this->CreateReRunCMakeFile(root); + this->CreateReRunCMakeFile(root, gens); // now make the allbuild depend on all the non-utility targets // in the project for(std::vector<cmLocalGenerator*>::iterator i = gens.begin(); i != gens.end(); ++i) { - cmLocalGenerator* lg = *i; + cmLocalGenerator* lg = *i; if(this->IsExcluded(root, *i)) { continue; @@ -370,7 +371,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) { cmTarget& target = l->second; - // make all exe, shared libs and modules + // make all exe, shared libs and modules // run the depend check makefile as a post build rule // this will make sure that when the next target is built // things are up-to-date @@ -385,7 +386,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, cmTarget::POST_BUILD, "Depend check for xcode", dir.c_str()); - + } if(!target.GetPropertyAsBool("EXCLUDE_FROM_ALL")) { @@ -402,13 +403,21 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, } //---------------------------------------------------------------------------- -void cmGlobalXCodeGenerator::CreateReRunCMakeFile(cmLocalGenerator* root) +void cmGlobalXCodeGenerator::CreateReRunCMakeFile( + cmLocalGenerator* root, std::vector<cmLocalGenerator*> const& gens) { cmMakefile* mf = root->GetMakefile(); - std::vector<std::string> lfiles = mf->GetListFiles(); + std::vector<std::string> lfiles; + for(std::vector<cmLocalGenerator*>::const_iterator gi = gens.begin(); + gi != gens.end(); ++gi) + { + std::vector<std::string> const& lf = (*gi)->GetMakefile()->GetListFiles(); + lfiles.insert(lfiles.end(), lf.begin(), lf.end()); + } + // sort the array - std::sort(lfiles.begin(), lfiles.end(), std::less<std::string>()); - std::vector<std::string>::iterator new_end = + std::sort(lfiles.begin(), lfiles.end(), std::less<std::string>()); + std::vector<std::string>::iterator new_end = std::unique(lfiles.begin(), lfiles.end()); lfiles.erase(new_end, lfiles.end()); std::string dir = mf->GetHomeOutputDirectory(); @@ -428,7 +437,7 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile(cmLocalGenerator* root) makefileStream << "\\\n" << this->ConvertToRelativeForMake(i->c_str()); } std::string cmake = mf->GetRequiredDefinition("CMAKE_COMMAND"); - makefileStream << "\n\t" << this->ConvertToRelativeForMake(cmake.c_str()) + makefileStream << "\n\t" << this->ConvertToRelativeForMake(cmake.c_str()) << " -H" << this->ConvertToRelativeForMake( mf->GetHomeDirectory()) << " -B" << this->ConvertToRelativeForMake( @@ -451,7 +460,7 @@ void cmGlobalXCodeGenerator::ClearXCodeObjects() } //---------------------------------------------------------------------------- -cmXCodeObject* +cmXCodeObject* cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::PBXType ptype) { cmXCodeObject* obj; @@ -468,7 +477,7 @@ cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::PBXType ptype) } //---------------------------------------------------------------------------- -cmXCodeObject* +cmXCodeObject* cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::Type type) { cmXCodeObject* obj = new cmXCodeObject(cmXCodeObject::None, type); @@ -539,7 +548,7 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg, buildFile->SetComment(fileRef->GetComment()); buildFile->AddAttribute("fileRef", this->CreateObjectReference(fileRef)); - cmXCodeObject* settings = + cmXCodeObject* settings = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); settings->AddAttribute("COMPILER_FLAGS", this->CreateString(flags.c_str())); @@ -608,7 +617,7 @@ cmGlobalXCodeGenerator::CreateXCodeFileReference(cmSourceFile* sf, } fileRef->AddAttribute("fileEncoding", this->CreateString("4")); - const char* lang = + const char* lang = this->CurrentLocalGenerator->GetSourceFileLanguage(*sf); std::string sourcecode = "sourcecode"; std::string ext = sf->GetExtension(); @@ -643,7 +652,7 @@ cmGlobalXCodeGenerator::CreateXCodeFileReference(cmSourceFile* sf, sourcecode += ".c.h"; } else if(ext == "hxx" || ext == "hpp" || ext == "txx" - || ext == "pch") + || ext == "pch" || ext == "hh") { sourcecode += ".cpp.h"; } @@ -675,7 +684,7 @@ cmGlobalXCodeGenerator::CreateXCodeFileReference(cmSourceFile* sf, // // valid lastKnownFileType value. // } - fileRef->AddAttribute("lastKnownFileType", + fileRef->AddAttribute("lastKnownFileType", this->CreateString(sourcecode.c_str())); // Store the file path relative to the top of the source tree. @@ -717,31 +726,15 @@ void cmGlobalXCodeGenerator::SetCurrentLocalGenerator(cmLocalGenerator* gen) std::string outdir = cmSystemTools::CollapseFullPath(this->CurrentMakefile-> GetCurrentOutputDirectory()); - cmSystemTools::SplitPath(outdir.c_str(), + cmSystemTools::SplitPath(outdir.c_str(), this->CurrentOutputDirectoryComponents); // Select the current set of configuration types. this->CurrentConfigurationTypes.clear(); - if(this->XcodeVersion > 20) - { - if(const char* types = - this->CurrentMakefile->GetDefinition("CMAKE_CONFIGURATION_TYPES")) - { - cmSystemTools::ExpandListArgument(types, - this->CurrentConfigurationTypes); - } - } + this->CurrentMakefile->GetConfigurations(this->CurrentConfigurationTypes); if(this->CurrentConfigurationTypes.empty()) { - if(const char* buildType = - this->CurrentMakefile->GetDefinition("CMAKE_BUILD_TYPE")) - { - this->CurrentConfigurationTypes.push_back(buildType); - } - else - { - this->CurrentConfigurationTypes.push_back(""); - } + this->CurrentConfigurationTypes.push_back(""); } } @@ -783,7 +776,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, this->CreateXCodeSourceFile(this->CurrentLocalGenerator, *i, cmtarget); cmXCodeObject* fr = xsf->GetObject("fileRef"); - cmXCodeObject* filetype = + cmXCodeObject* filetype = fr->GetObject()->GetObject("lastKnownFileType"); cmTarget::SourceFileFlags tsFlags = @@ -829,7 +822,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, sourceBuildPhase = this->CreateObject(cmXCodeObject::PBXSourcesBuildPhase); sourceBuildPhase->SetComment("Sources"); - sourceBuildPhase->AddAttribute("buildActionMask", + sourceBuildPhase->AddAttribute("buildActionMask", this->CreateString("2147483647")); buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST); for(std::vector<cmXCodeObject*>::iterator i = sourceFiles.begin(); @@ -838,7 +831,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, buildFiles->AddObject(*i); } sourceBuildPhase->AddAttribute("files", buildFiles); - sourceBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing", + sourceBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing", this->CreateString("0")); } @@ -931,7 +924,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, for ( sfIt = mit->second.begin(); sfIt != mit->second.end(); ++ sfIt ) { cmXCodeObject* xsf = - this->CreateXCodeSourceFile(this->CurrentLocalGenerator, + this->CreateXCodeSourceFile(this->CurrentLocalGenerator, *sfIt, cmtarget); buildFiles->AddObject(xsf); } @@ -955,12 +948,12 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, { buildFiles->AddObject(*i); } - frameworkBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing", + frameworkBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing", this->CreateString("0")); } // create list of build phases and create the XCode target - cmXCodeObject* buildPhases = + cmXCodeObject* buildPhases = this->CreateObject(cmXCodeObject::OBJECT_LIST); this->CreateCustomCommands(buildPhases, sourceBuildPhase, @@ -1049,15 +1042,15 @@ cmGlobalXCodeGenerator::CreateBuildPhase(const char* name, { return 0; } - cmXCodeObject* buildPhase = + cmXCodeObject* buildPhase = this->CreateObject(cmXCodeObject::PBXShellScriptBuildPhase); buildPhase->AddAttribute("buildActionMask", this->CreateString("2147483647")); cmXCodeObject* buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST); buildPhase->AddAttribute("files", buildFiles); - buildPhase->AddAttribute("name", + buildPhase->AddAttribute("name", this->CreateString(name)); - buildPhase->AddAttribute("runOnlyForDeploymentPostprocessing", + buildPhase->AddAttribute("runOnlyForDeploymentPostprocessing", this->CreateString("0")); buildPhase->AddAttribute("shellPath", this->CreateString("/bin/sh")); @@ -1080,16 +1073,16 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, frameworkBuildPhase, cmTarget& cmtarget) { - std::vector<cmCustomCommand> const & prebuild + std::vector<cmCustomCommand> const & prebuild = cmtarget.GetPreBuildCommands(); - std::vector<cmCustomCommand> const & prelink + std::vector<cmCustomCommand> const & prelink = cmtarget.GetPreLinkCommands(); - std::vector<cmCustomCommand> const & postbuild + std::vector<cmCustomCommand> const & postbuild = cmtarget.GetPostBuildCommands(); std::vector<cmSourceFile*>const &classes = cmtarget.GetSourceFiles(); // add all the sources std::vector<cmCustomCommand> commands; - for(std::vector<cmSourceFile*>::const_iterator i = classes.begin(); + for(std::vector<cmSourceFile*>::const_iterator i = classes.begin(); i != classes.end(); ++i) { if((*i)->GetCustomCommand()) @@ -1098,7 +1091,7 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, } } std::vector<cmCustomCommand> reruncom; - cmXCodeObject* cmakeReRunPhase = + cmXCodeObject* cmakeReRunPhase = this->CreateBuildPhase("CMake ReRun", "cmakeReRunPhase", cmtarget, reruncom); buildPhases->AddObject(cmakeReRunPhase); @@ -1108,15 +1101,15 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, "cmakeRulesBuildPhase", cmtarget, commands); // create prebuild phase - cmXCodeObject* preBuildPhase = + cmXCodeObject* preBuildPhase = this->CreateBuildPhase("CMake PreBuild Rules", "preBuildCommands", cmtarget, prebuild); // create prelink phase - cmXCodeObject* preLinkPhase = + cmXCodeObject* preLinkPhase = this->CreateBuildPhase("CMake PreLink Rules", "preLinkCommands", cmtarget, prelink); // create postbuild phase - cmXCodeObject* postBuildPhase = + cmXCodeObject* postBuildPhase = this->CreateBuildPhase("CMake PostBuild Rules", "postBuildPhase", cmtarget, postbuild); @@ -1183,10 +1176,10 @@ std::string cmGlobalXCodeGenerator::ExtractFlag(const char* flag, } //---------------------------------------------------------------------------- -void +void cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase, cmTarget& target, - std::vector<cmCustomCommand> + std::vector<cmCustomCommand> const & commands, const char* name) { @@ -1197,7 +1190,7 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase, std::string makecmd = "make -C "; makecmd += cdir; makecmd += " -f "; - makecmd += + makecmd += this->ConvertToRelativeForMake(this->CurrentReRunCMakeMakefile.c_str()); cmSystemTools::ReplaceString(makecmd, "\\ ", "\\\\ "); buildphase->AddAttribute("shellScript", @@ -1211,7 +1204,7 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase, for(std::vector<cmCustomCommand>::const_iterator i = commands.begin(); i != commands.end(); ++i) { - cmCustomCommand const& cc = *i; + cmCustomCommand const& cc = *i; if(!cc.GetCommandLines().empty()) { const std::vector<std::string>& outputs = cc.GetOutputs(); @@ -1229,7 +1222,7 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase, } } } - + std::string dir = this->CurrentMakefile->GetCurrentOutputDirectory(); dir += "/CMakeScripts"; cmSystemTools::MakeDirectory(dir.c_str()); @@ -1239,19 +1232,19 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase, makefile += "_"; makefile += name; makefile += ".make"; - - for (std::vector<std::string>::const_iterator currentConfig= + + for (std::vector<std::string>::const_iterator currentConfig= this->CurrentConfigurationTypes.begin(); currentConfig!=this->CurrentConfigurationTypes.end(); currentConfig++ ) { - this->CreateCustomRulesMakefile(makefile.c_str(), - target, - commands, + this->CreateCustomRulesMakefile(makefile.c_str(), + target, + commands, currentConfig->c_str(), multipleOutputPairs); } - + std::string cdir = this->CurrentMakefile->GetCurrentOutputDirectory(); cdir = this->ConvertToRelativeForXCode(cdir.c_str()); std::string makecmd = "make -C "; @@ -1265,18 +1258,18 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase, } makecmd += " all"; cmSystemTools::ReplaceString(makecmd, "\\ ", "\\\\ "); - buildphase->AddAttribute("shellScript", + buildphase->AddAttribute("shellScript", this->CreateString(makecmd.c_str())); } //---------------------------------------------------------------------------- void cmGlobalXCodeGenerator -::CreateCustomRulesMakefile(const char* makefileBasename, - cmTarget& target, - std::vector<cmCustomCommand> +::CreateCustomRulesMakefile(const char* makefileBasename, + cmTarget& target, + std::vector<cmCustomCommand> const & commands, const char* configName, - const std::map<cmStdString, + const std::map<cmStdString, cmStdString>& multipleOutputPairs ) { @@ -1293,7 +1286,10 @@ void cmGlobalXCodeGenerator makefileStream.SetCopyIfDifferent(true); makefileStream << "# Generated by CMake, DO NOT EDIT\n"; makefileStream << "# Custom rules for " << target.GetName() << "\n"; - + + // disable the implicit rules + makefileStream << ".SUFFIXES: " << "\n"; + // have all depend on all outputs makefileStream << "all: "; std::map<const cmCustomCommand*, cmStdString> tname; @@ -1301,7 +1297,7 @@ void cmGlobalXCodeGenerator for(std::vector<cmCustomCommand>::const_iterator i = commands.begin(); i != commands.end(); ++i) { - cmCustomCommand const& cc = *i; + cmCustomCommand const& cc = *i; if(!cc.GetCommandLines().empty()) { const std::vector<std::string>& outputs = cc.GetOutputs(); @@ -1315,10 +1311,10 @@ void cmGlobalXCodeGenerator } } else - { + { cmOStringStream str; str << "_buildpart_" << count++ ; - tname[&cc] = std::string(target.GetName()) + str.str(); + tname[&cc] = std::string(target.GetName()) + str.str(); makefileStream << "\\\n\t" << tname[&cc]; } } @@ -1327,11 +1323,10 @@ void cmGlobalXCodeGenerator for(std::vector<cmCustomCommand>::const_iterator i = commands.begin(); i != commands.end(); ++i) { - cmCustomCommand const& cc = *i; + cmCustomCommand const& cc = *i; if(!cc.GetCommandLines().empty()) { - bool escapeOldStyle = cc.GetEscapeOldStyle(); - bool escapeAllowMakeVars = cc.GetEscapeAllowMakeVars(); + cmCustomCommandGenerator ccg(cc, configName, this->CurrentMakefile); makefileStream << "\n"; const std::vector<std::string>& outputs = cc.GetOutputs(); if(!outputs.empty()) @@ -1346,15 +1341,17 @@ void cmGlobalXCodeGenerator // There are no outputs. Use the generated force rule name. makefileStream << tname[&cc] << ": "; } - for(std::vector<std::string>::const_iterator d = + for(std::vector<std::string>::const_iterator d = cc.GetDepends().begin(); d != cc.GetDepends().end(); ++d) { - std::string dep = - this->CurrentLocalGenerator->GetRealDependency(d->c_str(), - configName); - makefileStream << "\\\n" << this - ->ConvertToRelativeForMake(dep.c_str()); + std::string dep; + if(this->CurrentLocalGenerator + ->GetRealDependency(d->c_str(), configName, dep)) + { + makefileStream << "\\\n" << + this->ConvertToRelativeForMake(dep.c_str()); + } } makefileStream << "\n"; @@ -1362,20 +1359,15 @@ void cmGlobalXCodeGenerator { std::string echo_cmd = "echo "; echo_cmd += (this->CurrentLocalGenerator-> - EscapeForShell(comment, escapeAllowMakeVars)); + EscapeForShell(comment, cc.GetEscapeAllowMakeVars())); makefileStream << "\t" << echo_cmd.c_str() << "\n"; } // Add each command line to the set of commands. - for(cmCustomCommandLines::const_iterator cl = - cc.GetCommandLines().begin(); - cl != cc.GetCommandLines().end(); ++cl) + for(unsigned int c = 0; c < ccg.GetNumberOfCommands(); ++c) { // Build the command line in a single string. - const cmCustomCommandLine& commandLine = *cl; - std::string cmd2 = this->CurrentLocalGenerator - ->GetRealLocation(commandLine[0].c_str(), configName); - + std::string cmd2 = ccg.GetCommand(c); cmSystemTools::ReplaceString(cmd2, "/./", "/"); cmd2 = this->ConvertToRelativeForMake(cmd2.c_str()); std::string cmd; @@ -1386,21 +1378,7 @@ void cmGlobalXCodeGenerator cmd += " && "; } cmd += cmd2; - for(unsigned int j=1; j < commandLine.size(); ++j) - { - cmd += " "; - if(escapeOldStyle) - { - cmd += (this->CurrentLocalGenerator - ->EscapeForShellOldStyle(commandLine[j].c_str())); - } - else - { - cmd += (this->CurrentLocalGenerator-> - EscapeForShell(commandLine[j].c_str(), - escapeAllowMakeVars)); - } - } + ccg.AppendArguments(c, cmd); makefileStream << "\t" << cmd.c_str() << "\n"; } } @@ -1409,7 +1387,7 @@ void cmGlobalXCodeGenerator // Add rules to deal with multiple outputs of custom commands. if(!multipleOutputPairs.empty()) { - makefileStream << + makefileStream << "\n# Dependencies of multiple outputs to their primary outputs \n"; for(std::map<cmStdString, cmStdString>::const_iterator o = @@ -1440,6 +1418,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, std::string defFlags; bool shared = ((target.GetType() == cmTarget::SHARED_LIBRARY) || (target.GetType() == cmTarget::MODULE_LIBRARY)); + bool binary = ((target.GetType() == cmTarget::STATIC_LIBRARY) || + (target.GetType() == cmTarget::EXECUTABLE) || + shared); const char* lang = target.GetLinkerLanguage(configName); std::string cflags; @@ -1454,10 +1435,17 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // Add language-specific flags. this->CurrentLocalGenerator->AddLanguageFlags(flags, lang, configName); - + // Add shared-library flags if needed. this->CurrentLocalGenerator->AddSharedFlags(flags, lang, shared); } + else if(binary) + { + cmSystemTools::Error + ("CMake can not determine linker language for target:", + target.GetName()); + return; + } // Add define flags this->CurrentLocalGenerator-> @@ -1492,11 +1480,11 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, std::string extraLinkOptions; if(target.GetType() == cmTarget::EXECUTABLE) { - extraLinkOptions = + extraLinkOptions = this->CurrentMakefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS"); std::string var = "CMAKE_EXE_LINKER_FLAGS_"; var += cmSystemTools::UpperCase(configName); - std::string val = + std::string val = this->CurrentMakefile->GetSafeDefinition(var.c_str()); if(val.size()) { @@ -1514,8 +1502,13 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, extraLinkOptions = this->CurrentMakefile-> GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS"); } - - const char* targetLinkFlags = target.GetProperty("LINK_FLAGS"); + + const char* linkFlagsProp = "LINK_FLAGS"; + if(target.GetType() == cmTarget::STATIC_LIBRARY) + { + linkFlagsProp = "STATIC_LIBRARY_FLAGS"; + } + const char* targetLinkFlags = target.GetProperty(linkFlagsProp); if(targetLinkFlags) { extraLinkOptions += " "; @@ -1523,7 +1516,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, } if(configName && *configName) { - std::string linkFlagsVar = "LINK_FLAGS_"; + std::string linkFlagsVar = linkFlagsProp; + linkFlagsVar += "_"; linkFlagsVar += cmSystemTools::UpperCase(configName); if(const char* linkFlags = target.GetProperty(linkFlagsVar.c_str())) { @@ -1589,9 +1583,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->CreateString(pndir.c_str())); pndir = target.GetDirectory(configName); } - buildSettings->AddAttribute("EXECUTABLE_PREFIX", + buildSettings->AddAttribute("EXECUTABLE_PREFIX", this->CreateString(pnprefix.c_str())); - buildSettings->AddAttribute("EXECUTABLE_SUFFIX", + buildSettings->AddAttribute("EXECUTABLE_SUFFIX", this->CreateString(pnsuffix.c_str())); } buildSettings->AddAttribute("SYMROOT", @@ -1602,20 +1596,20 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, { case cmTarget::STATIC_LIBRARY: { - buildSettings->AddAttribute("LIBRARY_STYLE", + buildSettings->AddAttribute("LIBRARY_STYLE", this->CreateString("STATIC")); break; } - + case cmTarget::MODULE_LIBRARY: { - buildSettings->AddAttribute("LIBRARY_STYLE", + buildSettings->AddAttribute("LIBRARY_STYLE", this->CreateString("BUNDLE")); if(this->XcodeVersion >= 22) { - buildSettings->AddAttribute("MACH_O_TYPE", + buildSettings->AddAttribute("MACH_O_TYPE", this->CreateString("mh_bundle")); - buildSettings->AddAttribute("GCC_DYNAMIC_NO_PIC", + buildSettings->AddAttribute("GCC_DYNAMIC_NO_PIC", this->CreateString("NO")); // Add the flags to create an executable. std::string createFlags = @@ -1700,7 +1694,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, plist.c_str()); std::string path = this->ConvertToRelativeForXCode(plist.c_str()); - buildSettings->AddAttribute("INFOPLIST_FILE", + buildSettings->AddAttribute("INFOPLIST_FILE", this->CreateString(path.c_str())); } @@ -1711,7 +1705,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, } if(this->XcodeVersion >= 22) { - buildSettings->AddAttribute("PREBINDING", + buildSettings->AddAttribute("PREBINDING", this->CreateString("NO")); } @@ -1736,7 +1730,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, } else { - std::string incpath = + std::string incpath = this->XCodeEscapePath(i->c_str()); dirs.Add(incpath.c_str()); } @@ -1755,12 +1749,12 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, } if(!fdirs.IsEmpty()) { - buildSettings->AddAttribute("FRAMEWORK_SEARCH_PATHS", + buildSettings->AddAttribute("FRAMEWORK_SEARCH_PATHS", fdirs.CreateList()); } if(!dirs.IsEmpty()) { - buildSettings->AddAttribute("HEADER_SEARCH_PATHS", + buildSettings->AddAttribute("HEADER_SEARCH_PATHS", dirs.CreateList()); } std::string oflagc = this->ExtractFlag("-O", cflags); @@ -1802,11 +1796,11 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, if(gflagc.size() ==0 && gflag.size() == 0) { debugStr = "NO"; - } + } buildSettings->AddAttribute("GCC_GENERATE_DEBUGGING_SYMBOLS", this->CreateString(debugStr)); - buildSettings->AddAttribute("GCC_OPTIMIZATION_LEVEL", + buildSettings->AddAttribute("GCC_OPTIMIZATION_LEVEL", this->CreateString(optLevel)); buildSettings->AddAttribute("GCC_SYMBOLS_PRIVATE_EXTERN", this->CreateString("NO")); @@ -1816,11 +1810,11 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, { flags += " "; flags += defFlags; - buildSettings->AddAttribute("OTHER_CPLUSPLUSFLAGS", + buildSettings->AddAttribute("OTHER_CPLUSPLUSFLAGS", this->CreateString(flags.c_str())); cflags += " "; cflags += defFlags; - buildSettings->AddAttribute("OTHER_CFLAGS", + buildSettings->AddAttribute("OTHER_CFLAGS", this->CreateString(cflags.c_str())); } @@ -1828,7 +1822,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, { flags += " "; flags += defFlags; - buildSettings->AddAttribute("OTHER_CFLAGS", + buildSettings->AddAttribute("OTHER_CFLAGS", this->CreateString(flags.c_str())); } @@ -1856,9 +1850,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, buildSettings->AddAttribute("INSTALL_PATH", this->CreateString(install_name_dir.c_str())); - buildSettings->AddAttribute("OTHER_LDFLAGS", + buildSettings->AddAttribute("OTHER_LDFLAGS", this->CreateString(extraLinkOptions.c_str())); - buildSettings->AddAttribute("OTHER_REZFLAGS", + buildSettings->AddAttribute("OTHER_REZFLAGS", this->CreateString("")); buildSettings->AddAttribute("SECTORDER_FLAGS", this->CreateString("")); @@ -1928,12 +1922,12 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, } //---------------------------------------------------------------------------- -cmXCodeObject* +cmXCodeObject* cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) { cmXCodeObject* shellBuildPhase = this->CreateObject(cmXCodeObject::PBXShellScriptBuildPhase); - shellBuildPhase->AddAttribute("buildActionMask", + shellBuildPhase->AddAttribute("buildActionMask", this->CreateString("2147483647")); cmXCodeObject* buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST); shellBuildPhase->AddAttribute("files", buildFiles); @@ -1948,10 +1942,10 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) shellBuildPhase->AddAttribute("shellScript", this->CreateString( "# shell script goes here\nexit 0")); - cmXCodeObject* target = + cmXCodeObject* target = this->CreateObject(cmXCodeObject::PBXAggregateTarget); target->SetComment(cmtarget.GetName()); - cmXCodeObject* buildPhases = + cmXCodeObject* buildPhases = this->CreateObject(cmXCodeObject::OBJECT_LIST); std::vector<cmXCodeObject*> emptyContentVector; this->CreateCustomCommands(buildPhases, 0, 0, 0, emptyContentVector, 0, @@ -1970,7 +1964,7 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) this->CreateBuildSettings(cmtarget, buildSettings, theConfig); target->AddAttribute("buildSettings", buildSettings); } - cmXCodeObject* dependencies = + cmXCodeObject* dependencies = this->CreateObject(cmXCodeObject::OBJECT_LIST); target->AddAttribute("dependencies", dependencies); target->AddAttribute("name", this->CreateString(cmtarget.GetName())); @@ -1998,13 +1992,13 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) std::string cmGlobalXCodeGenerator::AddConfigurations(cmXCodeObject* target, cmTarget& cmtarget) { - std::string configTypes = + std::string configTypes = this->CurrentMakefile->GetRequiredDefinition("CMAKE_CONFIGURATION_TYPES"); std::vector<std::string> configVectorIn; std::vector<std::string> configVector; configVectorIn.push_back(configTypes); cmSystemTools::ExpandList(configVectorIn, configVector); - cmXCodeObject* configlist = + cmXCodeObject* configlist = this->CreateObject(cmXCodeObject::XCConfigurationList); cmXCodeObject* buildConfigurations = this->CreateObject(cmXCodeObject::OBJECT_LIST); @@ -2015,11 +2009,11 @@ std::string cmGlobalXCodeGenerator::AddConfigurations(cmXCodeObject* target, comment += cmtarget.GetName(); comment += "\""; configlist->SetComment(comment.c_str()); - target->AddAttribute("buildConfigurationList", + target->AddAttribute("buildConfigurationList", this->CreateObjectReference(configlist)); for(unsigned int i = 0; i < configVector.size(); ++i) { - cmXCodeObject* config = + cmXCodeObject* config = this->CreateObject(cmXCodeObject::XCBuildConfiguration); buildConfigurations->AddObject(config); cmXCodeObject* buildSettings = @@ -2032,9 +2026,9 @@ std::string cmGlobalXCodeGenerator::AddConfigurations(cmXCodeObject* target, } if(configVector.size()) { - configlist->AddAttribute("defaultConfigurationName", + configlist->AddAttribute("defaultConfigurationName", this->CreateString(configVector[0].c_str())); - configlist->AddAttribute("defaultConfigurationIsVisible", + configlist->AddAttribute("defaultConfigurationIsVisible", this->CreateString("0")); return configVector[0]; } @@ -2089,7 +2083,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, cmXCodeObject* buildPhases) { - cmXCodeObject* target = + cmXCodeObject* target = this->CreateObject(cmXCodeObject::PBXNativeTarget); target->AddAttribute("buildPhases", buildPhases); cmXCodeObject* buildRules = this->CreateObject(cmXCodeObject::OBJECT_LIST); @@ -2107,13 +2101,13 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, this->CreateBuildSettings(cmtarget, buildSettings, defConfig.c_str()); target->AddAttribute("buildSettings", buildSettings); } - cmXCodeObject* dependencies = + cmXCodeObject* dependencies = this->CreateObject(cmXCodeObject::OBJECT_LIST); target->AddAttribute("dependencies", dependencies); target->AddAttribute("name", this->CreateString(cmtarget.GetName())); target->AddAttribute("productName",this->CreateString(cmtarget.GetName())); - cmXCodeObject* fileRef = + cmXCodeObject* fileRef = this->CreateObject(cmXCodeObject::PBXFileReference); if(const char* fileType = this->GetTargetFileType(cmtarget)) { @@ -2125,7 +2119,7 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, fileRef->AddAttribute("sourceTree", this->CreateString("BUILT_PRODUCTS_DIR")); fileRef->SetComment(cmtarget.GetName()); - target->AddAttribute("productReference", + target->AddAttribute("productReference", this->CreateObjectReference(fileRef)); if(const char* productType = this->GetTargetProductType(cmtarget)) { @@ -2166,20 +2160,20 @@ void cmGlobalXCodeGenerator::AddDependTarget(cmXCodeObject* target, // now avoid circular references if dependTarget already // depends on target then skip it. Circular references crashes // xcode - cmXCodeObject* dependTargetDepends = + cmXCodeObject* dependTargetDepends = dependTarget->GetObject("dependencies"); if(dependTargetDepends) { if(dependTargetDepends->HasObject(target->GetPBXTargetDependency())) - { + { return; } } - + cmXCodeObject* targetdep = dependTarget->GetPBXTargetDependency(); if(!targetdep) { - cmXCodeObject* container = + cmXCodeObject* container = this->CreateObject(cmXCodeObject::PBXContainerItemProxy); container->SetComment("PBXContainerItemProxy"); container->AddAttribute("containerPortal", @@ -2187,25 +2181,25 @@ void cmGlobalXCodeGenerator::AddDependTarget(cmXCodeObject* target, container->AddAttribute("proxyType", this->CreateString("1")); container->AddAttribute("remoteGlobalIDString", this->CreateObjectReference(dependTarget)); - container->AddAttribute("remoteInfo", + container->AddAttribute("remoteInfo", this->CreateString( dependTarget->GetTarget()->GetName())); - targetdep = + targetdep = this->CreateObject(cmXCodeObject::PBXTargetDependency); targetdep->SetComment("PBXTargetDependency"); targetdep->AddAttribute("target", this->CreateObjectReference(dependTarget)); - targetdep->AddAttribute("targetProxy", + targetdep->AddAttribute("targetProxy", this->CreateObjectReference(container)); dependTarget->SetPBXTargetDependency(targetdep); } - + cmXCodeObject* depends = target->GetObject("dependencies"); if(!depends) { cmSystemTools:: Error("target does not have dependencies attribute error.."); - + } else { @@ -2253,14 +2247,14 @@ void cmGlobalXCodeGenerator { // There are multiple configurations. Add the setting to the // buildSettings of the configuration name given. - cmXCodeObject* configurationList = + cmXCodeObject* configurationList = target->GetObject("buildConfigurationList")->GetObject(); - cmXCodeObject* buildConfigs = + cmXCodeObject* buildConfigs = configurationList->GetObject("buildConfigurations"); std::vector<cmXCodeObject*> list = buildConfigs->GetObjectList(); - // each configuration and the target itself has a buildSettings in it + // each configuration and the target itself has a buildSettings in it //list.push_back(target); - for(std::vector<cmXCodeObject*>::iterator i = list.begin(); + for(std::vector<cmXCodeObject*>::iterator i = list.begin(); i != list.end(); ++i) { if(configName) @@ -2422,7 +2416,7 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, std::vector<cmSourceGroup> sourceGroups = mf->GetSourceGroups(); cmTargets &tgts = mf->GetTargets(); for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) - { + { cmTarget& cmtarget = l->second; // Same skipping logic here as in CreateXCodeTargets so that we do not @@ -2445,21 +2439,21 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, std::vector<cmSourceFile*> classes = cmtarget.GetSourceFiles(); - for(std::vector<cmSourceFile*>::const_iterator s = classes.begin(); + for(std::vector<cmSourceFile*>::const_iterator s = classes.begin(); s != classes.end(); s++) { cmSourceFile* sf = *s; // Add the file to the list of sources. std::string const& source = sf->GetFullPath(); - cmSourceGroup& sourceGroup = + cmSourceGroup& sourceGroup = mf->FindSourceGroup(source.c_str(), sourceGroups); - cmXCodeObject* pbxgroup = + cmXCodeObject* pbxgroup = this->CreateOrGetPBXGroup(cmtarget, &sourceGroup); cmStdString key = GetGroupMapKey(cmtarget, sf); this->GroupMap[key] = pbxgroup; } } - } + } } //---------------------------------------------------------------------------- @@ -2485,7 +2479,7 @@ cmXCodeObject* cmGlobalXCodeGenerator { tgroup = this->CreateObject(cmXCodeObject::PBXGroup); this->TargetGroup[cmtarget.GetName()] = tgroup; - cmXCodeObject* tgroupChildren = + cmXCodeObject* tgroupChildren = this->CreateObject(cmXCodeObject::OBJECT_LIST); tgroup->AddAttribute("name", this->CreateString(cmtarget.GetName())); tgroup->AddAttribute("children", tgroupChildren); @@ -2508,7 +2502,7 @@ cmXCodeObject* cmGlobalXCodeGenerator cmXCodeObject* tgroupChildren = tgroup->GetObject("children"); cmXCodeObject* group = this->CreateObject(cmXCodeObject::PBXGroup); - cmXCodeObject* groupChildren = + cmXCodeObject* groupChildren = this->CreateObject(cmXCodeObject::OBJECT_LIST); group->AddAttribute("name", this->CreateString(sg->GetName())); group->AddAttribute("children", groupChildren); @@ -2528,19 +2522,19 @@ void cmGlobalXCodeGenerator std::vector<cmLocalGenerator*>& generators) { - this->ClearXCodeObjects(); + this->ClearXCodeObjects(); this->RootObject = 0; this->SourcesGroupChildren = 0; this->ResourcesGroupChildren = 0; this->MainGroupChildren = 0; cmXCodeObject* group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); group->AddAttribute("COPY_PHASE_STRIP", this->CreateString("NO")); - cmXCodeObject* developBuildStyle = + cmXCodeObject* developBuildStyle = this->CreateObject(cmXCodeObject::PBXBuildStyle); cmXCodeObject* listObjs = this->CreateObject(cmXCodeObject::OBJECT_LIST); if(this->XcodeVersion == 15) { - developBuildStyle->AddAttribute("name", + developBuildStyle->AddAttribute("name", this->CreateString("Development")); developBuildStyle->AddAttribute("buildSettings", group); listObjs->AddObject(developBuildStyle); @@ -2556,7 +2550,7 @@ void cmGlobalXCodeGenerator { for(unsigned int i = 0; i < this->CurrentConfigurationTypes.size(); ++i) { - cmXCodeObject* buildStyle = + cmXCodeObject* buildStyle = this->CreateObject(cmXCodeObject::PBXBuildStyle); const char* name = this->CurrentConfigurationTypes[i].c_str(); buildStyle->AddAttribute("name", this->CreateString(name)); @@ -2570,7 +2564,7 @@ void cmGlobalXCodeGenerator } cmXCodeObject* mainGroup = this->CreateObject(cmXCodeObject::PBXGroup); - this->MainGroupChildren = + this->MainGroupChildren = this->CreateObject(cmXCodeObject::OBJECT_LIST); mainGroup->AddAttribute("children", this->MainGroupChildren); if(this->XcodeVersion == 15) @@ -2580,7 +2574,7 @@ void cmGlobalXCodeGenerator mainGroup->AddAttribute("sourceTree", this->CreateString("<group>")); cmXCodeObject* sourcesGroup = this->CreateObject(cmXCodeObject::PBXGroup); - this->SourcesGroupChildren = + this->SourcesGroupChildren = this->CreateObject(cmXCodeObject::OBJECT_LIST); sourcesGroup->AddAttribute("name", this->CreateString("Sources")); sourcesGroup->AddAttribute("children", this->SourcesGroupChildren); @@ -2603,7 +2597,7 @@ void cmGlobalXCodeGenerator resourcesGroup->AddAttribute("sourceTree", this->CreateString("<group>")); this->MainGroupChildren->AddObject(resourcesGroup); - // now create the cmake groups + // now create the cmake groups this->CreateGroups(root, generators); cmXCodeObject* productGroup = this->CreateObject(cmXCodeObject::PBXGroup); @@ -2613,16 +2607,16 @@ void cmGlobalXCodeGenerator productGroup->AddAttribute("refType", this->CreateString("4")); } productGroup->AddAttribute("sourceTree", this->CreateString("<group>")); - cmXCodeObject* productGroupChildren = + cmXCodeObject* productGroupChildren = this->CreateObject(cmXCodeObject::OBJECT_LIST); productGroup->AddAttribute("children", productGroupChildren); this->MainGroupChildren->AddObject(productGroup); - - + + this->RootObject = this->CreateObject(cmXCodeObject::PBXProject); this->RootObject->SetComment("Project object"); group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); - this->RootObject->AddAttribute("mainGroup", + this->RootObject->AddAttribute("mainGroup", this->CreateObjectReference(mainGroup)); this->RootObject->AddAttribute("buildSettings", group); this->RootObject->AddAttribute("buildStyles", listObjs); @@ -2634,7 +2628,10 @@ void cmGlobalXCodeGenerator group->AddAttribute("BuildIndependentTargetsInParallel", this->CreateString("YES")); this->RootObject->AddAttribute("attributes", group); - if (this->XcodeVersion >= 31) + if (this->XcodeVersion >= 32) + this->RootObject->AddAttribute("compatibilityVersion", + this->CreateString("Xcode 3.2")); + else if (this->XcodeVersion >= 31) this->RootObject->AddAttribute("compatibilityVersion", this->CreateString("Xcode 3.1")); else @@ -2649,18 +2646,18 @@ void cmGlobalXCodeGenerator this->CreateString(pdir.c_str())); this->RootObject->AddAttribute("projectRoot", this->CreateString("")); } - cmXCodeObject* configlist = + cmXCodeObject* configlist = this->CreateObject(cmXCodeObject::XCConfigurationList); cmXCodeObject* buildConfigurations = this->CreateObject(cmXCodeObject::OBJECT_LIST); std::vector<cmXCodeObject*> configs; if(this->XcodeVersion == 15) { - cmXCodeObject* configDebug = + cmXCodeObject* configDebug = this->CreateObject(cmXCodeObject::XCBuildConfiguration); configDebug->AddAttribute("name", this->CreateString("Debug")); configs.push_back(configDebug); - cmXCodeObject* configRelease = + cmXCodeObject* configRelease = this->CreateObject(cmXCodeObject::XCBuildConfiguration); configRelease->AddAttribute("name", this->CreateString("Release")); configs.push_back(configRelease); @@ -2670,7 +2667,7 @@ void cmGlobalXCodeGenerator for(unsigned int i = 0; i < this->CurrentConfigurationTypes.size(); ++i) { const char* name = this->CurrentConfigurationTypes[i].c_str(); - cmXCodeObject* config = + cmXCodeObject* config = this->CreateObject(cmXCodeObject::XCBuildConfiguration); config->AddAttribute("name", this->CreateString(name)); configs.push_back(config); @@ -2688,13 +2685,13 @@ void cmGlobalXCodeGenerator comment += this->CurrentProject; comment += "\""; configlist->SetComment(comment.c_str()); - configlist->AddAttribute("defaultConfigurationIsVisible", + configlist->AddAttribute("defaultConfigurationIsVisible", this->CreateString("0")); - configlist->AddAttribute("defaultConfigurationName", + configlist->AddAttribute("defaultConfigurationName", this->CreateString("Debug")); cmXCodeObject* buildSettings = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); - const char* osxArch = + const char* osxArch = this->CurrentMakefile->GetDefinition("CMAKE_OSX_ARCHITECTURES"); if(strlen(osxArch) == 0) { @@ -2719,11 +2716,11 @@ void cmGlobalXCodeGenerator this->CreateString("YES")); } - const char* sysroot = + const char* sysroot = this->CurrentMakefile->GetDefinition("CMAKE_OSX_SYSROOT"); - const char* sysrootDefault = + const char* sysrootDefault = this->CurrentMakefile->GetDefinition("CMAKE_OSX_SYSROOT_DEFAULT"); - const char* deploymentTarget = + const char* deploymentTarget = this->CurrentMakefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET"); if(osxArch && sysroot) { @@ -2733,22 +2730,24 @@ void cmGlobalXCodeGenerator cmSystemTools::ExpandListArgument(std::string(osxArch), this->Architectures); flagsUsed = true; - buildSettings->AddAttribute("SDKROOT", + buildSettings->AddAttribute("SDKROOT", this->CreateString(sysroot)); std::string archString; - for( std::vector<std::string>::iterator i = + const char* sep = ""; + for( std::vector<std::string>::iterator i = this->Architectures.begin(); i != this->Architectures.end(); ++i) { + archString += sep; archString += *i; - archString += " "; + sep = " "; } - buildSettings->AddAttribute("ARCHS", + buildSettings->AddAttribute("ARCHS", this->CreateString(archString.c_str())); if(!flagsUsed && sysrootDefault && strcmp(sysroot, sysrootDefault) != 0) { - buildSettings->AddAttribute("SDKROOT", + buildSettings->AddAttribute("SDKROOT", this->CreateString(sysroot)); } } @@ -2758,6 +2757,22 @@ void cmGlobalXCodeGenerator this->CreateString(deploymentTarget)); } + // Put this last so it can override existing settings + // Convert "CMAKE_XCODE_ATTRIBUTE_*" variables directly. + { + std::vector<std::string> vars = this->CurrentMakefile->GetDefinitions(); + for(std::vector<std::string>::const_iterator i = vars.begin(); + i != vars.end(); ++i) + { + if(i->find("CMAKE_XCODE_ATTRIBUTE_") == 0) + { + buildSettings->AddAttribute(i->substr(22).c_str(), + this->CreateString( + this->CurrentMakefile->GetDefinition(i->c_str()))); + } + } + } + std::string symroot = root->GetMakefile()->GetCurrentOutputDirectory(); symroot += "/build"; buildSettings->AddAttribute("SYMROOT", this->CreateString(symroot.c_str())); @@ -2768,7 +2783,7 @@ void cmGlobalXCodeGenerator (*i)->AddAttribute("buildSettings", buildSettings); } - this->RootObject->AddAttribute("buildConfigurationList", + this->RootObject->AddAttribute("buildConfigurationList", this->CreateObjectReference(configlist)); std::vector<cmXCodeObject*> targets; @@ -2793,7 +2808,7 @@ void cmGlobalXCodeGenerator cmXCodeObject* allTargets = this->CreateObject(cmXCodeObject::OBJECT_LIST); for(std::vector<cmXCodeObject*>::iterator i = targets.begin(); i != targets.end(); ++i) - { + { cmXCodeObject* t = *i; allTargets->AddObject(t); cmXCodeObject* productRef = t->GetObject("productReference"); @@ -2806,11 +2821,11 @@ void cmGlobalXCodeGenerator } //---------------------------------------------------------------------------- -void +void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( std::vector<cmXCodeObject*>& targets) -{ - cmGeneratedFileStream +{ + cmGeneratedFileStream makefileStream(this->CurrentXCodeHackMakefile.c_str()); if(!makefileStream) { @@ -2856,9 +2871,9 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( this->ConvertToRelativeForMake(tfull.c_str()); } } - makefileStream << "\n\n"; + makefileStream << "\n\n"; } - makefileStream + makefileStream << "# For each target create a dummy rule " "so the target does not have to exist\n"; std::set<cmStdString> emitted; @@ -2868,7 +2883,7 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( cmXCodeObject* target = *i; std::map<cmStdString, cmXCodeObject::StringVec> const& deplibs = target->GetDependLibraries(); - for(std::map<cmStdString, cmXCodeObject::StringVec>::const_iterator ci + for(std::map<cmStdString, cmXCodeObject::StringVec>::const_iterator ci = deplibs.begin(); ci != deplibs.end(); ++ci) { for(cmXCodeObject::StringVec::const_iterator d = ci->second.begin(); @@ -2876,7 +2891,7 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( { if(emitted.insert(*d).second) { - makefileStream << + makefileStream << this->ConvertToRelativeForMake(d->c_str()) << ":\n"; } } @@ -2885,10 +2900,10 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( makefileStream << "\n\n"; // Write rules to help Xcode relink things at the right time. - makefileStream << + makefileStream << "# Rules to remove targets that are older than anything to which they\n" "# link. This forces Xcode to relink the targets from scratch. It\n" - "# does not seem to check these dependencies itself.\n"; + "# does not seem to check these dependencies itself.\n"; for(std::vector<std::string>::const_iterator ct = this->CurrentConfigurationTypes.begin(); ct != this->CurrentConfigurationTypes.end(); ++ct) @@ -2909,7 +2924,7 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( { // Create a rule for this target. std::string tfull = t->GetFullPath(configName); - makefileStream << this->ConvertToRelativeForMake(tfull.c_str()) + makefileStream << this->ConvertToRelativeForMake(tfull.c_str()) << ":"; // List dependencies if any exist. @@ -2921,7 +2936,7 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( for(std::vector<cmStdString>::const_iterator d = deplibs.begin(); d != deplibs.end(); ++d) { - makefileStream << "\\\n\t" << + makefileStream << "\\\n\t" << this->ConvertToRelativeForMake(d->c_str()); } } @@ -2943,7 +2958,7 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( universal += "/"; universal += t->GetName(); universal += ".build/Objects-normal/"; - for( std::vector<std::string>::iterator arch = + for( std::vector<std::string>::iterator arch = this->Architectures.begin(); arch != this->Architectures.end(); ++arch) { @@ -2952,7 +2967,7 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( universalFile += "/"; universalFile += t->GetFullName(configName); makefileStream << "\t/bin/rm -f " - << + << this->ConvertToRelativeForMake(universalFile.c_str()) << "\n"; } @@ -2966,7 +2981,7 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( //---------------------------------------------------------------------------- void cmGlobalXCodeGenerator::OutputXCodeProject(cmLocalGenerator* root, - std::vector<cmLocalGenerator*>& + std::vector<cmLocalGenerator*>& generators) { if(generators.size() == 0) @@ -3006,7 +3021,7 @@ cmGlobalXCodeGenerator::OutputXCodeProject(cmLocalGenerator* root, } //---------------------------------------------------------------------------- -void +void cmGlobalXCodeGenerator::WriteXCodePBXProj(std::ostream& fout, cmLocalGenerator* , std::vector<cmLocalGenerator*>& ) @@ -3022,7 +3037,9 @@ cmGlobalXCodeGenerator::WriteXCodePBXProj(std::ostream& fout, cmXCodeObject::Indent(1, fout); if(this->XcodeVersion >= 21) { - if (this->XcodeVersion >= 31) + if (this->XcodeVersion >= 32) + fout << "objectVersion = 46;\n"; + else if (this->XcodeVersion >= 31) fout << "objectVersion = 45;\n"; else if (this->XcodeVersion >= 30) fout << "objectVersion = 44;\n"; @@ -3064,7 +3081,7 @@ std::string cmGlobalXCodeGenerator::ConvertToRelativeForMake(const char* p) } else { - std::string ret = + std::string ret = this->CurrentLocalGenerator-> ConvertToRelativePath(this->CurrentOutputDirectoryComponents, p); return cmSystemTools::ConvertToOutputPath(ret.c_str()); @@ -3080,7 +3097,7 @@ std::string cmGlobalXCodeGenerator::ConvertToRelativeForXCode(const char* p) } else { - std::string ret = + std::string ret = this->CurrentLocalGenerator-> ConvertToRelativePath(this->ProjectOutputDirectoryComponents, p); return cmSystemTools::ConvertToOutputPath(ret.c_str()); @@ -3120,7 +3137,7 @@ std::string cmGlobalXCodeGenerator::XCodeEscapePath(const char* p) //---------------------------------------------------------------------------- void cmGlobalXCodeGenerator:: GetTargetObjectFileDirectories(cmTarget* target, - std::vector<std::string>& + std::vector<std::string>& dirs) { std::string dir = this->CurrentMakefile->GetCurrentOutputDirectory(); @@ -3134,7 +3151,7 @@ GetTargetObjectFileDirectories(cmTarget* target, std::string dirsave = dir; if(this->Architectures.size()) { - for(std::vector<std::string>::iterator i = this->Architectures.begin(); + for(std::vector<std::string>::iterator i = this->Architectures.begin(); i != this->Architectures.end(); ++i) { dir += *i; |