summaryrefslogtreecommitdiffstats
path: root/Source/cmAddCustomCommandCommand.cxx
diff options
context:
space:
mode:
authorDaniel Eiband <daniel.eiband@brainlab.com>2019-09-23 20:18:36 (GMT)
committerDaniel Eiband <daniel.eiband@brainlab.com>2019-09-23 20:18:36 (GMT)
commita1cc6b4447787b84777fdf9a860e8c39f0f4a090 (patch)
tree2c6bda9df6651b5732f6eef005333c15a3d07d65 /Source/cmAddCustomCommandCommand.cxx
parentcbb861ade85e3b7e550bb1f150513b237efc1f02 (diff)
downloadCMake-a1cc6b4447787b84777fdf9a860e8c39f0f4a090.zip
CMake-a1cc6b4447787b84777fdf9a860e8c39f0f4a090.tar.gz
CMake-a1cc6b4447787b84777fdf9a860e8c39f0f4a090.tar.bz2
add_custom_target: Add output checks for custom target byproducts
Use the output checks for byproducts of add_custom_command also for byproducts of add_custom_target.
Diffstat (limited to 'Source/cmAddCustomCommandCommand.cxx')
-rw-r--r--Source/cmAddCustomCommandCommand.cxx36
1 files changed, 4 insertions, 32 deletions
diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx
index defefaf..9d665c4 100644
--- a/Source/cmAddCustomCommandCommand.cxx
+++ b/Source/cmAddCustomCommandCommand.cxx
@@ -5,6 +5,7 @@
#include <sstream>
#include <unordered_set>
+#include "cmCheckCustomOutputs.h"
#include "cmCustomCommand.h"
#include "cmCustomCommandLines.h"
#include "cmExecutionStatus.h"
@@ -16,9 +17,6 @@
#include "cmSystemTools.h"
#include "cmTarget.h"
-static bool cmAddCustomCommandCommandCheckOutputs(
- const std::vector<std::string>& outputs, cmExecutionStatus& status);
-
bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
cmExecutionStatus& status)
{
@@ -307,9 +305,9 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
}
// Make sure the output names and locations are safe.
- if (!cmAddCustomCommandCommandCheckOutputs(output, status) ||
- !cmAddCustomCommandCommandCheckOutputs(outputs, status) ||
- !cmAddCustomCommandCommandCheckOutputs(byproducts, status)) {
+ if (!cmCheckCustomOutputs(output, "OUTPUT", status) ||
+ !cmCheckCustomOutputs(outputs, "OUTPUTS", status) ||
+ !cmCheckCustomOutputs(byproducts, "BYPRODUCTS", status)) {
return false;
}
@@ -387,29 +385,3 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
return true;
}
-
-bool cmAddCustomCommandCommandCheckOutputs(
- const std::vector<std::string>& outputs, cmExecutionStatus& status)
-{
- cmMakefile& mf = status.GetMakefile();
- for (std::string const& o : outputs) {
- // Make sure the file will not be generated into the source
- // directory during an out of source build.
- if (!mf.CanIWriteThisFile(o)) {
- std::string e = "attempted to have a file\n\"" + o +
- "\"\nin a source directory as an output of custom command.";
- status.SetError(e);
- cmSystemTools::SetFatalErrorOccured();
- return false;
- }
-
- // Make sure the output file name has no invalid characters.
- std::string::size_type pos = o.find_first_of("#<>");
- if (pos != std::string::npos) {
- status.SetError(cmStrCat("called with OUTPUT containing a \"", o[pos],
- "\". This character is not allowed."));
- return false;
- }
- }
- return true;
-}