diff options
author | Brad King <brad.king@kitware.com> | 2006-06-01 15:45:51 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2006-06-01 15:45:51 (GMT) |
commit | 4189370497f4f00c7a7d3ec6ba221879bfc8b58c (patch) | |
tree | 40e1ca868cd74dd3f3cb21644d7d43107183282f /Source/cmMakefileTargetGenerator.cxx | |
parent | f54d254a814ff37bf9ad5992c9646bd975822178 (diff) | |
download | CMake-4189370497f4f00c7a7d3ec6ba221879bfc8b58c.zip CMake-4189370497f4f00c7a7d3ec6ba221879bfc8b58c.tar.gz CMake-4189370497f4f00c7a7d3ec6ba221879bfc8b58c.tar.bz2 |
BUG: Custom command outputs listed explicitly as source files in a target should be generated whether or not an object file in the target needs them. This useful and makes Makefile builds more consistent with VS IDE builds.
Diffstat (limited to 'Source/cmMakefileTargetGenerator.cxx')
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 177 |
1 files changed, 111 insertions, 66 deletions
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 96700b5..5a6df64 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -99,7 +99,7 @@ void cmMakefileTargetGenerator::CreateRuleFile() } //---------------------------------------------------------------------------- -void cmMakefileTargetGenerator::WriteCustomCommandsForTarget() +void cmMakefileTargetGenerator::WriteTargetBuildRules() { // write the custom commands for this target // Look for files registered for cleaning in this directory. @@ -110,7 +110,56 @@ void cmMakefileTargetGenerator::WriteCustomCommandsForTarget() cmSystemTools::ExpandListArgument(additional_clean_files, this->CleanFiles); } - this->WriteCustomCommands(); + + // add custom commands to the clean rules? + const char* clean_no_custom = + this->Makefile->GetProperty("CLEAN_NO_CUSTOM"); + bool clean = cmSystemTools::IsOff(clean_no_custom); + + // First generate the object rule files. Save a list of all object + // files for this target. + const std::vector<cmSourceFile*>& sources = this->Target->GetSourceFiles(); + for(std::vector<cmSourceFile*>::const_iterator source = sources.begin(); + source != sources.end(); ++source) + { + if(cmCustomCommand* cc = (*source)->GetCustomCommand()) + { + this->GenerateCustomRuleFile(*cc); + if (clean) + { + const std::vector<std::string>& outputs = cc->GetOutputs(); + for(std::vector<std::string>::const_iterator o = outputs.begin(); + o != outputs.end(); ++o) + { + this->CleanFiles.push_back + (this->Convert(o->c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::UNCHANGED)); + } + } + } + else if(!(*source)->GetPropertyAsBool("HEADER_FILE_ONLY")) + { + if(!this->GlobalGenerator->IgnoreFile + ((*source)->GetSourceExtension().c_str())) + { + // Generate this object file's rule file. + this->WriteObjectRuleFiles(*(*source)); + } + else if((*source)->GetPropertyAsBool("EXTERNAL_OBJECT")) + { + // This is an external object file. Just add it. + this->ExternalObjects.push_back((*source)->GetFullPath()); + } + else + { + // We only get here if a source file is not an external object + // and has an extension that is listed as an ignored file type + // for this language. No message or diagnosis should be + // given. + } + } + } } @@ -159,37 +208,11 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules() cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE) << "\n\n"; - - // First generate the object rule files. Save a list of all object - // files for this target. - const std::vector<cmSourceFile*>& sources = this->Target->GetSourceFiles(); - for(std::vector<cmSourceFile*>::const_iterator source = sources.begin(); - source != sources.end(); ++source) - { - if(!(*source)->GetPropertyAsBool("HEADER_FILE_ONLY") && - !(*source)->GetCustomCommand()) - { - if(!this->GlobalGenerator->IgnoreFile - ((*source)->GetSourceExtension().c_str())) - { - // Generate this object file's rule file. - this->WriteObjectRuleFiles(*(*source)); - } - else if((*source)->GetPropertyAsBool("EXTERNAL_OBJECT")) - { - // This is an external object file. Just add it. - this->ExternalObjects.push_back((*source)->GetFullPath()); - } - else - { - // We only get here if a source file is not an external object - // and has an extension that is listed as an ignored file type - // for this language. No message or diagnosis should be - // given. - } - } - } - +} + +//---------------------------------------------------------------------------- +void cmMakefileTargetGenerator::WriteTargetLanguageFlags() +{ // write language flags for target std::map<cmStdString,cmLocalUnixMakefileGenerator3::IntegrityCheckSet>& checkSet = @@ -654,39 +677,6 @@ void cmMakefileTargetGenerator } //---------------------------------------------------------------------------- -void cmMakefileTargetGenerator::WriteCustomCommands() -{ - // add custom commands to the clean rules? - const char* clean_no_custom = - this->Makefile->GetProperty("CLEAN_NO_CUSTOM"); - bool clean = cmSystemTools::IsOff(clean_no_custom); - - // Generate the rule files for each custom command. - const std::vector<cmSourceFile*> &classes = - this->Makefile->GetSourceFiles(); - for(std::vector<cmSourceFile*>::const_iterator i = classes.begin(); - i != classes.end(); i++) - { - if(cmCustomCommand* cc = (*i)->GetCustomCommand()) - { - this->GenerateCustomRuleFile(*cc); - if (clean) - { - const std::vector<std::string>& outputs = cc->GetOutputs(); - for(std::vector<std::string>::const_iterator o = outputs.begin(); - o != outputs.end(); ++o) - { - this->CleanFiles.push_back - (this->Convert(o->c_str(), - cmLocalGenerator::START_OUTPUT, - cmLocalGenerator::UNCHANGED)); - } - } - } - } -} - -//---------------------------------------------------------------------------- void cmMakefileTargetGenerator ::GenerateCustomRuleFile(const cmCustomCommand& cc) { @@ -815,6 +805,61 @@ cmMakefileTargetGenerator *this->BuildFileStream << "\n" << "\n"; } +//---------------------------------------------------------------------------- +void cmMakefileTargetGenerator::WriteTargetDriverRule(const char* main_output, + bool relink) +{ + // Compute the name of the driver target. + std::string dir = this->Makefile->GetStartOutputDirectory(); + dir += "/"; + dir += this->LocalGenerator->GetTargetDirectory(*this->Target); + std::string buildTargetRuleName = dir; + buildTargetRuleName += relink?"/preinstall":"/build"; + buildTargetRuleName = this->Convert(buildTargetRuleName.c_str(), + cmLocalGenerator::HOME_OUTPUT, + cmLocalGenerator::MAKEFILE); + + // Build the list of target outputs to drive. + std::vector<std::string> depends; + if(main_output) + { + depends.push_back(main_output); + } + + const char* comment = 0; + if(relink) + { + // Setup the comment for the preinstall driver. + comment = "Rule to relink during preinstall."; + } + else + { + // Setup the comment for the main build driver. + comment = "Rule to build all files generated by this target."; + + // Make sure all custom command outputs in this target are built. + const std::vector<cmSourceFile*>& sources = this->Target->GetSourceFiles(); + for(std::vector<cmSourceFile*>::const_iterator source = sources.begin(); + source != sources.end(); ++source) + { + if(cmCustomCommand* cc = (*source)->GetCustomCommand()) + { + const std::vector<std::string>& outputs = cc->GetOutputs(); + for(std::vector<std::string>::const_iterator o = outputs.begin(); + o != outputs.end(); ++o) + { + depends.push_back(*o); + } + } + } + } + + // Write the driver rule. + std::vector<std::string> no_commands; + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, comment, + buildTargetRuleName.c_str(), + depends, no_commands, true); +} //---------------------------------------------------------------------------- std::string cmMakefileTargetGenerator::GetFrameworkFlags() |