Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    [SOLVED] CMake new macros for Qt5

    Installation and Deployment
    1
    2
    5737
    Loading More Posts
    • 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.
    • G
      goocreations last edited by

      I've noticed that there are some cool new macros in CMake 2.8.8 for Qt5. I've followed the example on "http://doc-snapshot.qt-project.org/5.0/cmake-manual.html":http://doc-snapshot.qt-project.org/5.0/cmake-manual.html but am a little bit confused about linking to my own libraries. I have a library linking to QtCore and an executable linking to my library and QtGui. The old way is as follows:

      @target_link_libraries(MyLibrary ${Qt5Core_LIBRARIES})
      target_link_libraries(MyExecutable MyLibrary ${Qt5Gui_LIBRARIES})@

      The new way (if I understand correclt), is as follows:

      @qt5_use_modules(MyLibrary Core)
      target_link_libraries(MyExecutable MyLibrary)
      qt5_use_modules(MyExecutable Gui)@

      When I do this, my linker gives me a lot "undefined reference" and "vtable" errors for my classes in MyLibrary.
      Do I have to handle the linking of MyLibrary to MyExectuable in a new or different manner?

      1 Reply Last reply Reply Quote 0
      • G
        goocreations last edited by

        Found the problem. The above code should work. My fault was using QT_WRAP_CPP instead of QT5_WRAP_CPP. Seems like moccing in Qt4 and Qt5 is different. But there is auto-moccing functionality in the new version of CMake, so will use that in any way.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post