From fd3ed41109db9682bbdcb5e5d3249b6654322ca6 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 30 Jun 2022 11:07:48 -0400 Subject: 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. --- Tests/RunCMake/File_Generate/InputAndContent-check.cmake | 8 ++++++++ Tests/RunCMake/File_Generate/InputAndContent-input.txt | 1 + Tests/RunCMake/File_Generate/InputAndContent.cmake | 10 ++++++++++ Tests/RunCMake/File_Generate/RunCMakeTest.cmake | 1 + 4 files changed, 20 insertions(+) create mode 100644 Tests/RunCMake/File_Generate/InputAndContent-check.cmake create mode 100644 Tests/RunCMake/File_Generate/InputAndContent-input.txt create mode 100644 Tests/RunCMake/File_Generate/InputAndContent.cmake diff --git a/Tests/RunCMake/File_Generate/InputAndContent-check.cmake b/Tests/RunCMake/File_Generate/InputAndContent-check.cmake new file mode 100644 index 0000000..5c9b803 --- /dev/null +++ b/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() diff --git a/Tests/RunCMake/File_Generate/InputAndContent-input.txt b/Tests/RunCMake/File_Generate/InputAndContent-input.txt new file mode 100644 index 0000000..73f162b --- /dev/null +++ b/Tests/RunCMake/File_Generate/InputAndContent-input.txt @@ -0,0 +1 @@ +INPUT file diff --git a/Tests/RunCMake/File_Generate/InputAndContent.cmake b/Tests/RunCMake/File_Generate/InputAndContent.cmake new file mode 100644 index 0000000..9c3977a --- /dev/null +++ b/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" +) diff --git a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake index be3bf04..5a670ae 100644 --- a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake +++ b/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) -- cgit v0.12