Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Installing CMake static target with QML module
Qt 6.11 is out! See what's new in the release blog

Installing CMake static target with QML module

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 840 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kritz
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      Kritz
      wrote on last edited by
      #3

      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>
      )
      
      
      1 Reply Last reply
      0
      • M Offline
        M Offline
        maxime-modulopi
        wrote on last edited by
        #2

        Also facing the exact same issue.

        1 Reply Last reply
        0
        • K Offline
          K Offline
          Kritz
          wrote on last edited by
          #3

          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>
          )
          
          
          1 Reply Last reply
          0
          • K Kritz has marked this topic as solved on

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved