aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/Qt6QmlMacros.cmake
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@qt.io>2021-02-15 12:41:11 +1100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-02-24 01:02:16 +0000
commitae68d95b8c1c56ae907cbe88122dd79bafd20b72 (patch)
tree7d3f15285eace3c456be3380707097d917b34018 /src/qml/Qt6QmlMacros.cmake
parent0d5847292b36896a23e5ccb6fca40e09c3a6d13d (diff)
Add finalizer to call qt6_import_qml_plugins() automatically
Any target created by a call to qt6_add_executable() that also links to the Qml target will now automatically call qt6_import_qml_plugins() in qt6_finalize_executable() for scenarios that need it. This is only relevant for static builds and only when not doing a top level Qt superbuild. The finalizers feature requires CMake 3.18. If using an earlier CMake version, the project is still responsible for calling qt6_import_qml_plugins() itself. Fixes: QTBUG-86669 Change-Id: I0f0b3f700ab6f1240b2373cb4155f52dc8991d2e Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit c71c48f5125c116f01f615f51f10e4f2877b2b1d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/qml/Qt6QmlMacros.cmake')
-rw-r--r--src/qml/Qt6QmlMacros.cmake11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/qml/Qt6QmlMacros.cmake b/src/qml/Qt6QmlMacros.cmake
index 01ee8fc4d4..2dfd02cbf6 100644
--- a/src/qml/Qt6QmlMacros.cmake
+++ b/src/qml/Qt6QmlMacros.cmake
@@ -1084,10 +1084,21 @@ endfunction()
include(CMakeParseArguments)
+# This function is called as a finalizer in qt6_finalize_executable() for any
+# target that links against the Qml library for a statically built Qt.
function(qt6_import_qml_plugins target)
if(QT6_IS_SHARED_LIBS_BUILD)
return()
endif()
+
+ # Protect against being called multiple times in case we are being called
+ # explicitly before the finalizer is invoked.
+ get_target_property(alreadyImported ${target} _QT_QML_PLUGINS_IMPORTED)
+ if(alreadyImported)
+ return()
+ endif()
+ set_target_properties(${target} PROPERTIES _QT_QML_PLUGINS_IMPORTED TRUE)
+
set(options)
set(oneValueArgs "PATH_TO_SCAN")
set(multiValueArgs)