From 5f242ab8041ed86448cc641f3e874847fa74a086 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 6 Mar 2024 16:34:40 +0100 Subject: [PATCH] CMake: Adjust QT_ADDITIONAL_QML_PLUGIN_GLOB_PREFIXES for EP examples Make sure to consider all qt_prefixes for adjusting QT_ADDITIONAL_QML_PLUGIN_GLOB_PREFIXES with locations where qml plugin config files might be present. Task-number: QTBUG-90820 Task-number: QTBUG-96232 Change-Id: I5a7eec434635db1953871d735e2420c331ccee48 Reviewed-by: Joerg Bornemann (cherry picked from commit 06fef6219e992489dae15e9851725e1675ff0bf6) Reviewed-by: Alexey Edelev --- cmake/QtBuildRepoExamplesHelpers.cmake | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cmake/QtBuildRepoExamplesHelpers.cmake b/cmake/QtBuildRepoExamplesHelpers.cmake index da8a44e4d0d..fc130aa8c58 100644 --- a/cmake/QtBuildRepoExamplesHelpers.cmake +++ b/cmake/QtBuildRepoExamplesHelpers.cmake @@ -312,6 +312,22 @@ function(qt_internal_add_example_external_project subdir) list(TRANSFORM module_paths APPEND "/${INSTALL_LIBDIR}/cmake/${QT_CMAKE_EXPORT_NAMESPACE}") list(APPEND CMAKE_MODULE_PATH ${module_paths}) + # Pass additional paths where qml plugin config files should be included by Qt6QmlPlugins.cmake. + # This is needed in prefix builds, where the cmake files are not installed yet. + set(glob_prefixes "${qt_prefixes}") + list(TRANSFORM glob_prefixes APPEND "/${INSTALL_LIBDIR}/cmake/${QT_CMAKE_EXPORT_NAMESPACE}Qml") + + set(qml_plugin_cmake_config_file_glob_prefixes "") + foreach(glob_prefix IN LISTS glob_prefix) + if(EXISTS "${glob_prefix}") + list(APPEND qml_plugin_cmake_config_file_glob_prefixes "${glob_prefix}") + endif() + endforeach() + + if(qml_plugin_cmake_config_file_glob_prefixes) + set(QT_ADDITIONAL_QML_PLUGIN_GLOB_PREFIXES ${qml_plugin_cmake_config_file_glob_prefixes}) + endif() + # In multi-config mode by default we exclude building tools for configs other than the main one. # Trying to build an example in a non-default config using the non-installed # QtFooConfig.cmake files would error out saying moc is not found. @@ -378,6 +394,7 @@ function(qt_internal_add_example_external_project subdir) CMAKE_PREFIX_PATH:STRING QT_BUILD_CMAKE_PREFIX_PATH:STRING QT_ADDITIONAL_PACKAGES_PREFIX_PATH:STRING + QT_ADDITIONAL_QML_PLUGIN_GLOB_PREFIXES:STRING CMAKE_FIND_ROOT_PATH:STRING CMAKE_MODULE_PATH:STRING BUILD_SHARED_LIBS:BOOL