diff options
Diffstat (limited to 'Source/cmMakefileTargetGenerator.cxx')
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 110 |
1 files changed, 21 insertions, 89 deletions
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 85e371d..067714e 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -702,7 +702,14 @@ cmMakefileTargetGenerator vars.Defines = definesString.c_str(); - bool lang_is_c_or_cxx = ((lang == "C") || (lang == "CXX")); + // At the moment, it is assumed that C, C++, and Fortran have both + // assembly and preprocessor capabilities. The same is true for the + // ability to export compile commands + bool lang_has_preprocessor = ((lang == "C") || + (lang == "CXX") || + (lang == "Fortran")); + bool const lang_has_assembly = lang_has_preprocessor; + bool const lang_can_export_cmds = lang_has_preprocessor; // Construct the compile rules. { @@ -715,7 +722,7 @@ cmMakefileTargetGenerator cmSystemTools::ExpandListArgument(compileRule, compileCommands); if (this->Makefile->IsOn("CMAKE_EXPORT_COMPILE_COMMANDS") && - lang_is_c_or_cxx && compileCommands.size() == 1) + lang_can_export_cmds && compileCommands.size() == 1) { std::string compileCommand = compileCommands[0]; this->LocalGenerator->ExpandRuleVariables(compileCommand, vars); @@ -747,33 +754,27 @@ cmMakefileTargetGenerator compileCommands.begin(), compileCommands.end()); } - // Write the rule. - this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - relativeObj, - depends, commands, false); - // Check for extra outputs created by the compilation. + std::vector<std::string> outputs(1, relativeObj); if(const char* extra_outputs_str = source.GetProperty("OBJECT_OUTPUTS")) { - std::vector<std::string> extra_outputs; - cmSystemTools::ExpandListArgument(extra_outputs_str, extra_outputs); - for(std::vector<std::string>::const_iterator eoi = extra_outputs.begin(); - eoi != extra_outputs.end(); ++eoi) + cmSystemTools::ExpandListArgument(extra_outputs_str, outputs); + for(std::vector<std::string>::const_iterator eoi = outputs.begin()+1; + eoi != outputs.end(); ++eoi) { - // Register this as an extra output for the object file rule. - // This will cause the object file to be rebuilt if the extra - // output is missing. - this->GenerateExtraOutput(eoi->c_str(), relativeObj.c_str(), false); - // Register this as an extra file to clean. this->CleanFiles.push_back(*eoi); } } - bool do_preprocess_rules = lang_is_c_or_cxx && + // Write the rule. + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, + outputs, depends, commands, false); + + bool do_preprocess_rules = lang_has_preprocessor && this->LocalGenerator->GetCreatePreprocessedSourceRules(); - bool do_assembly_rules = lang_is_c_or_cxx && + bool do_assembly_rules = lang_has_assembly && this->LocalGenerator->GetCreateAssemblySourceRules(); if(do_preprocess_rules || do_assembly_rules) { @@ -1010,25 +1011,6 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() this->LocalGenerator-> WriteDependLanguageInfo(*this->InfoFileStream,*this->Target); - // Store multiple output pairs in the depend info file. - if(!this->MultipleOutputPairs.empty()) - { - *this->InfoFileStream - << "\n" - << "# Pairs of files generated by the same build rule.\n" - << "set(CMAKE_MULTIPLE_OUTPUT_PAIRS\n"; - for(MultipleOutputPairsType::const_iterator pi = - this->MultipleOutputPairs.begin(); - pi != this->MultipleOutputPairs.end(); ++pi) - { - *this->InfoFileStream - << " " << this->LocalGenerator->EscapeForCMake(pi->first) - << " " << this->LocalGenerator->EscapeForCMake(pi->second) - << "\n"; - } - *this->InfoFileStream << " )\n\n"; - } - // Store list of targets linked directly or transitively. { *this->InfoFileStream @@ -1266,7 +1248,7 @@ void cmMakefileTargetGenerator } } this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - *o, depends, commands, + outputs, depends, commands, symbolic); // If the rule has changed make sure the output is rebuilt. @@ -1276,21 +1258,6 @@ void cmMakefileTargetGenerator } } - // Write rules to drive building any outputs beyond the first. - const char* in = o->c_str(); - for(++o; o != outputs.end(); ++o) - { - bool symbolic = false; - if(need_symbolic) - { - if(cmSourceFile* sf = this->Makefile->GetSource(*o)) - { - symbolic = sf->GetPropertyAsBool("SYMBOLIC"); - } - } - this->GenerateExtraOutput(o->c_str(), in, symbolic); - } - // Setup implicit dependency scanning. for(cmCustomCommand::ImplicitDependsList::const_iterator idi = ccg.GetCC().GetImplicitDepends().begin(); @@ -1309,32 +1276,6 @@ void cmMakefileTargetGenerator //---------------------------------------------------------------------------- void -cmMakefileTargetGenerator -::GenerateExtraOutput(const char* out, const char* in, bool symbolic) -{ - // Add a rule to build the primary output if the extra output needs - // to be created. - std::vector<std::string> commands; - std::vector<std::string> depends; - std::string emptyCommand = this->GlobalGenerator->GetEmptyRuleHackCommand(); - if(!emptyCommand.empty()) - { - commands.push_back(emptyCommand); - } - depends.push_back(in); - this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - out, depends, commands, - symbolic); - - // Register the extra output as paired with the first output so that - // the check-build-system step will remove the primary output if any - // extra outputs are missing. This forces the rule to regenerate - // all outputs. - this->AddMultipleOutputPair(out, in); -} - -//---------------------------------------------------------------------------- -void cmMakefileTargetGenerator::AppendProgress(std::vector<std::string>& commands) { this->NumberOfProgressActions++; @@ -1577,7 +1518,7 @@ std::string cmMakefileTargetGenerator::GetFrameworkFlags(std::string const& l) { std::string frameworkDir = *i; frameworkDir += "/../"; - frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str()); + frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir); emitted.insert(frameworkDir); } } @@ -1763,15 +1704,6 @@ void cmMakefileTargetGenerator::RemoveForbiddenFlags(const char* flagVar, //---------------------------------------------------------------------------- void cmMakefileTargetGenerator -::AddMultipleOutputPair(const char* depender, const char* dependee) -{ - MultipleOutputPairsType::value_type p(depender, dependee); - this->MultipleOutputPairs.insert(p); -} - -//---------------------------------------------------------------------------- -void -cmMakefileTargetGenerator ::CreateLinkScript(const char* name, std::vector<std::string> const& link_commands, std::vector<std::string>& makefile_commands, |