diff options
author | Daniel Eiband <daniel.eiband@brainlab.com> | 2019-09-23 20:18:36 (GMT) |
---|---|---|
committer | Daniel Eiband <daniel.eiband@brainlab.com> | 2019-09-23 20:18:36 (GMT) |
commit | a1cc6b4447787b84777fdf9a860e8c39f0f4a090 (patch) | |
tree | 2c6bda9df6651b5732f6eef005333c15a3d07d65 /Source/cmCheckCustomOutputs.cxx | |
parent | cbb861ade85e3b7e550bb1f150513b237efc1f02 (diff) | |
download | CMake-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/cmCheckCustomOutputs.cxx')
-rw-r--r-- | Source/cmCheckCustomOutputs.cxx | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Source/cmCheckCustomOutputs.cxx b/Source/cmCheckCustomOutputs.cxx new file mode 100644 index 0000000..a401738 --- /dev/null +++ b/Source/cmCheckCustomOutputs.cxx @@ -0,0 +1,36 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "cmCheckCustomOutputs.h" + +#include "cmExecutionStatus.h" +#include "cmMakefile.h" +#include "cmStringAlgorithms.h" +#include "cmSystemTools.h" + +bool cmCheckCustomOutputs(const std::vector<std::string>& outputs, + cm::string_view keyword, 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)) { + status.SetError( + cmStrCat("attempted to have a file\n\"", o, + "\"\nin a source directory as an output of custom command.")); + 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 ", keyword, " containing a \"", + o[pos], "\". This character is not allowed.")); + return false; + } + } + + return true; +} |