From becbe4df3a7f493c0d3e40f29495279f503d3895 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Thu, 7 Mar 2019 10:05:10 +0100 Subject: [PATCH] Improve add_qt_resource function * Handle BASE to give the directory files will be relative to. * Support lang="foo" for qresource sections. Change-Id: I36087220d03789a97105dc6dd1aca7a25a063d9f Reviewed-by: Simon Hausmann --- cmake/QtBuild.cmake | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index 09e9899bc53..6eabccb83c2 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -870,28 +870,44 @@ endfunction() function(add_qt_resource target resourceName) - qt_parse_all_arguments(rcc "add_qt_resource" "" "PREFIX;BASE" "FILES" ${ARGN}) + qt_parse_all_arguments(rcc "add_qt_resource" "" "PREFIX;LANG;BASE" "FILES" ${ARGN}) - set(qrcContents "") - if (${rcc_PREFIX}) - string(APPEND qrcContents " \n") - else() - string(APPEND qrcContents " \n") + # Generate .qrc file: + + # + set(qrcContents "\n \n") foreach(file ${rcc_FILES}) - get_property(alias SOURCE ${file} PROPERTY alias) + if(rcc_BASE) + set(based_file "${rcc_BASE}/${file}") + else() + set(based_file "${file}") + endif() + get_property(alias SOURCE ${based_file} PROPERTY alias) if (NOT alias) set(alias "${file}") endif() ### FIXME: escape file paths to be XML conform - string(APPEND qrcContents " ${CMAKE_CURRENT_SOURCE_DIR}/${file}\n") + # ... + string(APPEND qrcContents " ") + string(APPEND qrcContents "${CMAKE_CURRENT_SOURCE_DIR}/${based_file}\n") endforeach() + # string(APPEND qrcContents " \n\n") + set(generatedResourceFile "${CMAKE_CURRENT_BINARY_DIR}/${resourceName}.qrc") file(GENERATE OUTPUT "${generatedResourceFile}" CONTENT "${qrcContents}") + # Process .qrc file: + set(generatedSourceCode "${CMAKE_CURRENT_BINARY_DIR}/qrc_${resourceName}.cpp") add_custom_command(OUTPUT "${generatedSourceCode}" COMMAND "${QT_CMAKE_EXPORT_NAMESPACE}::rcc"