CMake: Don't handle empty resource files

[ChangeLog][Qml] Empty resource files will not be passed to Qt
Quick Compiler to be handled when using CMake.

Change-Id: I1513d29b70d8a4b08a2947f4a97fbd525c5ace8f
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
Andy Shaw 2018-12-11 12:09:38 +01:00
parent 12f89fb8dd
commit eb1f9c2e68
3 changed files with 13 additions and 11 deletions

View File

@ -9,7 +9,7 @@ find_package(Qt5QuickCompiler)
set(CMAKE_CXXFLAGS "${CMAKE_CXXFLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") set(CMAKE_CXXFLAGS "${CMAKE_CXXFLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")
qtquick_compiler_add_resources(RESOURCES "resources with space/qqc_test.qrc") qtquick_compiler_add_resources(RESOURCES "empty.qrc" "resources with space/qqc_test.qrc")
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)

View File

@ -61,16 +61,18 @@ but not all the files it references.
set(rcc_file_with_compilation_units) set(rcc_file_with_compilation_units)
execute_process(COMMAND ${rcc_path} -list \"${input_resource}\" OUTPUT_VARIABLE rcc_contents) execute_process(COMMAND ${rcc_path} -list \"${input_resource}\" OUTPUT_VARIABLE rcc_contents)
string(REGEX REPLACE \"[\r\n]+\" \";\" rcc_contents ${rcc_contents}) if (NOT rcc_contents STREQUAL \"\")
foreach(it ${rcc_contents}) string(REGEX REPLACE \"[\r\n]+\" \";\" rcc_contents ${rcc_contents})
get_filename_component(extension ${it} EXT) foreach(it ${rcc_contents})
if(extension STREQUAL \".qml\" OR extension STREQUAL \".js\" OR extension STREQUAL \".ui.qml\" OR extension STREQUAL \".mjs\") get_filename_component(extension ${it} EXT)
qtquick_compiler_determine_output_filename(output_file ${it}) if(extension STREQUAL \".qml\" OR extension STREQUAL \".js\" OR extension STREQUAL \".ui.qml\" OR extension STREQUAL \".mjs\")
add_custom_command(OUTPUT ${output_file} COMMAND ${compiler_path} ARGS --resource=${input_resource} ${it} -o ${output_file} DEPENDS ${it}) qtquick_compiler_determine_output_filename(output_file ${it})
list(APPEND compiler_output ${output_file}) add_custom_command(OUTPUT ${output_file} COMMAND ${compiler_path} ARGS --resource=${input_resource} ${it} -o ${output_file} DEPENDS ${it})
set(rcc_file_with_compilation_units ${input_resource}) list(APPEND compiler_output ${output_file})
endif() set(rcc_file_with_compilation_units ${input_resource})
endforeach() endif()
endforeach()
endif()
if(rcc_file_with_compilation_units) if(rcc_file_with_compilation_units)
list(APPEND rcc_files_with_compilation_units ${rcc_file_with_compilation_units}) list(APPEND rcc_files_with_compilation_units ${rcc_file_with_compilation_units})