Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Equivalent of CONFIG+=qmltypes in CMake build?



  • Hello.
    I just found out about the new way to expose C++ types to QML using the
    QML_ELEMENT macro, as described e.g. here.

    To test it with CMake builds, I converted the Adding example
    Qt/Examples/Qt-5.15.0/qml/referenceexamples/adding
    to a CMake project.

    While it runs fine when using the old way of registering the type with

    qmlRegisterType<Person>("People", 1,0, "Person");
    

    it fails when commenting that line out (and uncommenting the QML_ELEMENT macro):

    QQmlComponent: Component is not ready
    (qrc:example.qml:52:1: module "People" is not installed
        import People 1.0
        ^)
    

    I assume it has to do with not having used the CMake equivalent of the following .pro line:

    CONFIG+=qmltypes
    

    But, what is the CMake equivalent of the above CONFIG flag?

    Thanks for your help!


Log in to reply