From 95c27e325f47cff168a85c21b4b9e592168384f9 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 9 Aug 2019 12:47:55 +0200 Subject: 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 Reviewed-by: Leander Beernaert --- cmake/QtBuild.cmake | 3 ++ src/plugins/platforms/eglfs/.prev_CMakeLists.txt | 34 +++++----------------- src/plugins/platforms/eglfs/CMakeLists.txt | 11 ++++--- tests/auto/corelib/kernel/qvariant/CMakeLists.txt | 11 +++++-- .../access/qnetworkreply/test/CMakeLists.txt | 5 ++++ tests/auto/opengl/qgl/CMakeLists.txt | 13 ++++++--- tests/auto/widgets/dialogs/qwizard/CMakeLists.txt | 16 ++++++---- tests/auto/widgets/kernel/qwidget/CMakeLists.txt | 17 ++++++----- util/cmake/pro2cmake.py | 5 ++-- 9 files changed, 62 insertions(+), 53 deletions(-) diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index 8ef77d6726..e14d7c1391 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -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 diff --git a/src/plugins/platforms/eglfs/.prev_CMakeLists.txt b/src/plugins/platforms/eglfs/.prev_CMakeLists.txt index e747e1d3c1..0f7c305a40 100644 --- a/src/plugins/platforms/eglfs/.prev_CMakeLists.txt +++ b/src/plugins/platforms/eglfs/.prev_CMakeLists.txt @@ -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() diff --git a/src/plugins/platforms/eglfs/CMakeLists.txt b/src/plugins/platforms/eglfs/CMakeLists.txt index 6705e40e0d..510a606152 100644 --- a/src/plugins/platforms/eglfs/CMakeLists.txt +++ b/src/plugins/platforms/eglfs/CMakeLists.txt @@ -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) - diff --git a/tests/auto/corelib/kernel/qvariant/CMakeLists.txt b/tests/auto/corelib/kernel/qvariant/CMakeLists.txt index 2273dafd79..b611bece63 100644 --- a/tests/auto/corelib/kernel/qvariant/CMakeLists.txt +++ b/tests/auto/corelib/kernel/qvariant/CMakeLists.txt @@ -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:: diff --git a/tests/auto/network/access/qnetworkreply/test/CMakeLists.txt b/tests/auto/network/access/qnetworkreply/test/CMakeLists.txt index df589b67da..ae7a4d0fe0 100644 --- a/tests/auto/network/access/qnetworkreply/test/CMakeLists.txt +++ b/tests/auto/network/access/qnetworkreply/test/CMakeLists.txt @@ -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 diff --git a/tests/auto/opengl/qgl/CMakeLists.txt b/tests/auto/opengl/qgl/CMakeLists.txt index c259f069a9..5d1ef8bbbf 100644 --- a/tests/auto/opengl/qgl/CMakeLists.txt +++ b/tests/auto/opengl/qgl/CMakeLists.txt @@ -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:: diff --git a/tests/auto/widgets/dialogs/qwizard/CMakeLists.txt b/tests/auto/widgets/dialogs/qwizard/CMakeLists.txt index daefe76139..4f8e9a4a5c 100644 --- a/tests/auto/widgets/dialogs/qwizard/CMakeLists.txt +++ b/tests/auto/widgets/dialogs/qwizard/CMakeLists.txt @@ -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:: diff --git a/tests/auto/widgets/kernel/qwidget/CMakeLists.txt b/tests/auto/widgets/kernel/qwidget/CMakeLists.txt index 86d02ac733..fca2c313a1 100644 --- a/tests/auto/widgets/kernel/qwidget/CMakeLists.txt +++ b/tests/auto/widgets/kernel/qwidget/CMakeLists.txt @@ -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:: @@ -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 diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index 794b2ec2ef..097ed38f06 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -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, -- cgit v1.2.3