diff options
author | Brad King <brad.king@kitware.com> | 2006-08-08 03:25:21 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2006-08-08 03:25:21 (GMT) |
commit | 5cfa1b02ab48abe10f323846d9b8886946ac1954 (patch) | |
tree | 8d0e5946700af682216cbea3fb6e4538589598dc /Source/cmMakefileTargetGenerator.cxx | |
parent | accf93fc12071b603de40a00d059a2bbbe7f2fe2 (diff) | |
download | CMake-5cfa1b02ab48abe10f323846d9b8886946ac1954.zip CMake-5cfa1b02ab48abe10f323846d9b8886946ac1954.tar.gz CMake-5cfa1b02ab48abe10f323846d9b8886946ac1954.tar.bz2 |
ENH: Added generation of rules to manually request preprocessed or generated assembly sources.
Diffstat (limited to 'Source/cmMakefileTargetGenerator.cxx')
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index cadd0cb..c85a981 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -495,6 +495,104 @@ cmMakefileTargetGenerator relativeObj.c_str(), depends, commands, false); + bool do_preprocess_rules = + this->LocalGenerator->GetCreatePreprocessedSourceRules(); + bool do_assembly_rules = + this->LocalGenerator->GetCreateAssemblySourceRules(); + if(do_preprocess_rules || do_assembly_rules) + { + std::vector<std::string> force_depends; + force_depends.push_back("cmake_force"); + std::string::size_type dot_pos = relativeObj.rfind("."); + std::string relativeObjBase = relativeObj.substr(0, dot_pos); + + if(do_preprocess_rules) + { + commands.clear(); + std::string relativeObjE = relativeObjBase + ".E"; + + std::string preprocessEcho = "Preprocessing "; + preprocessEcho += lang; + preprocessEcho += " source to "; + preprocessEcho += relativeObjE; + this->LocalGenerator->AppendEcho( + commands, preprocessEcho.c_str(), + cmLocalUnixMakefileGenerator3::EchoBuild + ); + + std::string preprocessRuleVar = "CMAKE_"; + preprocessRuleVar += lang; + preprocessRuleVar += "_CREATE_PREPROCESSED_SOURCE"; + if(const char* preprocessRule = + this->Makefile->GetDefinition(preprocessRuleVar.c_str())) + { + cmSystemTools::ExpandListArgument(preprocessRule, commands); + + vars.PreprocessedSource = relativeObjE.c_str(); + + // Expand placeholders in the commands. + for(std::vector<std::string>::iterator i = commands.begin(); + i != commands.end(); ++i) + { + this->LocalGenerator->ExpandRuleVariables(*i, vars); + } + } + else + { + std::string cmd = "$(CMAKE_COMMAND) -E cmake_unimplemented_variable "; + cmd += preprocessRuleVar; + commands.push_back(cmd); + } + + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, + relativeObjE.c_str(), + force_depends, commands, false); + } + + if(do_assembly_rules) + { + commands.clear(); + std::string relativeObjS = relativeObjBase + ".S"; + + std::string assemblyEcho = "Compiling "; + assemblyEcho += lang; + assemblyEcho += " source to assembly "; + assemblyEcho += relativeObjS; + this->LocalGenerator->AppendEcho( + commands, assemblyEcho.c_str(), + cmLocalUnixMakefileGenerator3::EchoBuild + ); + + std::string assemblyRuleVar = "CMAKE_"; + assemblyRuleVar += lang; + assemblyRuleVar += "_CREATE_ASSEMBLY_SOURCE"; + if(const char* assemblyRule = + this->Makefile->GetDefinition(assemblyRuleVar.c_str())) + { + cmSystemTools::ExpandListArgument(assemblyRule, commands); + + vars.AssemblySource = relativeObjS.c_str(); + + // Expand placeholders in the commands. + for(std::vector<std::string>::iterator i = commands.begin(); + i != commands.end(); ++i) + { + this->LocalGenerator->ExpandRuleVariables(*i, vars); + } + } + else + { + std::string cmd = "$(CMAKE_COMMAND) -E cmake_unimplemented_variable "; + cmd += assemblyRuleVar; + commands.push_back(cmd); + } + + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, + relativeObjS.c_str(), + force_depends, commands, false); + } + } + // If the language needs provides-requires mode, create the // corresponding targets. std::string objectRequires = relativeObj; |