From 7f9baf579033e13a25fb9c4db4c79d8f7bb0b47e Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Thu, 2 Mar 2017 18:16:54 +0100 Subject: Autogen: Test: Add generated qrc file to rccDepends test --- Tests/QtAutogen/CMakeLists.txt | 21 ++++++++++++++++++--- Tests/QtAutogen/rccDepends/CMakeLists.txt | 21 +++++++++++++++------ Tests/QtAutogen/rccDepends/main.cpp | 5 +++++ Tests/QtAutogen/rccDepends/res/input1.txt.in | 1 + Tests/QtAutogen/rccDepends/res/input2.txt.in | 1 + Tests/QtAutogen/rccDepends/res1/input.txt.in | 1 - Tests/QtAutogen/rccDepends/res2.qrc.in | 5 +++++ Tests/QtAutogen/rccDepends/test_res1.cpp | 5 ----- 8 files changed, 45 insertions(+), 15 deletions(-) create mode 100644 Tests/QtAutogen/rccDepends/main.cpp create mode 100644 Tests/QtAutogen/rccDepends/res/input1.txt.in create mode 100644 Tests/QtAutogen/rccDepends/res/input2.txt.in delete mode 100644 Tests/QtAutogen/rccDepends/res1/input.txt.in create mode 100644 Tests/QtAutogen/rccDepends/res2.qrc.in delete mode 100644 Tests/QtAutogen/rccDepends/test_res1.cpp diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt index c941d8c..1952379 100644 --- a/Tests/QtAutogen/CMakeLists.txt +++ b/Tests/QtAutogen/CMakeLists.txt @@ -101,7 +101,7 @@ list(GET target1List 0 binFile) set(timeformat "%Y%j%H%M%S") file(TIMESTAMP "${binFile}" timeBegin "${timeformat}") -# Touch qrc input file and rebuild +# Touch first qrc input file and rebuild execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change. execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${CMAKE_CURRENT_BINARY_DIR}/rccDepends/res1/input.txt") execute_process(COMMAND "${CMAKE_COMMAND}" --build . @@ -111,11 +111,26 @@ execute_process(COMMAND "${CMAKE_COMMAND}" --build . if (rccDepends_result) message(SEND_ERROR "Second build of rccDepends failed.") endif() - # Compare timestamps file(TIMESTAMP "${binFile}" timeStep1 "${timeformat}") if (NOT timeStep1 GREATER timeBegin) - message(SEND_ERROR "file1 (${binFile}) should have changed in the first step!") + message(SEND_ERROR "File (${binFile}) should have changed in the first step!") +endif() + +# Touch second qrc input file and rebuild +execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change. +execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${CMAKE_CURRENT_BINARY_DIR}/rccDepends/res2/input.txt") +execute_process(COMMAND "${CMAKE_COMMAND}" --build . + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/rccDepends" + RESULT_VARIABLE rccDepends_result +) +if (rccDepends_result) + message(SEND_ERROR "Third build of rccDepends failed.") +endif() +# Compare timestamps +file(TIMESTAMP "${binFile}" timeStep2 "${timeformat}") +if (NOT timeStep2 GREATER timeStep1) + message(SEND_ERROR "File (${binFile}) should have changed in the second step!") endif() # -- Test diff --git a/Tests/QtAutogen/rccDepends/CMakeLists.txt b/Tests/QtAutogen/rccDepends/CMakeLists.txt index 6fa5752..de98573 100644 --- a/Tests/QtAutogen/rccDepends/CMakeLists.txt +++ b/Tests/QtAutogen/rccDepends/CMakeLists.txt @@ -15,13 +15,22 @@ else() set(QT_CORE_TARGET Qt5::Core) endif() +configure_file(res/input1.txt.in res1/input.txt @ONLY) +configure_file(res/input2.txt.in res2/input.txt @ONLY) +# Configure time generated qrc file configure_file(res1.qrc.in res1.qrc @ONLY) -configure_file(res1/input.txt.in res1/input.txt @ONLY) +# Dependency generated qrc file +add_custom_command(OUTPUT res2.qrc + COMMAND ${CMAKE_COMMAND} -E sleep 3 + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/res2.qrc.in ${CMAKE_CURRENT_BINARY_DIR}/res2.qrc + ) -add_executable(test_res1 - test_res1.cpp + +add_executable(rccDepends + main.cpp ${CMAKE_CURRENT_BINARY_DIR}/res1.qrc + ${CMAKE_CURRENT_BINARY_DIR}/res2.qrc ) -target_link_libraries(test_res1 ${QT_CORE_TARGET}) -add_custom_command(TARGET test_res1 POST_BUILD COMMAND - ${CMAKE_COMMAND} -E echo "$" > target1.txt) +target_link_libraries(rccDepends ${QT_CORE_TARGET}) +add_custom_command(TARGET rccDepends POST_BUILD COMMAND + ${CMAKE_COMMAND} -E echo "$" > target1.txt) diff --git a/Tests/QtAutogen/rccDepends/main.cpp b/Tests/QtAutogen/rccDepends/main.cpp new file mode 100644 index 0000000..766b775 --- /dev/null +++ b/Tests/QtAutogen/rccDepends/main.cpp @@ -0,0 +1,5 @@ + +int main() +{ + return 0; +} diff --git a/Tests/QtAutogen/rccDepends/res/input1.txt.in b/Tests/QtAutogen/rccDepends/res/input1.txt.in new file mode 100644 index 0000000..da62762 --- /dev/null +++ b/Tests/QtAutogen/rccDepends/res/input1.txt.in @@ -0,0 +1 @@ +Res1 input. diff --git a/Tests/QtAutogen/rccDepends/res/input2.txt.in b/Tests/QtAutogen/rccDepends/res/input2.txt.in new file mode 100644 index 0000000..08e14b7 --- /dev/null +++ b/Tests/QtAutogen/rccDepends/res/input2.txt.in @@ -0,0 +1 @@ +Res2 input. diff --git a/Tests/QtAutogen/rccDepends/res1/input.txt.in b/Tests/QtAutogen/rccDepends/res1/input.txt.in deleted file mode 100644 index da62762..0000000 --- a/Tests/QtAutogen/rccDepends/res1/input.txt.in +++ /dev/null @@ -1 +0,0 @@ -Res1 input. diff --git a/Tests/QtAutogen/rccDepends/res2.qrc.in b/Tests/QtAutogen/rccDepends/res2.qrc.in new file mode 100644 index 0000000..18b916a --- /dev/null +++ b/Tests/QtAutogen/rccDepends/res2.qrc.in @@ -0,0 +1,5 @@ + + + res2/input.txt + + diff --git a/Tests/QtAutogen/rccDepends/test_res1.cpp b/Tests/QtAutogen/rccDepends/test_res1.cpp deleted file mode 100644 index 766b775..0000000 --- a/Tests/QtAutogen/rccDepends/test_res1.cpp +++ /dev/null @@ -1,5 +0,0 @@ - -int main() -{ - return 0; -} -- cgit v0.12