diff options
author | Tobias Hunger <tobias.hunger@qt.io> | 2018-11-15 12:01:22 +0100 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@qt.io> | 2018-11-22 15:19:41 +0000 |
commit | 13e1c93e370551a7398d8e819b8ec4710def0151 (patch) | |
tree | 1e4e1655b83b46fb29d883825d118afbdb476f7a /cmake/QtBuild.cmake | |
parent | f4dc3dcacb61694915f45a0a0c47c85c21580d40 (diff) |
CMake: Add test for QRC and make it pass
Add a test for QRC file handling in cmake and fix the qrc file handling
to handle qrc files in subfolders properly.
Change-Id: Iff4224e59e7ee1badacce5fc00dbf68aef69bffe
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Diffstat (limited to 'cmake/QtBuild.cmake')
-rw-r--r-- | cmake/QtBuild.cmake | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index 771d04f3a7..c453e41334 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -358,21 +358,18 @@ endfunction() # This function creates the necessary rule to call rcc on the given # resource file and stores the name of the to-be generated C++ source # file (created by rcc) in the outCppFile variable. -function(qt_create_rcc_command resourceFile outCppFile) - get_filename_component(outfilename "${resourceFile}" NAME_WE) - get_filename_component(infile "${resourceFile}" ABSOLUTE) - set(generatedCppFile "${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cpp") - - qt_extract_qrc_dependencies("${infile}" _out_depends _rc_depends) +function(qt_create_rcc_command resourceFile source_dir binary_dir outfile) + qt_extract_qrc_dependencies("${infile}" out_depends rc_depends "${source_dir}" "${binary_dir}") set_source_files_properties("${infile}" PROPERTIES SKIP_AUTORCC ON) - add_custom_command(OUTPUT "${generatedCppFile}" - COMMAND "Qt::rcc" --name "${outfilename}" --output "${generatedCppFile}" "${infile}" + get_filename_component(outfilename "${resourceFile}" NAME_WE) + add_custom_command(OUTPUT "${outfile}" + COMMAND "Qt::rcc" --name "${outfilename}" --output "${outfile}" "${resourceFile}" MAIN_DEPENDENCY "${infile}" - DEPENDS "${_rc_depends}" "${_out_depends}" VERBATIM) - set_source_files_properties("${generatedCppFile}" PROPERTIES SKIP_AUTOMOC ON) - set_source_files_properties("${generatedCppFile}" PROPERTIES SKIP_AUTOUIC ON) - set("${outCppFile}" "${generatedCppFile}" PARENT_SCOPE) + DEPENDS "${rc_depends}" "${out_depends}" + WORKING_DIRECTORY "${source_dir}" VERBATIM) + set_source_files_properties("${outfile}" PROPERTIES SKIP_AUTOMOC ON) + set_source_files_properties("${outfile}" PROPERTIES SKIP_AUTOUIC ON) endfunction() @@ -380,20 +377,25 @@ endfunction() # Any sources ending with the .qrc extension are treated as Qt resources and rules # to call rcc are generated. The source files rcc generates are added to the target. function(qt_internal_autorcc target) - if ("x${ARGN}" STREQUAL "x") - return() - endif() + get_target_property(binary_dir "${target}" BINARY_DIR) + get_target_property(source_dir "${target}" SOURCE_DIR) - set(_qrc_cpp_files "") + set(qrc_outfiles "") - foreach(s ${ARGN}) - get_filename_component(ext "${s}" EXT) + foreach(infile ${ARGN}) + get_filename_component(ext "${infile}" EXT) if("${ext}" STREQUAL ".qrc") - qt_create_rcc_command("${s}" _qrc_cpp_file) - list(APPEND _qrc_cpp_files "${_qrc_cpp_file}") + qt_make_output_file("${infile}" "qrc_" ".cpp" "${source_dir}" "${binary_dir}" outfile) + list(FIND all_sources "${outfile}" known_result) + if (known_result GREATER -1) + continue() + endif() + + qt_create_rcc_command("${infile}" "${source_dir}" "${binary_dir}" "${outfile}") + list(APPEND qrc_outfiles "${outfile}") endif() endforeach() - target_sources("${target}" PRIVATE "${_qrc_cpp_files}") + target_sources("${target}" PRIVATE "${qrc_outfiles}") endfunction() |