1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-15 12:16:40 +08:00

file(CONFIGURE): Allow angle brackets in content

Fixes: #21306
This commit is contained in:
Cristian Adam
2020-10-15 15:37:39 +02:00
parent 85c2bb724f
commit 06a9a3bdc3
7 changed files with 9 additions and 20 deletions

View File

@@ -2945,15 +2945,7 @@ bool HandleConfigureCommand(std::vector<std::string> const& args,
std::string outputFile = cmSystemTools::CollapseFullPath(
args[2], status.GetMakefile().GetCurrentBinaryDirectory());
std::string::size_type pos = input.find_first_of("<>");
if (pos != std::string::npos) {
status.SetError(cmStrCat("CONFIGURE called with CONTENT containing a \"",
input[pos],
"\". This character is not allowed."));
return false;
}
pos = outputFile.find_first_of("<>");
std::string::size_type pos = outputFile.find_first_of("<>");
if (pos != std::string::npos) {
status.SetError(cmStrCat("CONFIGURE called with OUTPUT containing a \"",
outputFile[pos],

View File

@@ -0,0 +1 @@
^foo-\$<CONFIG>$

View File

@@ -0,0 +1,6 @@
file(CONFIGURE
OUTPUT "file.txt"
CONTENT "foo-$<CONFIG>"
)
file(READ ${CMAKE_CURRENT_BINARY_DIR}/file.txt out)
message("${out}")

View File

@@ -1,5 +0,0 @@
CMake Error at BadArgGeneratorExpressionContent.cmake:[0-9]+ \(file\):
file CONFIGURE called with CONTENT containing a "<". This character is not
allowed.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@@ -1,4 +0,0 @@
file(CONFIGURE
OUTPUT "file.txt"
CONTENT "foo-$<CONFIG>"
)

View File

@@ -1,7 +1,7 @@
include(RunCMake)
run_cmake(AngleBracketsContent)
run_cmake(BadArg)
run_cmake(BadArgGeneratorExpressionContent)
run_cmake(BadArgGeneratorExpressionOutput)
run_cmake(DirOutput)
run_cmake(NewLineStyle-NoArg)