Search code examples
qtcmakeqml

Qt QML distinct URIs within a module


Is it possible for one to create a single module which supports multiple URIs?

Something like:

qt_add_qml_module(proj1
    URI proj1
    QML_FILES qml/Debug1.qml)

qt_target_qml_sources(proj1
    URI proj1.extra
    QML_FILES qml/x/Debug2.qml)

with a QML consuming it like:

import proj1
import proj1.extra as Extra

Item {
    Extra.Debug2 {
    }
}

Solution

  • The technical answer to my question is no.

    Functionally, however, what @JarMan implies and @smr suggests gets close enough for me when put into one CMakeLists.txt

    Solution looks something like:

    project(proj1-meta)
    
    qt_add_qml_module(proj1
        URI proj1
        QML_FILES qml/Debug1.qml)
    
    qt_add_qml_module(proj1-extra
        URI proj1.extra
        QML_FILES qml/x/Debug2.qml)
    
    target_link_libraries(${PROJECT_NAME} proj1plugin proj1-extraplugin)
    

    Requiring all the extra linking and setup that each Qt module needs. I aggregated them all into one meta project to simulate one library.