From 3348131819bb30a592898631df11aaf8ad8db4d2 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 13 Dec 2002 16:16:48 -0500 Subject: [PATCH] ENH: Added source file property OBJECT_DEPENDS to support generated header files included in non-generated sources. --- Source/cmLocalUnixMakefileGenerator.cxx | 40 +++++++++++++++++-- Source/cmLocalUnixMakefileGenerator.h | 6 +++ Source/cmLocalVisualStudio6Generator.cxx | 24 ++++++++++- Source/cmLocalVisualStudio7Generator.cxx | 42 +++++++++++++++++--- Source/cmSetSourceFilesPropertiesCommand.cxx | 13 ++++++ 5 files changed, 114 insertions(+), 11 deletions(-) diff --git a/Source/cmLocalUnixMakefileGenerator.cxx b/Source/cmLocalUnixMakefileGenerator.cxx index 5092045cc..cd7d67e31 100644 --- a/Source/cmLocalUnixMakefileGenerator.cxx +++ b/Source/cmLocalUnixMakefileGenerator.cxx @@ -2351,6 +2351,23 @@ OutputBuildObjectFromSource(std::ostream& fout, objectFile.c_str(), flags.c_str()); } + + std::vector sourceAndDeps; + sourceAndDeps.push_back(sourceFile); + + // Check for extra object-file dependencies. + const char* additionalDeps = source.GetProperty("OBJECT_DEPENDS"); + if(additionalDeps) + { + std::vector depends; + cmSystemTools::ExpandListArgument(additionalDeps, depends); + for(std::vector::iterator i = depends.begin(); + i != depends.end(); ++i) + { + sourceAndDeps.push_back(cmSystemTools::ConvertToOutputPath(i->c_str())); + } + } + this->OutputMakeRule(fout, comment.c_str(), objectFile.c_str(), @@ -2477,6 +2494,20 @@ void cmLocalUnixMakefileGenerator::OutputMakeRule(std::ostream& fout, const char* target, const char* depends, const std::vector& commands) +{ + std::vector depend; + if(depends) + { + depend.push_back(depends); + } + this->OutputMakeRule(fout, comment, target, depend, commands); +} + +void cmLocalUnixMakefileGenerator::OutputMakeRule(std::ostream& fout, + const char* comment, + const char* target, + const std::vector& depends, + const std::vector& commands) { if(!target) { @@ -2497,13 +2528,14 @@ void cmLocalUnixMakefileGenerator::OutputMakeRule(std::ostream& fout, replace = target; m_Makefile->ExpandVariablesInString(replace); - fout << cmSystemTools::ConvertToOutputPath(replace.c_str()) << ": "; + fout << cmSystemTools::ConvertToOutputPath(replace.c_str()) << ":"; - if(depends) + for(std::vector::const_iterator dep = depends.begin(); + dep != depends.end(); ++dep) { - replace = depends; + replace = *dep; m_Makefile->ExpandVariablesInString(replace); - fout << replace.c_str(); + fout << " " << replace.c_str(); } fout << "\n"; int count = 0; diff --git a/Source/cmLocalUnixMakefileGenerator.h b/Source/cmLocalUnixMakefileGenerator.h index c8fcd1802..7ba859887 100644 --- a/Source/cmLocalUnixMakefileGenerator.h +++ b/Source/cmLocalUnixMakefileGenerator.h @@ -160,6 +160,12 @@ protected: const char* depends, const std::vector& commands); + virtual void OutputMakeRule(std::ostream&, + const char* comment, + const char* target, + const std::vector& depends, + const std::vector& commands); + virtual void OutputMakeRule(std::ostream&, const char* comment, const char* target, diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index b90de0eb5..64d9c83e1 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -280,10 +280,20 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, { std::string source = cc->first; const cmSourceGroup::Commands& commands = cc->second.m_Commands; + std::vector depends; const char* compileFlags = 0; if(cc->second.m_SourceFile) { + // Check for extra compiler flags. compileFlags = cc->second.m_SourceFile->GetProperty("COMPILE_FLAGS"); + + // Check for extra object-file dependencies. + const char* dependsValue = + cc->second.m_SourceFile->GetProperty("OBJECT_DEPENDS"); + if(dependsValue) + { + cmSystemTools::ExpandListArgument(dependsValue, depends); + } } if (source != libName || target.GetType() == cmTarget::UTILITY) { @@ -293,6 +303,18 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, // build it, then it will. fout << "SOURCE=" << cmSystemTools::ConvertToOutputPath(source.c_str()) << "\n\n"; + if(!depends.empty()) + { + // Write out the dependencies for the rule. + fout << "USERDEP__HACK="; + for(std::vector::const_iterator d = depends.begin(); + d != depends.end(); ++d) + { + fout << "\\\n\t" << + cmSystemTools::ConvertToOutputPath(d->c_str()); + } + fout << "\n"; + } if (!commands.empty()) { cmSourceGroup::CommandFiles totalCommand; @@ -385,7 +407,7 @@ void cmLocalVisualStudio6Generator::WriteCustomRule(std::ostream& fout, for(std::set::const_iterator output = outputs.begin(); output != outputs.end(); ++output) { - fout << "\"" << output->c_str() + fout << "\"" << cmSystemTools::ConvertToOutputPath(output->c_str()) << "\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\""; fout << command << "\n\n"; } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 668c9d6bd..963199b23 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -664,14 +664,35 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, std::string source = cc->first; const cmSourceGroup::Commands& commands = cc->second.m_Commands; const char* compileFlags = 0; + std::string additionalDeps; if(cc->second.m_SourceFile) { + // Check for extra compiler flags. compileFlags = cc->second.m_SourceFile->GetProperty("COMPILE_FLAGS"); + + // Check for extra object-file dependencies. + const char* deps = + cc->second.m_SourceFile->GetProperty("OBJECT_DEPENDS"); + if(deps) + { + std::vector depends; + cmSystemTools::ExpandListArgument(deps, depends); + if(!depends.empty()) + { + std::vector::iterator i = depends.begin(); + additionalDeps = this->ConvertToXMLOutputPath(i->c_str()); + for(++i;i != depends.end(); ++i) + { + additionalDeps += ";"; + additionalDeps += this->ConvertToXMLOutputPath(i->c_str()); + } + } + } } if (source != libName || target.GetType() == cmTarget::UTILITY) { fout << "\t\t\tConvertToXMLOutputPath(source.c_str()); // remove double quotes from the string cmSystemTools::ReplaceString(d, "\"", ""); // Tell MS-Dev what the source is. If the compiler knows how to @@ -689,7 +710,7 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, totalCommand.m_Depends, totalCommand.m_Outputs, compileFlags); } - else if(compileFlags) + else if(compileFlags || additionalDeps.length()) { for(std::vector::iterator i = configs->begin(); i != configs->end(); ++i) @@ -697,9 +718,18 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, fout << "\t\t\t\t\n" << "\t\t\t\t\t\n" + << "\t\t\t\t\tName=\"VCCLCompilerTool\"\n"; + if(compileFlags) + { + fout << "\t\t\t\t\tAdditionalOptions=\"" + << compileFlags << "\"\n"; + } + if(additionalDeps.length()) + { + fout << "\t\t\t\t\tAdditionalDependencies=\"" + << additionalDeps.c_str() << "\"\n"; + } + fout << "\t\t\t\t\t/>\n" << "\t\t\t\t\n"; } } @@ -783,7 +813,7 @@ void cmLocalVisualStudio7Generator::WriteCustomRule(std::ostream& fout, { first = false; } - fout << output->c_str(); + fout << this->ConvertToXMLOutputPath(output->c_str()); } fout << "\"/>\n"; fout << "\t\t\t\t\n"; diff --git a/Source/cmSetSourceFilesPropertiesCommand.cxx b/Source/cmSetSourceFilesPropertiesCommand.cxx index 393332114..2164e35f3 100644 --- a/Source/cmSetSourceFilesPropertiesCommand.cxx +++ b/Source/cmSetSourceFilesPropertiesCommand.cxx @@ -64,6 +64,19 @@ bool cmSetSourceFilesPropertiesCommand::InitialPass( } propertyPairs.push_back(*j); } + else if(*j == "OBJECT_DEPENDS") + { + doingFiles = false; + propertyPairs.push_back("OBJECT_DEPENDS"); + ++j; + if(j == args.end()) + { + this->SetError("called with incorrect number of arguments " + "OBJECT_DEPENDS with no dependencies"); + return false; + } + propertyPairs.push_back(*j); + } else if(*j == "PROPERTIES") { doingFiles = false;