Xcode: Rearrange CMakeReRun to enable parallel builds

by isolating the CMakeReRun steps to a ZERO_CHECK target, as
in the Visual Studio generators. Also, honor the value of
CMAKE_SUPPRESS_REGENERATION.
This commit is contained in:
Johan Björk 2011-07-26 23:13:42 +02:00 committed by David Cole
parent 14e54c4c44
commit 312d68d5b1
1 changed files with 23 additions and 22 deletions

View File

@ -335,6 +335,9 @@ cmGlobalXCodeGenerator::PostBuildMakeTarget(std::string const& tName,
return out; return out;
} }
//----------------------------------------------------------------------------
#define CMAKE_CHECK_BUILD_SYSTEM_TARGET "ZERO_CHECK"
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void void
cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
@ -366,8 +369,18 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
makecommand.push_back(this->CurrentXCodeHackMakefile.c_str()); makecommand.push_back(this->CurrentXCodeHackMakefile.c_str());
makecommand.push_back(""); // placeholder, see below makecommand.push_back(""); // placeholder, see below
// Add Re-Run CMake rules // Add ZERO_CHECK
this->CreateReRunCMakeFile(root, gens); 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());
}
// now make the allbuild depend on all the non-utility targets // now make the allbuild depend on all the non-utility targets
// in the project // in the project
@ -379,10 +392,17 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
{ {
continue; continue;
} }
cmTargets& tgts = lg->GetMakefile()->GetTargets(); cmTargets& tgts = lg->GetMakefile()->GetTargets();
for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++)
{ {
cmTarget& target = l->second; cmTarget& target = l->second;
if (regenerate && (l->first != CMAKE_CHECK_BUILD_SYSTEM_TARGET))
{
target.AddUtility(CMAKE_CHECK_BUILD_SYSTEM_TARGET);
}
// make all exe, shared libs and modules // make all exe, shared libs and modules
// run the depend check makefile as a post build rule // run the depend check makefile as a post build rule
// this will make sure that when the next target is built // this will make sure that when the next target is built
@ -402,8 +422,8 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
cmTarget::POST_BUILD, cmTarget::POST_BUILD,
"Depend check for xcode", "Depend check for xcode",
dir.c_str()); dir.c_str());
} }
if(!target.GetPropertyAsBool("EXCLUDE_FROM_ALL")) if(!target.GetPropertyAsBool("EXCLUDE_FROM_ALL"))
{ {
allbuild->AddUtility(target.GetName()); allbuild->AddUtility(target.GetName());
@ -1114,11 +1134,6 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases,
commands.push_back(*(*i)->GetCustomCommand()); commands.push_back(*(*i)->GetCustomCommand());
} }
} }
std::vector<cmCustomCommand> reruncom;
cmXCodeObject* cmakeReRunPhase =
this->CreateBuildPhase("CMake ReRun", "cmakeReRunPhase",
cmtarget, reruncom);
buildPhases->AddObject(cmakeReRunPhase);
// create prebuild phase // create prebuild phase
cmXCodeObject* cmakeRulesBuildPhase = cmXCodeObject* cmakeRulesBuildPhase =
this->CreateBuildPhase("CMake Rules", this->CreateBuildPhase("CMake Rules",
@ -1207,20 +1222,6 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase,
const & commands, const & commands,
const char* name) const char* name)
{ {
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;
}
// collect multiple outputs of custom commands into a set // collect multiple outputs of custom commands into a set
// which will be used for every configuration // which will be used for every configuration