summaryrefslogtreecommitdiffstats
path: root/Source/cmVisualStudio10TargetGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-06-08 16:45:20 (GMT)
committerBrad King <brad.king@kitware.com>2021-06-09 14:09:58 (GMT)
commit526e2ef71c5b797818bbf232e21d0152a3938197 (patch)
treecbf166ad88496f7d0b070e7bc1f38bba073f4356 /Source/cmVisualStudio10TargetGenerator.cxx
parent794ad78abb8da517e59e25ea38f5c1edced1cf46 (diff)
downloadCMake-526e2ef71c5b797818bbf232e21d0152a3938197.zip
CMake-526e2ef71c5b797818bbf232e21d0152a3938197.tar.gz
CMake-526e2ef71c5b797818bbf232e21d0152a3938197.tar.bz2
VS: Add support for add_custom_command DEPFILE
Transform the depfile into MSBuild `AdditionalInputs` content. Add MSBuild Targets to update `AdditionalInputs` and the `.tlog` files for future builds without actually modifying the `.vcxproj` file. Fixes: #20286
Diffstat (limited to 'Source/cmVisualStudio10TargetGenerator.cxx')
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx32
1 files changed, 27 insertions, 5 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 98d56df..b79c6fd 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -768,6 +768,11 @@ void cmVisualStudio10TargetGenerator::Generate()
Elem(e1, "Import").Attribute("Project", nasmTargets);
}
}
+ if (this->ProjectType == vcxproj && this->HaveCustomCommandDepfile) {
+ std::string depfileTargets =
+ GetCMakeFilePath("Templates/MSBuild/CustomBuildDepFile.targets");
+ Elem(e0, "Import").Attribute("Project", depfileTargets);
+ }
if (this->ProjectType == csproj) {
for (std::string const& c : this->Configurations) {
Elem e1(e0, "PropertyGroup");
@@ -1460,7 +1465,7 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule(
e2.SetHasElements();
}
for (std::string const& c : this->Configurations) {
- cmCustomCommandGenerator ccg(command, c, lg);
+ cmCustomCommandGenerator ccg(command, c, lg, true);
std::string comment = lg->ConstructComment(ccg);
comment = cmVS10EscapeComment(comment);
std::string script = lg->ConstructScript(ccg);
@@ -1524,10 +1529,10 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule(
std::string name = "CustomCommand_" + c + "_" +
cmSystemTools::ComputeStringMD5(sourcePath);
this->WriteCustomRuleCSharp(e0, c, name, script, additional_inputs.str(),
- outputs.str(), comment);
+ outputs.str(), comment, ccg);
} else {
this->WriteCustomRuleCpp(*spe2, c, script, additional_inputs.str(),
- outputs.str(), comment, symbolic);
+ outputs.str(), comment, ccg, symbolic);
}
}
}
@@ -1535,7 +1540,8 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule(
void cmVisualStudio10TargetGenerator::WriteCustomRuleCpp(
Elem& e2, std::string const& config, std::string const& script,
std::string const& additional_inputs, std::string const& outputs,
- std::string const& comment, bool symbolic)
+ std::string const& comment, cmCustomCommandGenerator const& ccg,
+ bool symbolic)
{
const std::string cond = this->CalcCondition(config);
e2.WritePlatformConfigTag("Message", cond, comment);
@@ -1554,13 +1560,29 @@ void cmVisualStudio10TargetGenerator::WriteCustomRuleCpp(
// outputs is marked SYMBOLIC and not expected to be created.
e2.WritePlatformConfigTag("VerifyInputsAndOutputsExist", cond, "false");
}
+
+ std::string depfile = ccg.GetFullDepfile();
+ if (!depfile.empty()) {
+ this->HaveCustomCommandDepfile = true;
+ std::string internal_depfile = ccg.GetInternalDepfile();
+ ConvertToWindowsSlash(internal_depfile);
+ e2.WritePlatformConfigTag("DepFileAdditionalInputsFile", cond,
+ internal_depfile);
+ }
}
void cmVisualStudio10TargetGenerator::WriteCustomRuleCSharp(
Elem& e0, std::string const& config, std::string const& name,
std::string const& script, std::string const& inputs,
- std::string const& outputs, std::string const& comment)
+ std::string const& outputs, std::string const& comment,
+ cmCustomCommandGenerator const& ccg)
{
+ if (!ccg.GetFullDepfile().empty()) {
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("CSharp target \"", this->GeneratorTarget->GetName(),
+ "\" does not support add_custom_command DEPFILE."));
+ }
this->CSharpCustomCommandNames.insert(name);
Elem e1(e0, "Target");
e1.Attribute("Condition", this->CalcCondition(config));