diff options
author | Alexander Neundorf <neundorf@kde.org> | 2007-05-09 12:25:45 (GMT) |
---|---|---|
committer | Alexander Neundorf <neundorf@kde.org> | 2007-05-09 12:25:45 (GMT) |
commit | 7f11536704d9f971cf5c8b0a2b490ccc6af58588 (patch) | |
tree | 05b5b24050a629bf9ceb59d743f77ca909448229 /Source/cmLocalVisualStudio6Generator.cxx | |
parent | 5af310502142252995ad5d74e66355be4094b7cc (diff) | |
download | CMake-7f11536704d9f971cf5c8b0a2b490ccc6af58588.zip CMake-7f11536704d9f971cf5c8b0a2b490ccc6af58588.tar.gz CMake-7f11536704d9f971cf5c8b0a2b490ccc6af58588.tar.bz2 |
ENH: now target names can be used in add_custom_command() and
add_custom_target() as COMMAND, and cmake will recognize them and replace
them with the actual output path of these executables. Also the dependency
will be added automatically. Test included.
ENH: moved TraceVSDependencies() to the end of GlobalGenerator::Configure(),
so it is done now in one central place
Alex
Diffstat (limited to 'Source/cmLocalVisualStudio6Generator.cxx')
-rw-r--r-- | Source/cmLocalVisualStudio6Generator.cxx | 96 |
1 files changed, 54 insertions, 42 deletions
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 24a381a..b3ae6e2 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -116,16 +116,6 @@ void cmLocalVisualStudio6Generator::OutputDSPFile() { this->AddDSPBuildRule(l->second); } - - // INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace - // so don't build a projectfile for it - if ((l->second.GetType() != cmTarget::INSTALL_FILES) - && (l->second.GetType() != cmTarget::INSTALL_PROGRAMS) - && (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) != 0)) - { - cmTarget& target = l->second; - target.TraceVSDependencies(target.GetName(), this->Makefile); - } } // build any targets @@ -490,23 +480,8 @@ void cmLocalVisualStudio6Generator } if (command) { - std::string script = - this->ConstructScript(command->GetCommandLines(), - command->GetWorkingDirectory(), - command->GetEscapeOldStyle(), - command->GetEscapeAllowMakeVars(), - "\\\n\t"); - std::string comment = - this->ConstructComment(*command, - "Building Custom Rule $(InputPath)"); - if(comment == "<hack>") - { - comment = ""; - } const char* flags = compileFlags.size() ? compileFlags.c_str(): 0; - this->WriteCustomRule(fout, source.c_str(), script.c_str(), - comment.c_str(), command->GetDepends(), - command->GetOutputs(), flags); + this->WriteCustomRule(fout, source.c_str(), *command, flags); } else if(!compileFlags.empty() || !objectNameDir.empty()) { @@ -603,16 +578,29 @@ void cmLocalVisualStudio6Generator ::WriteCustomRule(std::ostream& fout, const char* source, - const char* command, - const char* comment, - const std::vector<std::string>& depends, - const std::vector<std::string>& outputs, + const cmCustomCommand& command, const char* flags) { + std::string comment = + this->ConstructComment(command, "Building Custom Rule $(InputPath)"); + if(comment == "<hack>") + { + comment = ""; + } + // Write the rule for each configuration. std::vector<std::string>::iterator i; for(i = this->Configurations.begin(); i != this->Configurations.end(); ++i) { + + std::string script = + this->ConstructScript(command.GetCommandLines(), + command.GetWorkingDirectory(), + i->c_str(), + command.GetEscapeOldStyle(), + command.GetEscapeAllowMakeVars(), + "\\\n\t"); + if (i == this->Configurations.begin()) { fout << "!IF \"$(CFG)\" == " << i->c_str() << std::endl; @@ -627,8 +615,9 @@ cmLocalVisualStudio6Generator } // Write out the dependencies for the rule. fout << "USERDEP__HACK="; - for(std::vector<std::string>::const_iterator d = depends.begin(); - d != depends.end(); ++d) + for(std::vector<std::string>::const_iterator d=command.GetDepends().begin(); + d != command.GetDepends().end(); + ++d) { // Lookup the real name of the dependency in case it is a CMake target. std::string dep = this->GetRealDependency(d->c_str(), i->c_str()); @@ -639,26 +628,28 @@ cmLocalVisualStudio6Generator fout << "# PROP Ignore_Default_Tool 1\n"; fout << "# Begin Custom Build -"; - if(comment && *comment) + if(!comment.empty()) { - fout << " " << comment; + fout << " " << comment.c_str(); } fout << "\n\n"; - if(outputs.empty()) + if(command.GetOutputs().empty()) { fout << source << "_force : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"\n\t"; - fout << command << "\n\n"; + fout << script.c_str() << "\n\n"; } else { - for(std::vector<std::string>::const_iterator o = outputs.begin(); - o != outputs.end(); ++o) + for(std::vector<std::string>::const_iterator o = + command.GetOutputs().begin(); + o != command.GetOutputs().end(); + ++o) { // Write a rule for every output generated by this command. fout << this->ConvertToOptionallyRelativeOutputPath(o->c_str()) << " : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"\n\t"; - fout << command << "\n\n"; + fout << script.c_str() << "\n\n"; } } fout << "# End Custom Build\n\n"; @@ -768,6 +759,7 @@ void cmLocalVisualStudio6Generator::SetBuildType(BuildType b, // look for custom rules on a target and collect them together std::string cmLocalVisualStudio6Generator::CreateTargetRules(cmTarget &target, + const char* configName, const char * /* libName */) { std::string customRuleCode = ""; @@ -808,6 +800,7 @@ cmLocalVisualStudio6Generator::CreateTargetRules(cmTarget &target, } customRuleCode += this->ConstructScript(cr->GetCommandLines(), cr->GetWorkingDirectory(), + configName, cr->GetEscapeOldStyle(), cr->GetEscapeAllowMakeVars(), "\\\n\t"); @@ -822,6 +815,7 @@ cmLocalVisualStudio6Generator::CreateTargetRules(cmTarget &target, } customRuleCode += this->ConstructScript(cr->GetCommandLines(), cr->GetWorkingDirectory(), + configName, cr->GetEscapeOldStyle(), cr->GetEscapeAllowMakeVars(), "\\\n\t"); @@ -850,6 +844,7 @@ cmLocalVisualStudio6Generator::CreateTargetRules(cmTarget &target, } customRuleCode += this->ConstructScript(cr->GetCommandLines(), cr->GetWorkingDirectory(), + configName, cr->GetEscapeOldStyle(), cr->GetEscapeAllowMakeVars(), "\\\n\t"); @@ -1274,7 +1269,14 @@ void cmLocalVisualStudio6Generator // are there any custom rules on the target itself // only if the target is a lib or exe - std::string customRuleCode = this->CreateTargetRules(target, libName); + std::string customRuleCodeRelease + = this->CreateTargetRules(target, "RELEASE", libName); + std::string customRuleCodeDebug + = this->CreateTargetRules(target, "DEBUG", libName); + std::string customRuleCodeMinSizeRel + = this->CreateTargetRules(target, "MINSIZEREL", libName); + std::string customRuleCodeRelWithDebInfo + = this->CreateTargetRules(target, "RELWITHDEBINFO", libName); std::ifstream fin(this->DSPHeaderTemplate.c_str()); if(!fin) @@ -1307,8 +1309,6 @@ void cmLocalVisualStudio6Generator } cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME_EXPORTS", exportSymbol.c_str()); - cmSystemTools::ReplaceString(line, "CMAKE_CUSTOM_RULE_CODE", - customRuleCode.c_str()); cmSystemTools::ReplaceString(line, "CMAKE_MFC_FLAG", mfcFlag); if(target.GetType() == cmTarget::STATIC_LIBRARY ) @@ -1337,6 +1337,18 @@ void cmLocalVisualStudio6Generator cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIMIZED_LIBRARIES", libMultiLineOptimizedOptions.c_str()); #endif + + // Substitute the rules for custom command. When specifying just the + // target name for the command the command can be different for + // different configs + cmSystemTools::ReplaceString(line, "CMAKE_CUSTOM_RULE_CODE_RELEASE", + customRuleCodeRelease.c_str()); + cmSystemTools::ReplaceString(line, "CMAKE_CUSTOM_RULE_CODE_DEBUG", + customRuleCodeDebug.c_str()); + cmSystemTools::ReplaceString(line, "CMAKE_CUSTOM_RULE_CODE_MINSIZEREL", + customRuleCodeMinSizeRel.c_str()); + cmSystemTools::ReplaceString(line, "CMAKE_CUSTOM_RULE_CODE_RELWITHDEBINFO", + customRuleCodeRelWithDebInfo.c_str()); // Substitute the real output name into the template. cmSystemTools::ReplaceString(line, "OUTPUT_NAME_DEBUG", |