diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Source/cmAddCustomCommandCommand.cxx | 8 | ||||
-rw-r--r-- | Source/cmAddCustomTargetCommand.cxx | 6 | ||||
-rw-r--r-- | Source/cmCheckCustomOutputs.cxx | 36 | ||||
-rw-r--r-- | Source/cmCheckCustomOutputs.h | 15 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 34 |
6 files changed, 32 insertions, 69 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index c3b7e50..c5b67c0 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -181,8 +181,6 @@ set(SRCS cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.h cmCacheManager.cxx cmCacheManager.h - cmCheckCustomOutputs.h - cmCheckCustomOutputs.cxx cmCLocaleEnvironmentScope.h cmCLocaleEnvironmentScope.cxx cmCMakePath.h diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx index 8194226..ccd7255 100644 --- a/Source/cmAddCustomCommandCommand.cxx +++ b/Source/cmAddCustomCommandCommand.cxx @@ -5,7 +5,6 @@ #include <sstream> #include <unordered_set> -#include "cmCheckCustomOutputs.h" #include "cmCustomCommand.h" #include "cmCustomCommandLines.h" #include "cmCustomCommandTypes.h" @@ -298,13 +297,6 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args, return false; } - // Make sure the output names and locations are safe. - if (!cmCheckCustomOutputs(output, "OUTPUT", status) || - !cmCheckCustomOutputs(outputs, "OUTPUTS", status) || - !cmCheckCustomOutputs(byproducts, "BYPRODUCTS", status)) { - return false; - } - // Check for an append request. if (append) { mf.AppendCustomCommandToOutput(output[0], depends, implicit_depends, diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx index fd509bd..104065f 100644 --- a/Source/cmAddCustomTargetCommand.cxx +++ b/Source/cmAddCustomTargetCommand.cxx @@ -4,7 +4,6 @@ #include <utility> -#include "cmCheckCustomOutputs.h" #include "cmCustomCommandLines.h" #include "cmExecutionStatus.h" #include "cmGeneratorExpression.h" @@ -210,11 +209,6 @@ bool cmAddCustomTargetCommand(std::vector<std::string> const& args, return false; } - // Make sure the byproduct names and locations are safe. - if (!cmCheckCustomOutputs(byproducts, "BYPRODUCTS", status)) { - return false; - } - // Add the utility target to the makefile. bool escapeOldStyle = !verbatim; cmTarget* target = mf.AddUtilityCommand( diff --git a/Source/cmCheckCustomOutputs.cxx b/Source/cmCheckCustomOutputs.cxx deleted file mode 100644 index 7645c88..0000000 --- a/Source/cmCheckCustomOutputs.cxx +++ /dev/null @@ -1,36 +0,0 @@ -/* 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; -} diff --git a/Source/cmCheckCustomOutputs.h b/Source/cmCheckCustomOutputs.h deleted file mode 100644 index 2752ed4..0000000 --- a/Source/cmCheckCustomOutputs.h +++ /dev/null @@ -1,15 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#pragma once - -#include "cmConfigure.h" // IWYU pragma: keep - -#include <string> -#include <vector> - -#include <cm/string_view> - -class cmExecutionStatus; - -bool cmCheckCustomOutputs(const std::vector<std::string>& outputs, - cm::string_view keyword, cmExecutionStatus& status); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index dd1779b..9f9d725 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -17,6 +17,7 @@ #include <cm/memory> #include <cm/string_view> #include <cmext/algorithm> +#include <cmext/string_view> #include "cmsys/RegularExpression.hxx" @@ -3813,7 +3814,14 @@ void cmLocalGenerator::GenerateFrameworkInfoPList( } namespace { +cm::string_view CustomOutputRoleKeyword(cmLocalGenerator::OutputRole role) +{ + return (role == cmLocalGenerator::OutputRole::Primary ? "OUTPUT"_s + : "BYPRODUCTS"_s); +} + void CreateGeneratedSource(cmLocalGenerator& lg, const std::string& output, + cmLocalGenerator::OutputRole role, cmCommandOrigin origin, const cmListFileBacktrace& lfbt) { @@ -3825,6 +3833,28 @@ void CreateGeneratedSource(cmLocalGenerator& lg, const std::string& output, return; } + // Make sure the file will not be generated into the source + // directory during an out of source build. + if (!lg.GetMakefile()->CanIWriteThisFile(output)) { + lg.GetCMakeInstance()->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat(CustomOutputRoleKeyword(role), " path\n ", output, + "\nin a source directory as an output of custom command."), + lfbt); + return; + } + + // Make sure the output file name has no invalid characters. + std::string::size_type pos = output.find_first_of("#<>"); + if (pos != std::string::npos) { + lg.GetCMakeInstance()->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat(CustomOutputRoleKeyword(role), " containing a \"", output[pos], + "\" is not allowed."), + lfbt); + return; + } + // Outputs without generator expressions from the project are already // created and marked as generated. Do not mark them again, because // other commands might have overwritten the property. @@ -4283,7 +4313,7 @@ void cmLocalGenerator::UpdateOutputToSourceMap(std::string const& byproduct, auto pr = this->OutputToSource.emplace(byproduct, entry); if (pr.second) { - CreateGeneratedSource(*this, byproduct, origin, bt); + CreateGeneratedSource(*this, byproduct, OutputRole::Byproduct, origin, bt); } else { SourceEntry& current = pr.first->second; // Has the target already been set? @@ -4311,7 +4341,7 @@ void cmLocalGenerator::UpdateOutputToSourceMap(std::string const& output, auto pr = this->OutputToSource.emplace(output, entry); if (pr.second) { - CreateGeneratedSource(*this, output, origin, bt); + CreateGeneratedSource(*this, output, role, origin, bt); } else { SourceEntry& current = pr.first->second; // Outputs take precedence over byproducts |