cmake-qml-plugin-example icon indicating copy to clipboard operation
cmake-qml-plugin-example copied to clipboard

Install missing

Open machinekoder opened this issue 6 years ago • 2 comments

Unfortunately, this example is missing the install step. QML plugins / modules / extensions (whatever you may call it) should be installed in QT_INSTALL_QML. Please take a look at the QMake equivalent generated by Qt Creator.

machinekoder avatar Aug 19 '18 16:08 machinekoder

Something along the lines of

set(URI QuickContainers)
string(REPLACE "." "/" TARGETPATH ${URI})
execute_process(COMMAND qmake -query QT_INSTALL_QML OUTPUT_VARIABLE QT_INSTALL_QML_RAW)
string(REPLACE "\n" "" QT_INSTALL_QML ${QT_INSTALL_QML_RAW})
set(DESTDIR "${QT_INSTALL_QML}/${TARGETPATH}")
install(TARGETS QuickContainers DESTINATION ${DESTDIR})

should do the trick.

Note that querying qmake isn't really nice, but seems to be the only option at the moment.

machinekoder avatar Aug 19 '18 18:08 machinekoder

Thank you, this was a great help. I'd just like to add: The URI has to be the name of the module and the TARGETS has to be the plugin specified in the qmldir. In the sample they are both QuickContainers but in other cases they may vary. Also, this is missing the step to install the qmldir file:

install(FILES ${CMAKE_CURRENT_LIST_DIR}/qmldir DESTINATION ${DESTDIR})

StefanFabian avatar Mar 25 '19 11:03 StefanFabian