cmGlobalXCodeGenerator: Simplify handling of multiple outputs

Make the multiple output pair map more local.  Generate it where we
have the current configuration available.
This commit is contained in:
Brad King 2014-03-10 15:04:38 -04:00
parent d45e7f3461
commit 9a5c554414
2 changed files with 19 additions and 34 deletions

View File

@ -1470,32 +1470,7 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase,
const & commands,
const char* name)
{
// collect multiple outputs of custom commands into a set
// which will be used for every configuration
std::map<std::string, std::string> multipleOutputPairs;
for(std::vector<cmCustomCommand>::const_iterator i = commands.begin();
i != commands.end(); ++i)
{
cmCustomCommand const& cc = *i;
if(!cc.GetCommandLines().empty())
{
const std::vector<std::string>& outputs = cc.GetOutputs();
if(!outputs.empty())
{
// If there are more than one outputs treat the
// first as the primary output and make the rest depend on it.
std::vector<std::string>::const_iterator o = outputs.begin();
std::string primaryOutput = this->ConvertToRelativeForMake(o->c_str());
for(++o; o != outputs.end(); ++o)
{
std::string currentOutput=this->ConvertToRelativeForMake(o->c_str());
multipleOutputPairs[currentOutput] = primaryOutput;
}
}
}
}
bool haveMultipleOutputPairs = false;
std::string dir = this->CurrentMakefile->GetCurrentOutputDirectory();
dir += "/CMakeScripts";
cmSystemTools::MakeDirectory(dir.c_str());
@ -1515,7 +1490,7 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase,
target,
commands,
currentConfig->c_str(),
multipleOutputPairs);
haveMultipleOutputPairs);
}
std::string cdir = this->CurrentMakefile->GetCurrentOutputDirectory();
@ -1525,7 +1500,7 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase,
makecmd += " -f ";
makecmd += this->ConvertToRelativeForMake(
(makefile+"$CONFIGURATION").c_str());
if(!multipleOutputPairs.empty())
if(haveMultipleOutputPairs)
{
makecmd += " cmake_check_multiple_outputs";
}
@ -1544,9 +1519,7 @@ void cmGlobalXCodeGenerator
std::vector<cmCustomCommand>
const & commands,
const std::string& configName,
const std::map<std::string,
std::string>& multipleOutputPairs
)
bool& haveMultipleOutputPairs)
{
std::string makefileName=makefileBasename;
if(this->XcodeVersion > 20)
@ -1569,6 +1542,7 @@ void cmGlobalXCodeGenerator
makefileStream << "all: ";
std::map<const cmCustomCommand*, std::string> tname;
int count = 0;
std::map<std::string, std::string> multipleOutputPairs;
for(std::vector<cmCustomCommand>::const_iterator i = commands.begin();
i != commands.end(); ++i)
{
@ -1584,6 +1558,16 @@ void cmGlobalXCodeGenerator
makefileStream
<< "\\\n\t" << this->ConvertToRelativeForMake(o->c_str());
}
// If there is more than one output treat the first as the
// primary output and make the rest depend on it.
std::vector<std::string>::const_iterator o = outputs.begin();
std::string primaryOutput = this->ConvertToRelativeForMake(o->c_str());
for(++o; o != outputs.end(); ++o)
{
std::string currentOutput=this->ConvertToRelativeForMake(o->c_str());
multipleOutputPairs[currentOutput] = primaryOutput;
}
}
else
{
@ -1683,6 +1667,9 @@ void cmGlobalXCodeGenerator
<< o->second << "; fi\n";
}
}
haveMultipleOutputPairs =
haveMultipleOutputPairs || !multipleOutputPairs.empty();
}
//----------------------------------------------------------------------------

View File

@ -124,9 +124,7 @@ private:
cmTarget& target,
std::vector<cmCustomCommand> const & commands,
const std::string& configName,
const std::map<std::string, std::string>&
multipleOutputPairs
);
bool& haveMultipleOutputPairs);
cmXCodeObject* FindXCodeTarget(cmTarget const*);
std::string GetOrCreateId(const std::string& name, const std::string& id);