1
0
Эх сурвалжийг харах

file(CONFIGURE): Allow angle brackets in content

Fixes: #21306
Cristian Adam 5 жил өмнө
parent
commit
06a9a3bdc3

+ 1 - 9
Source/cmFileCommand.cxx

@@ -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],

+ 1 - 0
Tests/RunCMake/File_Configure/AngleBracketsContent-stderr.txt

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

+ 6 - 0
Tests/RunCMake/File_Configure/AngleBracketsContent.cmake

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

+ 0 - 1
Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent-result.txt

@@ -1 +0,0 @@
-1

+ 0 - 5
Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent-stderr.txt

@@ -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\)

+ 0 - 4
Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent.cmake

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

+ 1 - 1
Tests/RunCMake/File_Configure/RunCMakeTest.cmake

@@ -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)