diff options
-rw-r--r-- | src/qml/Qt6QmlMacros.cmake | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/qml/Qt6QmlMacros.cmake b/src/qml/Qt6QmlMacros.cmake index 733dd6725e..7cf2e9bef4 100644 --- a/src/qml/Qt6QmlMacros.cmake +++ b/src/qml/Qt6QmlMacros.cmake @@ -371,8 +371,19 @@ function(qt6_add_qml_module target) # Embed qmldir in static builds if (is_static) + # The qmldir resource name needs to match the one generated by qmake's qml_module.prf, to + # ensure that all Q_INIT_RESOURCE(resource_name) calls in Qt code don't lead to undefined + # symbol errors when linking an application project. + # The Q_INIT_RESOURCE() calls are not strictly necessary anymore because the CMake Qt + # build passes around the compiled resources as object files. + # These object files have global initiliazers that don't get discared when linked into + # an application (as opposed to when the resource libraries were embedded into the static + # libraries when Qt was built with qmake). + # The reason to match the naming is to ensure that applications link successfully regardless + # if Qt was built with CMake or qmake, while the build system transition phase is still + # happening. string(REPLACE "/" "_" qmldir_resource_name ${arg_TARGET_PATH}) - string(APPEND qmldir_resource_name "_qmldir") + string(PREPEND qmldir_resource_name "qmake_") set_source_files_properties("${qmldir_file}" PROPERTIES QT_RESOURCE_ALIAS "qmldir" |