Просмотр исходного кода

file(GENERATE): Add test case covering use of both INPUT and CONTENT

We have long incorrectly accepted both of these together, and used only
the first one.  Add a test to preserve compatibility.
Brad King 3 лет назад
Родитель
Сommit
fd3ed41109

+ 8 - 0
Tests/RunCMake/File_Generate/InputAndContent-check.cmake

@@ -0,0 +1,8 @@
+file(READ "${RunCMake_TEST_BINARY_DIR}/output-INPUT.txt" input)
+if(NOT input MATCHES "INPUT file")
+  string(APPEND RunCMake_TEST_FAILED "INPUT incorrectly overridden by CONTENT")
+endif()
+file(READ "${RunCMake_TEST_BINARY_DIR}/output-CONTENT.txt" content)
+if(NOT content MATCHES "CONTENT argument")
+  string(APPEND RunCMake_TEST_FAILED "CONTENT incorrectly overridden by INPUT")
+endif()

+ 1 - 0
Tests/RunCMake/File_Generate/InputAndContent-input.txt

@@ -0,0 +1 @@
+INPUT file

+ 10 - 0
Tests/RunCMake/File_Generate/InputAndContent.cmake

@@ -0,0 +1,10 @@
+file(GENERATE
+  OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output-INPUT.txt"
+  INPUT "${CMAKE_CURRENT_SOURCE_DIR}/InputAndContent-input.txt"
+  CONTENT "CONTENT argument"
+)
+file(GENERATE
+  OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output-CONTENT.txt"
+  CONTENT "CONTENT argument"
+  INPUT "${CMAKE_CURRENT_SOURCE_DIR}/InputAndContent-input.txt"
+)

+ 1 - 0
Tests/RunCMake/File_Generate/RunCMakeTest.cmake

@@ -17,6 +17,7 @@ run_cmake(EmptyCondition2)
 run_cmake(BadCondition)
 run_cmake(DebugEvaluate)
 run_cmake(GenerateSource)
+run_cmake(InputAndContent)
 run_cmake(OutputNameMatchesSources)
 run_cmake(OutputNameMatchesObjects)
 run_cmake(OutputNameMatchesOtherSources)