diff options
author | Brad King <brad.king@kitware.com> | 2002-12-13 21:16:48 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2002-12-13 21:16:48 (GMT) |
commit | 3348131819bb30a592898631df11aaf8ad8db4d2 (patch) | |
tree | bc84549b8fd511222dfe58aae3d4613b17a85a4d /Source | |
parent | 7e824e83a9c97234f23640188c590201eeffea5d (diff) | |
download | CMake-3348131819bb30a592898631df11aaf8ad8db4d2.zip CMake-3348131819bb30a592898631df11aaf8ad8db4d2.tar.gz CMake-3348131819bb30a592898631df11aaf8ad8db4d2.tar.bz2 |
ENH: Added source file property OBJECT_DEPENDS to support generated header files included in non-generated sources.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator.cxx | 40 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator.h | 6 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio6Generator.cxx | 24 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.cxx | 42 | ||||
-rw-r--r-- | Source/cmSetSourceFilesPropertiesCommand.cxx | 13 |
5 files changed, 114 insertions, 11 deletions
diff --git a/Source/cmLocalUnixMakefileGenerator.cxx b/Source/cmLocalUnixMakefileGenerator.cxx index 5092045..cd7d67e 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<std::string> sourceAndDeps; + sourceAndDeps.push_back(sourceFile); + + // Check for extra object-file dependencies. + const char* additionalDeps = source.GetProperty("OBJECT_DEPENDS"); + if(additionalDeps) + { + std::vector<std::string> depends; + cmSystemTools::ExpandListArgument(additionalDeps, depends); + for(std::vector<std::string>::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(), @@ -2478,6 +2495,20 @@ void cmLocalUnixMakefileGenerator::OutputMakeRule(std::ostream& fout, const char* depends, const std::vector<std::string>& commands) { + std::vector<std::string> 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<std::string>& depends, + const std::vector<std::string>& commands) +{ if(!target) { cmSystemTools::Error("no target for OutputMakeRule"); @@ -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<std::string>::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 c8fcd18..7ba8598 100644 --- a/Source/cmLocalUnixMakefileGenerator.h +++ b/Source/cmLocalUnixMakefileGenerator.h @@ -163,6 +163,12 @@ protected: virtual void OutputMakeRule(std::ostream&, const char* comment, const char* target, + const std::vector<std::string>& depends, + const std::vector<std::string>& commands); + + virtual void OutputMakeRule(std::ostream&, + const char* comment, + const char* target, const char* depends, const char* command, const char* command2 = 0, diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index b90de0e..64d9c83 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<std::string> 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<std::string>::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<std::string>::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 668c9d6..963199b 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<std::string> depends; + cmSystemTools::ExpandListArgument(deps, depends); + if(!depends.empty()) + { + std::vector<std::string>::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\t<File\n"; - std::string d = cmSystemTools::ConvertToOutputPath(source.c_str()); + std::string d = this->ConvertToXMLOutputPath(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<std::string>::iterator i = configs->begin(); i != configs->end(); ++i) @@ -697,9 +718,18 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, fout << "\t\t\t\t<FileConfiguration\n" << "\t\t\t\t\tName=\"" << *i << "|Win32\">\n" << "\t\t\t\t\t<Tool\n" - << "\t\t\t\t\tName=\"VCCLCompilerTool\"\n" - << "\t\t\t\t\tAdditionalOptions=\"" - << compileFlags << "\"/>\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</FileConfiguration>\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</FileConfiguration>\n"; diff --git a/Source/cmSetSourceFilesPropertiesCommand.cxx b/Source/cmSetSourceFilesPropertiesCommand.cxx index 3933321..2164e35 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; |