diff options
author | Brad King <brad.king@kitware.com> | 2014-11-10 15:43:08 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2014-11-10 15:43:08 (GMT) |
commit | a1f964ef6897343cd47f904b7cf7ad94b2b65e70 (patch) | |
tree | 1ae7ea93267d9ce8d93876d12c52a6f0830bcf5d /Source | |
parent | 742e6f8f06a635bbc0cb10a36ce68d5b9987f1f5 (diff) | |
parent | b6b37e303786e48c305cb83011ce5fa6cf71e359 (diff) | |
download | CMake-a1f964ef6897343cd47f904b7cf7ad94b2b65e70.zip CMake-a1f964ef6897343cd47f904b7cf7ad94b2b65e70.tar.gz CMake-a1f964ef6897343cd47f904b7cf7ad94b2b65e70.tar.bz2 |
Merge topic 'make-fortran-preprocessor-assembly-targets'
b6b37e30 Makefile: Add assembly and preprocessed targets for Fortran
0842b084 Makefile: Refactor checks for lang-specific targets and export compile cmds
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.cxx | 43 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 15 |
2 files changed, 36 insertions, 22 deletions
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index c18e027..ff8ba8b 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -315,36 +315,43 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile() // Check whether preprocessing and assembly rules make sense. // They make sense only for C and C++ sources. - bool lang_is_c_or_cxx = false; + bool lang_has_preprocessor = false; + bool lang_has_assembly = false; + for(std::vector<LocalObjectEntry>::const_iterator ei = lo->second.begin(); ei != lo->second.end(); ++ei) { - if(ei->Language == "C" || ei->Language == "CXX") + if(ei->Language == "C" || + ei->Language == "CXX" || + ei->Language == "Fortran") { - lang_is_c_or_cxx = true; + // Right now, C, C++ and Fortran have both a preprocessor and the + // ability to generate assembly code + lang_has_preprocessor = true; + lang_has_assembly = true; break; } } // Add convenience rules for preprocessed and assembly files. - if(lang_is_c_or_cxx && (do_preprocess_rules || do_assembly_rules)) + if(lang_has_preprocessor && do_preprocess_rules) { std::string::size_type dot_pos = lo->first.rfind("."); std::string base = lo->first.substr(0, dot_pos); - if(do_preprocess_rules) - { - this->WriteObjectConvenienceRule( - ruleFileStream, "target to preprocess a source file", - (base + ".i").c_str(), lo->second); - lo->second.HasPreprocessRule = true; - } - if(do_assembly_rules) - { - this->WriteObjectConvenienceRule( - ruleFileStream, "target to generate assembly for a file", - (base + ".s").c_str(), lo->second); - lo->second.HasAssembleRule = true; - } + this->WriteObjectConvenienceRule( + ruleFileStream, "target to preprocess a source file", + (base + ".i").c_str(), lo->second); + lo->second.HasPreprocessRule = true; + } + + if(lang_has_assembly && do_assembly_rules) + { + std::string::size_type dot_pos = lo->first.rfind("."); + std::string base = lo->first.substr(0, dot_pos); + this->WriteObjectConvenienceRule( + ruleFileStream, "target to generate assembly for a file", + (base + ".s").c_str(), lo->second); + lo->second.HasAssembleRule = true; } } diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 1adcb8a..1e01f11 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); @@ -771,9 +778,9 @@ cmMakefileTargetGenerator } } - bool do_preprocess_rules = lang_is_c_or_cxx && + 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) { |