summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefileTargetGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-03-30 20:32:26 (GMT)
committerBrad King <brad.king@kitware.com>2015-03-30 20:35:48 (GMT)
commit4adf1dad2a6e462364bae81030c928599d11c24f (patch)
treec8439c0f37554c41374373117c8ea1f20cf40381 /Source/cmMakefileTargetGenerator.cxx
parentc1f8c6cdf94d650df1bd8ec847ae7ac453550978 (diff)
downloadCMake-4adf1dad2a6e462364bae81030c928599d11c24f.zip
CMake-4adf1dad2a6e462364bae81030c928599d11c24f.tar.gz
CMake-4adf1dad2a6e462364bae81030c928599d11c24f.tar.bz2
Makefile: Tell GNU make to delete rule outputs on error (#15474)
Add .DELETE_ON_ERROR to the "build.make" files that contain the actual build rules that generate files. This tells GNU make to delete the output of a rule if the recipe modifies the output but returns failure. This is particularly useful for custom commands that use shell redirection to produce a file. Do not add .DELETE_ON_ERROR for Borland or Watcom make tools because they may not tolerate it and would not honor it anyway. Other make tools that do not understand .DELETE_ON_ERROR will not be hurt. Suggested-by: Andrey Vihrov <andrey.vihrov@gmail.com>
Diffstat (limited to 'Source/cmMakefileTargetGenerator.cxx')
-rw-r--r--Source/cmMakefileTargetGenerator.cxx8
1 files changed, 8 insertions, 0 deletions
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 641cd23..2cd2d3e 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -122,6 +122,14 @@ void cmMakefileTargetGenerator::CreateRuleFile()
return;
}
this->LocalGenerator->WriteDisclaimer(*this->BuildFileStream);
+ if (this->GlobalGenerator->AllowDeleteOnError())
+ {
+ std::vector<std::string> no_depends;
+ std::vector<std::string> no_commands;
+ this->LocalGenerator->WriteMakeRule(
+ *this->BuildFileStream, "Delete rule output on recipe failure.",
+ ".DELETE_ON_ERROR", no_depends, no_commands, false);
+ }
this->LocalGenerator->WriteSpecialTargetsTop(*this->BuildFileStream);
}