diff options
author | Brad King <brad.king@kitware.com> | 2006-04-11 15:06:19 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2006-04-11 15:06:19 (GMT) |
commit | d5719f22c1dca3e100f1e3b5dfaa4fe7d26796a0 (patch) | |
tree | 714a99bed97290f96ff8f846fa6864cebbdc0a28 /Source/cmLocalVisualStudio7Generator.cxx | |
parent | b613cf0be806cc1d37d2b590f1a5ba7898236ae8 (diff) | |
download | CMake-d5719f22c1dca3e100f1e3b5dfaa4fe7d26796a0.zip CMake-d5719f22c1dca3e100f1e3b5dfaa4fe7d26796a0.tar.gz CMake-d5719f22c1dca3e100f1e3b5dfaa4fe7d26796a0.tar.bz2 |
ENH: Added support for multiple outputs generated by a single custom command. For Visual Studio generators the native tool provides support. For Xcode and Makefile generators a simple trick is used. The first output is considered primary and has the build rule attached. Other outputs simply depend on the first output with no build rule. During cmake_check_build_system CMake detects when a secondary output is missing and removes the primary output to make sure all outputs are regenerated. This approach always builds the custom command at the right time and only once even during parallel builds.
Diffstat (limited to 'Source/cmLocalVisualStudio7Generator.cxx')
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.cxx | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 55b80ef..3c9942f 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -170,6 +170,8 @@ void cmLocalVisualStudio7Generator::AddVCProjBuildRule(cmTarget& tgt) std::string makefileIn = this->Makefile->GetStartDirectory(); makefileIn += "/"; makefileIn += "CMakeLists.txt"; + std::string comment = "Building Custom Rule "; + comment += makefileIn; std::string args; args = "-H"; args += @@ -202,9 +204,10 @@ void cmLocalVisualStudio7Generator::AddVCProjBuildRule(cmTarget& tgt) cmCustomCommandLines commandLines; commandLines.push_back(commandLine); const char* no_working_directory = 0; - const char* no_comment = 0; - this->Makefile->AddCustomCommandToOutput(dspname.c_str(), listFiles, makefileIn.c_str(), - commandLines, no_comment, no_working_directory, true); + this->Makefile->AddCustomCommandToOutput(dspname.c_str(), listFiles, + makefileIn.c_str(), commandLines, + comment.c_str(), + no_working_directory, true); if(cmSourceFile* file = this->Makefile->GetSource(makefileIn.c_str())) { tgt.GetSourceFiles().push_back(file); @@ -1024,12 +1027,11 @@ void cmLocalVisualStudio7Generator::WriteGroup(const cmSourceGroup *sg, cmTarget // Construct the entire set of commands in one string. std::string script = this->ConstructScript(command->GetCommandLines(), command->GetWorkingDirectory()); - const char* comment = command->GetComment(); + std::string comment = this->ConstructComment(*command); const char* flags = compileFlags.size() ? compileFlags.c_str(): 0; this->WriteCustomRule(fout, source.c_str(), script.c_str(), - (*comment?comment:"Custom Rule"), - command->GetDepends(), - command->GetOutput(), flags); + comment.c_str(), command->GetDepends(), + command->GetOutputs(), flags); } else if(compileFlags.size() || additionalDeps.length()) { @@ -1093,9 +1095,10 @@ WriteCustomRule(std::ostream& fout, const char* command, const char* comment, const std::vector<std::string>& depends, - const char *output, + const std::vector<std::string>& outputs, const char* compileFlags) { + // Write the rule for each configuration. std::vector<std::string>::iterator i; std::vector<std::string> *configs = static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator)->GetConfigurations(); @@ -1112,11 +1115,8 @@ WriteCustomRule(std::ostream& fout, } fout << "\t\t\t\t\t<Tool\n" << "\t\t\t\t\tName=\"VCCustomBuildTool\"\n" - << "\t\t\t\t\tDescription=\"Building " << comment; - fout << " " << output; - fout << "\"\n" - << "\t\t\t\t\tCommandLine=\"" - << this->EscapeForXML(command) << "\"\n" + << "\t\t\t\t\tDescription=\"" << this->EscapeForXML(comment) << "\"\n" + << "\t\t\t\t\tCommandLine=\"" << this->EscapeForXML(command) << "\"\n" << "\t\t\t\t\tAdditionalDependencies=\""; // Write out the dependencies for the rule. std::string temp; @@ -1130,13 +1130,21 @@ WriteCustomRule(std::ostream& fout, } fout << "\"\n"; fout << "\t\t\t\t\tOutputs=\""; - if(output == 0) + if(outputs.empty()) { fout << source << "_force"; } - - // Write a rule for the output generated by this command. - fout << this->ConvertToXMLOutputPathSingle(output); + else + { + // Write a rule for the output generated by this command. + const char* sep = ""; + for(std::vector<std::string>::const_iterator o = outputs.begin(); + o != outputs.end(); ++o) + { + fout << sep << this->ConvertToXMLOutputPathSingle(o->c_str()); + sep = ";"; + } + } fout << "\"/>\n"; fout << "\t\t\t\t</FileConfiguration>\n"; } |