QtAutogen: Workaround rcc CRCRLF newlines on Windows (#15459)

The 'rcc --list' operation may print newlines of the form CRCRLF,
so strip any trailing CR characters found on each line.

Update the Tests/QtAutogen test to use a resource named in a
subdirectory.  This causes 'rcc --list' to display a blank line
and tests that it is correctly filtered out.
This commit is contained in:
Brad King 2015-04-16 12:51:05 -04:00
parent 15f1a6b499
commit e8fdd5f12a
5 changed files with 10 additions and 3 deletions

View File

@ -201,6 +201,13 @@ std::string cmQtAutoGenerators::ListQt5RccInputs(cmSourceFile* sf,
std::string oline;
while(std::getline(ostr, oline))
{
// Strip CR characters rcc may have printed (possibly more than one!).
std::string::size_type cr = oline.find('\r');
if (cr != oline.npos)
{
oline = oline.substr(0, cr);
}
if (oline.empty())
{
// The output of rcc --list contains many empty lines.

View File

@ -147,7 +147,7 @@ set(timeformat "%Y%j%H%M%S")
file(TIMESTAMP "${qrc_file1}" file1_before "${timeformat}")
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}/autorcc_depends/res1_input.txt")
execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${CMAKE_CURRENT_BINARY_DIR}/autorcc_depends/res1/input.txt")
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/autorcc_depends"

View File

@ -16,7 +16,7 @@ else()
endif()
configure_file(res1.qrc.in res1.qrc @ONLY)
configure_file(res1_input.txt.in res1_input.txt @ONLY)
configure_file(res1/input.txt.in res1/input.txt @ONLY)
add_executable(test_res1
test_res1.cpp

View File

@ -1,5 +1,5 @@
<RCC>
<qresource prefix="/">
<file>res1_input.txt</file>
<file>res1/input.txt</file>
</qresource>
</RCC>