Fix add_qt_resource behavior with regards to unspecified prefixes

This change makes the PREFIX parameter a required parameter if the
target does not specify a default. This way the behavior is clear when
reading the code: add_qt_resource() without PREFIX means it must come
frmo the target.

Change-Id: I79024e70e7b4d32a5164b93aa08ec9ff409b2d39
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
This commit is contained in:
Simon Hausmann 2019-08-09 12:47:55 +02:00
parent aaec072623
commit 95c27e325f
9 changed files with 62 additions and 53 deletions

View File

@ -2541,6 +2541,9 @@ function(add_qt_resource target resourceName)
if(NOT rcc_PREFIX)
get_target_property(rcc_PREFIX ${target} QT_RESOURCE_PREFIX)
if (NOT rcc_PREFIX)
message(FATAL_ERROR "add_qt_resource() was called without a PREFIX and the target does not provide QT_RESOURCE_PREFIX. Please either add a PREFIX or make the target ${target} provide a default.")
endif()
endif()
# Apply quick compiler pass

View File

@ -77,9 +77,13 @@ extend_target(EglFSDeviceIntegration CONDITION NOT EGLFS_DEVICE_INTEGRATION_ISEM
# CONFIG = "no_linker_version_script"
# Resources:
add_qt_resource(EglFSDeviceIntegration "cursor" FILES
cursor-atlas.png
cursor.json)
add_qt_resource(EglFSDeviceIntegration "cursor"
PREFIX
"/"
FILES
cursor-atlas.png
cursor.json
)
extend_target(EglFSDeviceIntegration CONDITION QT_FEATURE_opengl
@ -119,27 +123,3 @@ add_qt_plugin(qeglfs
#### Keys ignored in scope 12:.:.:eglfs-plugin.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN:
# PLUGIN_EXTENDS = "-"
add_subdirectory(deviceintegration)
if(TARGET Qt::InputSupportPrivate)
endif()
if(TARGET Qt::PlatformCompositorSupportPrivate)
endif()
if(NOT EGLFS_PLATFORM_HOOKS_SOURCES_ISEMPTY)
endif()
if(NOT EGLFS_DEVICE_INTEGRATION_ISEMPTY)
endif()
if(use_gold_linker)
endif()
if(NOT DEFINES___contains___QT_NO_CURSOR)
endif()
if(QT_FEATURE_opengl)
endif()
if(NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN)
endif()

View File

@ -63,9 +63,13 @@ extend_target(EglFSDeviceIntegration CONDITION TARGET Qt::PlatformCompositorSupp
# CONFIG = "no_linker_version_script"
# Resources:
add_qt_resource(EglFSDeviceIntegration "cursor" FILES
cursor-atlas.png
cursor.json)
add_qt_resource(EglFSDeviceIntegration "cursor"
PREFIX
"/"
FILES
cursor-atlas.png
cursor.json
)
extend_target(EglFSDeviceIntegration CONDITION QT_FEATURE_opengl
@ -106,4 +110,3 @@ add_qt_plugin(qeglfs
#### Keys ignored in scope 12:.:.:eglfs-plugin.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN:
# PLUGIN_EXTENDS = "-"
add_subdirectory(deviceintegration)

View File

@ -5,6 +5,7 @@
#####################################################################
add_qt_test(tst_qvariant
GUI
SOURCES
tst_qvariant.cpp
DEFINES
@ -16,9 +17,13 @@ add_qt_test(tst_qvariant
)
# Resources:
add_qt_resource(tst_qvariant "qvariant" FILES
stream/qt4.9/
stream/qt5.0/)
add_qt_resource(tst_qvariant "qvariant"
PREFIX
"/"
FILES
stream/qt4.9/
stream/qt5.0/
)
#### Keys ignored in scope 1:.:.:qvariant.pro:<TRUE>:

View File

@ -35,7 +35,12 @@ add_qt_test(tst_qnetworkreply
)
# Resources:
set_source_files_properties("../resource"
PROPERTIES alias "resource"
)
add_qt_resource(tst_qnetworkreply "qnetworkreply"
PREFIX
"/"
BASE
".."
FILES

View File

@ -5,6 +5,7 @@
#####################################################################
add_qt_test(tst_qgl
GUI
SOURCES
tst_qgl.cpp
LIBRARIES
@ -13,7 +14,6 @@ add_qt_test(tst_qgl
Qt::OpenGLPrivate
Qt::WidgetsPrivate
PUBLIC_LIBRARIES
Qt::Core
Qt::Gui
Qt::OpenGL
Qt::Widgets
@ -21,9 +21,14 @@ add_qt_test(tst_qgl
# Resources:
set_source_files_properties("../../gui/image/qpixmap/images/designer.png"
PROPERTIES alias "designer.png")
add_qt_resource(tst_qgl "qgl" FILES
../../gui/image/qpixmap/images/designer.png)
PROPERTIES alias "designer.png"
)
add_qt_resource(tst_qgl "qgl"
PREFIX
"/"
FILES
../../gui/image/qpixmap/images/designer.png
)
#### Keys ignored in scope 1:.:.:qgl.pro:<TRUE>:

View File

@ -5,19 +5,25 @@
#####################################################################
add_qt_test(tst_qwizard
GUI
SOURCES
tst_qwizard.cpp
tst_qwizard_2.cpp
PUBLIC_LIBRARIES
Qt::Gui
Qt::Widgets
)
# Resources:
add_qt_resource(tst_qwizard "qwizard" FILES
images/background.png
images/banner.png
images/logo.png
images/watermark.png)
add_qt_resource(tst_qwizard "qwizard"
PREFIX
"/"
FILES
images/background.png
images/banner.png
images/logo.png
images/watermark.png
)
#### Keys ignored in scope 1:.:.:qwizard.pro:<TRUE>:

View File

@ -5,6 +5,7 @@
#####################################################################
add_qt_test(tst_qwidget
GUI
SOURCES
tst_qwidget.cpp
LIBRARIES
@ -13,17 +14,19 @@ add_qt_test(tst_qwidget
Qt::TestPrivate
Qt::WidgetsPrivate
PUBLIC_LIBRARIES
Qt::Core
Qt::Gui
Qt::Test
Qt::Widgets
)
# Resources:
add_qt_resource(tst_qwidget "qwidget" FILES
geometry-fullscreen.dat
geometry-maximized.dat
geometry.dat)
add_qt_resource(tst_qwidget "qwidget"
PREFIX
"/"
FILES
geometry-fullscreen.dat
geometry-maximized.dat
geometry.dat
)
#### Keys ignored in scope 1:.:.:qwidget.pro:<TRUE>:
@ -33,7 +36,7 @@ add_qt_resource(tst_qwidget "qwidget" FILES
## Scopes:
#####################################################################
extend_target(tst_qwidget CONDITION APPLE_OSX
extend_target(tst_qwidget CONDITION APPLE
SOURCES
tst_qwidget_mac_helpers.mm
PUBLIC_LIBRARIES

View File

@ -152,7 +152,7 @@ def process_qrc_file(target: str, filepath: str, base_dir: str = '', project_fil
for resource in root:
assert(resource.tag == 'qresource')
lang = resource.get('lang', '')
prefix = resource.get('prefix', '')
prefix = resource.get('prefix', '/')
full_resource_name = resource_name + (str(resource_count) if resource_count > 0 else '')
@ -192,8 +192,7 @@ def process_qrc_file(target: str, filepath: str, base_dir: str = '', project_fil
params = ''
if lang:
params += ' LANG\n "{}"\n'.format(lang)
if prefix:
params += ' PREFIX\n "{}"\n'.format(prefix)
params += ' PREFIX\n "{}"\n'.format(prefix)
if base_dir:
params += ' BASE\n "{}"\n'.format(base_dir)
output += 'add_qt_resource({} "{}"\n{} FILES\n {}\n)\n'.format(target, full_resource_name,