Qt 6.11 is out! See what's new in the release
blog
Installing CMake static target with QML module
-
Hi everyone,
I have a static library target with a QML module that works fine in its own project and installs as well. But another project uses the installed library gives an error saying:
Objects of target "QTTest::GuiA_resources_1" referenced but is not one of the allowed target types (EXECUTABLE, STATIC, SHARED, MODULE, OBJECT).I used the code below to create the qml module and install the target.
qt_add_qml_module(GuiA URI qttest OUTPUT_DIRECTORY qtbin/qttest OUTPUT_TARGETS _qt_output_targets QML_FILES qml/Ascreen.qml ) # Value of the _qt_output_targets = GuiA_resources_1;GuiA_resources_2;GuiA_resources_3;GuiAplugin_init install( TARGETS GuiA ${_qt_output_targets} EXPORT GuiATargets )What am I doint wrong here?
-
Found the solution. Had to give destination for object files and add generated GuiAplugin target to installed targets. Final install code lokes like this:
install( TARGETS GuiA GuiAplugin ${_qt_output_targets} EXPORT GuiATargets FILE_SET HEADERS DESTINATION include RUNTIME DESTINATION $<IF:$<CONFIG:Debug>,debug/bin,bin> LIBRARY DESTINATION $<IF:$<CONFIG:Debug>,debug/lib,lib> ARCHIVE DESTINATION $<IF:$<CONFIG:Debug>,debug/lib,lib> OBJECTS DESTINATION $<IF:$<CONFIG:Debug>,debug/obj,obj> ) -
Also facing the exact same issue.
-
Found the solution. Had to give destination for object files and add generated GuiAplugin target to installed targets. Final install code lokes like this:
install( TARGETS GuiA GuiAplugin ${_qt_output_targets} EXPORT GuiATargets FILE_SET HEADERS DESTINATION include RUNTIME DESTINATION $<IF:$<CONFIG:Debug>,debug/bin,bin> LIBRARY DESTINATION $<IF:$<CONFIG:Debug>,debug/lib,lib> ARCHIVE DESTINATION $<IF:$<CONFIG:Debug>,debug/lib,lib> OBJECTS DESTINATION $<IF:$<CONFIG:Debug>,debug/obj,obj> ) -
K Kritz has marked this topic as solved on