Autogen: Add AUTORCC configuration change test

This commit is contained in:
Sebastian Holtermann
2018-05-25 11:40:23 +02:00
parent 41685c8ba0
commit 5852acffa4
11 changed files with 94 additions and 0 deletions

View File

@@ -43,3 +43,4 @@ if(NOT QT_TEST_VERSION STREQUAL 4)
ADD_AUTOGEN_TEST(RerunMocPlugin)
endif()
ADD_AUTOGEN_TEST(RerunRccDepends)
ADD_AUTOGEN_TEST(RerunRccConfigChange)

View File

@@ -0,0 +1,41 @@
cmake_minimum_required(VERSION 3.11.2)
project(RerunRccConfigChange)
include("../AutogenTest.cmake")
# Tests rcc rebuilding after a configuration change
# 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}/RccConfigChange")
set(rccDepBD "${CMAKE_CURRENT_BINARY_DIR}/RccConfigChange")
# Initial build
try_compile(RCC_DEPENDS
"${rccDepBD}"
"${rccDepSD}"
RccConfigChange
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 rccConfigChange failed. Output: ${output}")
endif()
# - Rebuild Release
message("Rebuilding rccConfigChange in Release configuration")
execute_process(COMMAND "${CMAKE_COMMAND}" --build . --config Release WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result)
if (result)
message(SEND_ERROR "Release build of rccConfigChange failed.")
endif()
# - Rebuild Debug
message("Rebuilding rccConfigChange in Debug configuration")
execute_process(COMMAND "${CMAKE_COMMAND}" --build . --config Debug WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result)
if (result)
message(SEND_ERROR "Debug build of rccConfigChange failed.")
endif()

View File

@@ -0,0 +1,26 @@
cmake_minimum_required(VERSION 3.11.2)
project(RccConfigChange)
include("../../AutogenTest.cmake")
# Enable AUTORCC for all targets
set(CMAKE_AUTORCC ON)
# Initial resource files setup
configure_file(resGen/input1.txt.in resGen/input1.txt COPYONLY)
configure_file(resGen/input2.txt.in resGen/input2.txt COPYONLY)
configure_file(resGen.qrc.in resGen.qrc COPYONLY)
# Generated qrc file with dependency
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/resGen.qrc.in
COMMAND ${CMAKE_COMMAND} -E sleep 2
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/resGen.qrc.in ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc
)
# Target that uses a plain .qrc file
add_executable(rccConfigChangePlain main.cpp resPlain.qrc)
target_link_libraries(rccConfigChangePlain ${QT_QTCORE_TARGET})
# Target that uses a GENERATED .qrc file
add_executable(rccConfigChangeGen main.cpp ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc )
target_link_libraries(rccConfigChangeGen ${QT_QTCORE_TARGET})

View File

@@ -0,0 +1,5 @@
int main()
{
return 0;
}

View File

@@ -0,0 +1,6 @@
<RCC>
<qresource prefix="/TextsGenerated">
<file>resGen/input1.txt</file>
<file>resGen/input2.txt</file>
</qresource>
</RCC>

View File

@@ -0,0 +1 @@
Generated resource input.

View File

@@ -0,0 +1 @@
Generated resource input.

View File

@@ -0,0 +1,6 @@
<RCC>
<qresource prefix="/TextsPlain">
<file>resPlain/input1.txt</file>
<file>resPlain/input2.txt</file>
</qresource>
</RCC>

View File

@@ -0,0 +1 @@
Plain resource input.

View File

@@ -0,0 +1 @@
Plain resource input.

View File

@@ -0,0 +1,5 @@
int main(int argv, char** args)
{
return 0;
}