diff options
author | Brad King <brad.king@kitware.com> | 2015-04-13 13:06:07 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2015-04-13 13:06:07 (GMT) |
commit | e0adfe61122da9387d450e4647da26865483d680 (patch) | |
tree | a85ed63c759fa11dbed8a557c995d25cae0104ee /Source | |
parent | 1862b39868b5a0c256d0256ac7c71e52e59e7155 (diff) | |
parent | 9660a3cceae12ebb3cdc49484dcef590a12eb33c (diff) | |
download | CMake-e0adfe61122da9387d450e4647da26865483d680.zip CMake-e0adfe61122da9387d450e4647da26865483d680.tar.gz CMake-e0adfe61122da9387d450e4647da26865483d680.tar.bz2 |
Merge topic 'custom-command-multiple-outputs'
9660a3cc Makefile: Fix multiple custom command outputs with one missing
5c08e255 KWSys SystemTools: Teach Touch with !create to succeed on missing file
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 58 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.h | 3 |
2 files changed, 35 insertions, 26 deletions
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 2cd2d3e..bd9c579 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -778,7 +778,7 @@ cmMakefileTargetGenerator // Write the rule. this->WriteMakeRule(*this->BuildFileStream, 0, outputs, - depends, commands, false); + depends, commands); bool do_preprocess_rules = lang_has_preprocessor && this->LocalGenerator->GetCreatePreprocessedSourceRules(); @@ -1000,18 +1000,30 @@ void cmMakefileTargetGenerator::WriteTargetCleanRules() } //---------------------------------------------------------------------------- -void cmMakefileTargetGenerator::WriteMakeRule( +bool cmMakefileTargetGenerator::WriteMakeRule( std::ostream& os, const char* comment, const std::vector<std::string>& outputs, const std::vector<std::string>& depends, const std::vector<std::string>& commands, - bool symbolic, bool in_help) { + bool symbolic = false; if (outputs.size() == 0) { - return; + return symbolic; + } + + // Check whether we need to bother checking for a symbolic output. + bool need_symbolic = this->GlobalGenerator->GetNeedSymbolicMark(); + + // Check whether the first output is marked as symbolic. + if(need_symbolic) + { + if(cmSourceFile* sf = this->Makefile->GetSource(outputs[0])) + { + symbolic = sf->GetPropertyAsBool("SYMBOLIC"); + } } // We always attach the actual commands to the first output. @@ -1021,7 +1033,7 @@ void cmMakefileTargetGenerator::WriteMakeRule( // For single outputs, we are done. if (outputs.size() == 1) { - return; + return symbolic; } // For multiple outputs, make the extra ones depend on the first one. @@ -1034,14 +1046,25 @@ void cmMakefileTargetGenerator::WriteMakeRule( std::string const out = this->Convert(*o, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::SHELL); std::vector<std::string> output_commands; - if (!symbolic) + + bool o_symbolic = false; + if(need_symbolic) + { + if(cmSourceFile* sf = this->Makefile->GetSource(*o)) + { + o_symbolic = sf->GetPropertyAsBool("SYMBOLIC"); + } + } + symbolic = symbolic && o_symbolic; + + if (!o_symbolic) { output_commands.push_back("@$(CMAKE_COMMAND) -E touch_nocreate " + out); } this->LocalGenerator->WriteMakeRule(os, 0, *o, output_depends, - output_commands, symbolic, in_help); + output_commands, o_symbolic, in_help); - if (!symbolic) + if (!o_symbolic) { // At build time, remove the first output if this one does not exist // so that "make" will rerun the real commands that create this one. @@ -1049,6 +1072,7 @@ void cmMakefileTargetGenerator::WriteMakeRule( this->MultipleOutputPairs.insert(p); } } + return symbolic; } //---------------------------------------------------------------------------- @@ -1269,30 +1293,16 @@ void cmMakefileTargetGenerator std::vector<std::string> depends; this->LocalGenerator->AppendCustomDepend(depends, ccg); - // Check whether we need to bother checking for a symbolic output. - bool need_symbolic = this->GlobalGenerator->GetNeedSymbolicMark(); - // Write the rule. const std::vector<std::string>& outputs = ccg.GetOutputs(); - std::vector<std::string>::const_iterator o = outputs.begin(); - { - bool symbolic = false; - if(need_symbolic) - { - if(cmSourceFile* sf = this->Makefile->GetSource(*o)) - { - symbolic = sf->GetPropertyAsBool("SYMBOLIC"); - } - } - this->WriteMakeRule(*this->BuildFileStream, 0, outputs, - depends, commands, symbolic); + bool symbolic = this->WriteMakeRule(*this->BuildFileStream, 0, + outputs, depends, commands); // If the rule has changed make sure the output is rebuilt. if(!symbolic) { this->GlobalGenerator->AddRuleHash(ccg.GetOutputs(), content.str()); } - } // Setup implicit dependency scanning. for(cmCustomCommand::ImplicitDependsList::const_iterator diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 98017be..58044e8 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -224,12 +224,11 @@ protected: typedef std::map<std::string, std::string> MultipleOutputPairsType; MultipleOutputPairsType MultipleOutputPairs; - void WriteMakeRule(std::ostream& os, + bool WriteMakeRule(std::ostream& os, const char* comment, const std::vector<std::string>& outputs, const std::vector<std::string>& depends, const std::vector<std::string>& commands, - bool symbolic, bool in_help = false); // Target name info. |