From 9a5c55441418ef79415b9a1b99c35192d2b8c1b0 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 10 Mar 2014 15:04:38 -0400 Subject: cmGlobalXCodeGenerator: Simplify handling of multiple outputs Make the multiple output pair map more local. Generate it where we have the current configuration available. --- Source/cmGlobalXCodeGenerator.cxx | 49 ++++++++++++++------------------------- Source/cmGlobalXCodeGenerator.h | 4 +--- 2 files changed, 19 insertions(+), 34 deletions(-) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 16c74b9..2dd31f3 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -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 multipleOutputPairs; - for(std::vector::const_iterator i = commands.begin(); - i != commands.end(); ++i) - { - cmCustomCommand const& cc = *i; - if(!cc.GetCommandLines().empty()) - { - const std::vector& 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::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 const & commands, const std::string& configName, - const std::map& multipleOutputPairs - ) + bool& haveMultipleOutputPairs) { std::string makefileName=makefileBasename; if(this->XcodeVersion > 20) @@ -1569,6 +1542,7 @@ void cmGlobalXCodeGenerator makefileStream << "all: "; std::map tname; int count = 0; + std::map multipleOutputPairs; for(std::vector::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::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(); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 93315ba..be81cdc 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -124,9 +124,7 @@ private: cmTarget& target, std::vector const & commands, const std::string& configName, - const std::map& - multipleOutputPairs - ); + bool& haveMultipleOutputPairs); cmXCodeObject* FindXCodeTarget(cmTarget const*); std::string GetOrCreateId(const std::string& name, const std::string& id); -- cgit v0.12