diff options
| author | Arjen Hiemstra <ahiemstra@heimr.nl> | 2022-01-19 14:14:00 +0100 | 
|---|---|---|
| committer | Arjen Hiemstra <ahiemstra@heimr.nl> | 2022-01-21 11:56:14 +0000 | 
| commit | 5069d782f38826be1e6edb24383a19bde9c16d05 (patch) | |
| tree | d202b2c2bb2c3fc7460b4a7234b0c954834f6cea /modules | |
| parent | 457904e1519aba0e854266889bdd4f0bd1694c4b (diff) | |
| download | extra-cmake-modules-5069d782f38826be1e6edb24383a19bde9c16d05.tar.gz extra-cmake-modules-5069d782f38826be1e6edb24383a19bde9c16d05.tar.bz2  | |
ECMQmlModule: Correct the prefix of the generated qrc to be what Qt expects
When the major version of a module is >1, Qt expects a .MajorVersion
suffix on the module path. Since we are already doing this for the
shared library install path, extract that code to a shared macro and
reuse it for the prefix path in the generated qrc.
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/ECMQmlModule.cmake | 25 | 
1 files changed, 17 insertions, 8 deletions
diff --git a/modules/ECMQmlModule.cmake b/modules/ECMQmlModule.cmake index 2e5147ae..aaff5dde 100644 --- a/modules/ECMQmlModule.cmake +++ b/modules/ECMQmlModule.cmake @@ -135,6 +135,19 @@ macro(_ecm_qmlmodule_verify_qml_target ARG_TARGET)      endif()  endmacro() +macro(_ecm_qmlmodule_uri_to_path ARG_OUTPUT ARG_PATH ARG_VERSION) +    string(REPLACE "." "/" _output "${ARG_PATH}") + +    # If the major version of the module is >2.0, Qt expects a ".MajorVersion" +    # suffix on the directory. So handle that. +    if (${ARG_VERSION} VERSION_GREATER_EQUAL 2.0) +        string(REGEX MATCH "^([0-9]+)" _version_major ${ARG_VERSION}) +        set("${ARG_OUTPUT}" "${_output}.${_version_major}") +    else() +        set("${ARG_OUTPUT}" "${_output}") +    endif() +endmacro() +  function(_ecm_qmlmodule_generate_qmldir ARG_TARGET)      get_target_property(_qml_uri ${ARG_TARGET} ${_ECM_QMLMODULE_PROPERTY_URI})      get_target_property(_qml_files ${ARG_TARGET} ${_ECM_QMLMODULE_PROPERTY_FILES}) @@ -182,12 +195,13 @@ function(_ecm_qmlmodule_generate_qrc ARG_TARGET)      get_target_property(_qml_uri ${ARG_TARGET} ${_ECM_QMLMODULE_PROPERTY_URI})      get_target_property(_qml_files ${ARG_TARGET} ${_ECM_QMLMODULE_PROPERTY_FILES})      get_target_property(_qmldir_file ${ARG_TARGET} ${_ECM_QMLMODULE_PROPERTY_QMLDIR}) +    get_target_property(_qml_version ${ARG_TARGET} ${_ECM_QMLMODULE_PROPERTY_VERSION}) -    string(REPLACE "." "/" _qml_prefix ${_qml_uri}) +    _ecm_qmlmodule_uri_to_path(_qml_prefix "${_qml_uri}" "${_qml_version}")      set(_qrc_template "<!-- This file was automatically generated by ECMQmlModule and should not be modified -->") -    string(APPEND _qrc_template "\n<RCC>\n<qresource prefix=\"${_qml_prefix}\">") +    string(APPEND _qrc_template "\n<RCC>\n<qresource prefix=\"/${_qml_prefix}\">")      string(APPEND _qrc_template "\n<file alias=\"qmldir\">${_qmldir_file}</file>")      foreach(_file ${_qml_files}) @@ -325,12 +339,7 @@ function(ecm_finalize_qml_module ARG_TARGET)      get_target_property(_qml_uri ${ARG_TARGET} ${_ECM_QMLMODULE_PROPERTY_URI})      get_target_property(_version ${ARG_TARGET} ${_ECM_QMLMODULE_PROPERTY_VERSION}) -    string(REPLACE "." "/" _plugin_path "${_qml_uri}") - -    if (${_version} VERSION_GREATER_EQUAL 2.0) -        string(REGEX MATCH "^([0-9]+)" _version_major ${_version}) -        set(_plugin_path "${_plugin_path}.${_version_major}") -    endif() +    _ecm_qmlmodule_uri_to_path(_plugin_path "${_qml_uri}" "${_version}")      get_target_property(_qml_only ${ARG_TARGET} ${_ECM_QMLMODULE_PROPERTY_QMLONLY})  | 
