diff options
author | Tobias Hunger <tobias.hunger@qt.io> | 2019-03-07 10:05:10 +0100 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@qt.io> | 2019-03-11 09:14:33 +0000 |
commit | becbe4df3a7f493c0d3e40f29495279f503d3895 (patch) | |
tree | 2ee11d8b0b52e4e2bc3a8a68346b0d74779a4b58 /cmake | |
parent | 4471249d33dd1b1e87ee5f2881c7341fc1f43c64 (diff) |
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 <simon.hausmann@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/QtBuild.cmake | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index 09e9899bc5..6eabccb83c 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 "<RCC>") - if (${rcc_PREFIX}) - string(APPEND qrcContents " <qresource>\n") - else() - string(APPEND qrcContents " <qresource prefix=\"${rcc_PREFIX}\">\n") + # Generate .qrc file: + + # <RCC><qresource ...> + set(qrcContents "<RCC>\n <qresource") + if (rcc_PREFIX) + string(APPEND qrcContents " prefix=\"${rcc_PREFIX}\"") endif() + if (rcc_LANG) + string(APPEND qrcContents " lang=\"${rcc_LANG}\"") + endif() + string(APPEND qrcContents ">\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 " <file alias=\"${alias}\">${CMAKE_CURRENT_SOURCE_DIR}/${file}</file>\n") + # <file ...>...</file> + string(APPEND qrcContents " <file alias=\"${alias}\">") + string(APPEND qrcContents "${CMAKE_CURRENT_SOURCE_DIR}/${based_file}</file>\n") endforeach() + # </qresource></RCC> string(APPEND qrcContents " </qresource>\n</RCC>\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" |