summaryrefslogtreecommitdiffstats
path: root/Tests/QtAutogen
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2017-12-09 12:30:54 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2017-12-13 12:50:18 (GMT)
commitb1504f9f97849777f4690565f8b5879372e7dd51 (patch)
tree320510b9093aa093e4e16a7544a99b943a1d32a0 /Tests/QtAutogen
parente9fcd1545facf6300181db843260008e1069c7b4 (diff)
downloadCMake-b1504f9f97849777f4690565f8b5879372e7dd51.zip
CMake-b1504f9f97849777f4690565f8b5879372e7dd51.tar.gz
CMake-b1504f9f97849777f4690565f8b5879372e7dd51.tar.bz2
Autogen: Tests: Separate RerunRccDepends test
Diffstat (limited to 'Tests/QtAutogen')
-rw-r--r--Tests/QtAutogen/CommonTests.cmake1
-rw-r--r--Tests/QtAutogen/RerunRccDepends/CMakeLists.txt139
-rw-r--r--Tests/QtAutogen/RerunRccDepends/RccDepends/CMakeLists.txt33
-rw-r--r--Tests/QtAutogen/RerunRccDepends/RccDepends/main.cpp5
-rw-r--r--Tests/QtAutogen/RerunRccDepends/RccDepends/resGen/input.txt.in1
-rw-r--r--Tests/QtAutogen/RerunRccDepends/RccDepends/resGen/inputAdded.txt.in1
-rw-r--r--Tests/QtAutogen/RerunRccDepends/RccDepends/resGenA.qrc.in5
-rw-r--r--Tests/QtAutogen/RerunRccDepends/RccDepends/resGenB.qrc.in6
-rw-r--r--Tests/QtAutogen/RerunRccDepends/RccDepends/resPlain/input.txt.in1
-rw-r--r--Tests/QtAutogen/RerunRccDepends/RccDepends/resPlain/inputAdded.txt.in1
-rw-r--r--Tests/QtAutogen/RerunRccDepends/RccDepends/resPlainA.qrc.in5
-rw-r--r--Tests/QtAutogen/RerunRccDepends/RccDepends/resPlainB.qrc.in6
-rw-r--r--Tests/QtAutogen/RerunRccDepends/dummy.cpp5
13 files changed, 209 insertions, 0 deletions
diff --git a/Tests/QtAutogen/CommonTests.cmake b/Tests/QtAutogen/CommonTests.cmake
index b03c282..5746ab5 100644
--- a/Tests/QtAutogen/CommonTests.cmake
+++ b/Tests/QtAutogen/CommonTests.cmake
@@ -36,3 +36,4 @@ ADD_AUTOGEN_TEST(RerunMocBasic)
if(NOT QT_TEST_VERSION STREQUAL 4)
ADD_AUTOGEN_TEST(RerunMocPlugin)
endif()
+ADD_AUTOGEN_TEST(RerunRccDepends)
diff --git a/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt b/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt
new file mode 100644
index 0000000..2e6a5bd
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt
@@ -0,0 +1,139 @@
+cmake_minimum_required(VERSION 3.10)
+project(RerunRccDepends)
+include("../AutogenTest.cmake")
+
+# Tests rcc rebuilding when a resource file changes
+
+# Dummy executable to generate a clean target
+add_executable(dummy dummy.cpp)
+
+# When a .qrc or a file listed in a .qrc file changes,
+# the target must be rebuilt
+set(timeformat "%Y%j%H%M%S")
+set(rccDepSD "${CMAKE_CURRENT_SOURCE_DIR}/RccDepends")
+set(rccDepBD "${CMAKE_CURRENT_BINARY_DIR}/RccDepends")
+
+# Initial build
+configure_file(${rccDepSD}/resPlainA.qrc.in ${rccDepBD}/resPlain.qrc COPYONLY)
+configure_file(${rccDepSD}/resGenA.qrc.in ${rccDepBD}/resGen.qrc.in COPYONLY)
+try_compile(RCC_DEPENDS
+ "${rccDepBD}"
+ "${rccDepSD}"
+ RccDepends
+ CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}"
+ "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
+ OUTPUT_VARIABLE output
+)
+if (NOT RCC_DEPENDS)
+ message(SEND_ERROR "Initial build of rccDepends failed. Output: ${output}")
+endif()
+
+# Get name of the output binaries
+file(STRINGS "${rccDepBD}/targetPlain.txt" targetListPlain ENCODING UTF-8)
+file(STRINGS "${rccDepBD}/targetGen.txt" targetListGen ENCODING UTF-8)
+list(GET targetListPlain 0 rccDepBinPlain)
+list(GET targetListGen 0 rccDepBinGen)
+message("Target that uses a plain .qrc file is:\n ${rccDepBinPlain}")
+message("Target that uses a GENERATED .qrc file is:\n ${rccDepBinGen}")
+
+
+message("Changing a resource files listed in the .qrc file")
+# - Acquire binary timestamps before the build
+file(TIMESTAMP "${rccDepBinPlain}" rdPlainBefore "${timeformat}")
+file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}")
+# - Ensure that the timestamp will change
+# - Change a resource files listed in the .qrc file
+# - Rebuild
+execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
+execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${rccDepBD}/resPlain/input.txt")
+execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${rccDepBD}/resGen/input.txt")
+execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result)
+if (result)
+ message(SEND_ERROR "Second build of rccDepends failed.")
+endif()
+# - Acquire binary timestamps after the build
+file(TIMESTAMP "${rccDepBinPlain}" rdPlainAfter "${timeformat}")
+file(TIMESTAMP "${rccDepBinGen}" rdGenAfter "${timeformat}")
+# - Test if timestamps changed
+if (NOT rdPlainAfter GREATER rdPlainBefore)
+ message(SEND_ERROR "Plain .qrc binary ${rccDepBinPlain}) should have changed!")
+endif()
+if (NOT rdGenAfter GREATER rdGenBefore)
+ message(SEND_ERROR "GENERATED .qrc binary ${rccDepBinGen} should have changed!")
+endif()
+
+
+message("Changing a the .qrc file")
+# - Acquire binary timestamps before the build
+file(TIMESTAMP "${rccDepBinPlain}" rdPlainBefore "${timeformat}")
+file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}")
+# - Ensure that the timestamp will change
+# - Change the .qrc file
+# - Rebuild
+execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
+configure_file(${rccDepSD}/resPlainB.qrc.in ${rccDepBD}/resPlain.qrc COPYONLY)
+configure_file(${rccDepSD}/resGenB.qrc.in ${rccDepBD}/resGen.qrc.in COPYONLY)
+execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result)
+if (result)
+ message(SEND_ERROR "Third build of rccDepends failed.")
+endif()
+# - Acquire binary timestamps after the build
+file(TIMESTAMP "${rccDepBinPlain}" rdPlainAfter "${timeformat}")
+file(TIMESTAMP "${rccDepBinGen}" rdGenAfter "${timeformat}")
+# - Test if timestamps changed
+if (NOT rdPlainAfter GREATER rdPlainBefore)
+ message(SEND_ERROR "Plain .qrc binary ${rccDepBinPlain}) should have changed!")
+endif()
+if (NOT rdGenAfter GREATER rdGenBefore)
+ message(SEND_ERROR "GENERATED .qrc binary ${rccDepBinGen} should have changed!")
+endif()
+
+
+message("Changing a newly added resource files listed in the .qrc file")
+# - Acquire binary timestamps before the build
+file(TIMESTAMP "${rccDepBinPlain}" rdPlainBefore "${timeformat}")
+file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}")
+# - Ensure that the timestamp will change
+# - Change a newly added resource files listed in the .qrc file
+# - Rebuild
+execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
+execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${rccDepBD}/resPlain/inputAdded.txt")
+execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${rccDepBD}/resGen/inputAdded.txt")
+execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result)
+if (result)
+ message(SEND_ERROR "Fourth build of rccDepends failed.")
+endif()
+# - Acquire binary timestamps after the build
+file(TIMESTAMP "${rccDepBinPlain}" rdPlainAfter "${timeformat}")
+file(TIMESTAMP "${rccDepBinGen}" rdGenAfter "${timeformat}")
+# - Test if timestamps changed
+if (NOT rdPlainAfter GREATER rdPlainBefore)
+ message(SEND_ERROR "Plain .qrc binary ${rccDepBinPlain}) should have changed!")
+endif()
+if (NOT rdGenAfter GREATER rdGenBefore)
+ message(SEND_ERROR "GENERATED .qrc binary ${rccDepBinGen} should have changed!")
+endif()
+
+
+message("Changing nothing in the .qrc file")
+# - Acquire binary timestamps before the build
+file(TIMESTAMP "${rccDepBinPlain}" rdPlainBefore "${timeformat}")
+file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}")
+# - Ensure that the timestamp will change
+# - Change nothing
+# - Rebuild
+execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
+execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result)
+if (result)
+ message(SEND_ERROR "Fifth build of rccDepends failed.")
+endif()
+# - Acquire binary timestamps after the build
+file(TIMESTAMP "${rccDepBinPlain}" rdPlainAfter "${timeformat}")
+file(TIMESTAMP "${rccDepBinGen}" rdGenAfter "${timeformat}")
+# - Test if timestamps changed
+if (rdPlainAfter GREATER rdPlainBefore)
+ message(SEND_ERROR "Plain .qrc binary ${rccDepBinPlain}) should NOT have changed!")
+endif()
+if (rdGenAfter GREATER rdGenBefore)
+ message(SEND_ERROR "GENERATED .qrc binary ${rccDepBinGen} should NOT have changed!")
+endif()
diff --git a/Tests/QtAutogen/RerunRccDepends/RccDepends/CMakeLists.txt b/Tests/QtAutogen/RerunRccDepends/RccDepends/CMakeLists.txt
new file mode 100644
index 0000000..0507e61
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccDepends/RccDepends/CMakeLists.txt
@@ -0,0 +1,33 @@
+cmake_minimum_required(VERSION 3.10)
+project(RccDepends)
+include("../../AutogenTest.cmake")
+
+# Enable AUTORCC for all targets
+set(CMAKE_AUTORCC ON)
+
+# Initial resource files setup
+configure_file(resPlain/input.txt.in resPlain/input.txt COPYONLY)
+configure_file(resPlain/input.txt.in resPlain/inputAdded.txt COPYONLY)
+configure_file(resGen/input.txt.in resGen/input.txt COPYONLY)
+configure_file(resGen/input.txt.in resGen/inputAdded.txt COPYONLY)
+
+# Generated qrc file with dependency
+add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc.in
+ COMMAND ${CMAKE_COMMAND} -E sleep 2
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc.in ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc
+)
+
+# Target that uses a plain .qrc file
+add_executable(rccDependsPlain main.cpp ${CMAKE_CURRENT_BINARY_DIR}/resPlain.qrc)
+target_link_libraries(rccDependsPlain ${QT_QTCORE_TARGET})
+add_custom_command(TARGET rccDependsPlain POST_BUILD COMMAND
+ ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:rccDependsPlain>" > targetPlain.txt
+)
+
+# Target that uses a GENERATED .qrc file
+add_executable(rccDependsGen main.cpp ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc )
+target_link_libraries(rccDependsGen ${QT_QTCORE_TARGET})
+add_custom_command(TARGET rccDependsGen POST_BUILD COMMAND
+ ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:rccDependsGen>" > targetGen.txt
+)
diff --git a/Tests/QtAutogen/RerunRccDepends/RccDepends/main.cpp b/Tests/QtAutogen/RerunRccDepends/RccDepends/main.cpp
new file mode 100644
index 0000000..766b775
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccDepends/RccDepends/main.cpp
@@ -0,0 +1,5 @@
+
+int main()
+{
+ return 0;
+}
diff --git a/Tests/QtAutogen/RerunRccDepends/RccDepends/resGen/input.txt.in b/Tests/QtAutogen/RerunRccDepends/RccDepends/resGen/input.txt.in
new file mode 100644
index 0000000..4f24589
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccDepends/RccDepends/resGen/input.txt.in
@@ -0,0 +1 @@
+Generated resource input.
diff --git a/Tests/QtAutogen/RerunRccDepends/RccDepends/resGen/inputAdded.txt.in b/Tests/QtAutogen/RerunRccDepends/RccDepends/resGen/inputAdded.txt.in
new file mode 100644
index 0000000..4f24589
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccDepends/RccDepends/resGen/inputAdded.txt.in
@@ -0,0 +1 @@
+Generated resource input.
diff --git a/Tests/QtAutogen/RerunRccDepends/RccDepends/resGenA.qrc.in b/Tests/QtAutogen/RerunRccDepends/RccDepends/resGenA.qrc.in
new file mode 100644
index 0000000..c131a34
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccDepends/RccDepends/resGenA.qrc.in
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/TextsGenerated">
+ <file>resGen/input.txt</file>
+ </qresource>
+</RCC>
diff --git a/Tests/QtAutogen/RerunRccDepends/RccDepends/resGenB.qrc.in b/Tests/QtAutogen/RerunRccDepends/RccDepends/resGenB.qrc.in
new file mode 100644
index 0000000..8c7e643
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccDepends/RccDepends/resGenB.qrc.in
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/TextsGenerated">
+ <file>resGen/input.txt</file>
+ <file alias="Added">resGen/inputAdded.txt</file>
+ </qresource>
+</RCC>
diff --git a/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlain/input.txt.in b/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlain/input.txt.in
new file mode 100644
index 0000000..a5e407a
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlain/input.txt.in
@@ -0,0 +1 @@
+Plaint resource input.
diff --git a/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlain/inputAdded.txt.in b/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlain/inputAdded.txt.in
new file mode 100644
index 0000000..a5e407a
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlain/inputAdded.txt.in
@@ -0,0 +1 @@
+Plaint resource input.
diff --git a/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlainA.qrc.in b/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlainA.qrc.in
new file mode 100644
index 0000000..c135d85
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlainA.qrc.in
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/TextsPlain">
+ <file>resPlain/input.txt</file>
+ </qresource>
+</RCC>
diff --git a/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlainB.qrc.in b/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlainB.qrc.in
new file mode 100644
index 0000000..186b653
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlainB.qrc.in
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/TextsPlain">
+ <file>resPlain/input.txt</file>
+ <file alias="Added">resPlain/inputAdded.txt</file>
+ </qresource>
+</RCC>
diff --git a/Tests/QtAutogen/RerunRccDepends/dummy.cpp b/Tests/QtAutogen/RerunRccDepends/dummy.cpp
new file mode 100644
index 0000000..4837a76
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccDepends/dummy.cpp
@@ -0,0 +1,5 @@
+
+int main(int argv, char** args)
+{
+ return 0;
+}