Qt Forum

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

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    [SOLVED] CMake automoc generation issues

    General and Desktop
    1
    2
    6229
    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.
    • C
      clarkb7 last edited by

      It appears that automoc generates the moc files in alphabetical order. Because of this some of my earlier files can't find what they need because it isn't handled until later.

      How can I add a dependency of sorts to ensure that my interfaces are defined before they are asked for?

      dr_heap_factory.cpp needs an interface in ../tool_interface.h and dr_heap_options.cpp needs an interface in ../options_interface.h

      Current CMakeLists.txt

      @cmake_minimum_required(VERSION 2.8.10)

      project(DR_Heapstat_GUI)

      set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ./tools)
      set(CMAKE_PREFIX_PATH /opt/Qt5.0.2/5.0.2/gcc_64)

      Find includes in corresponding build directories

      set(CMAKE_INCLUDE_CURRENT_DIR ON)

      Instruct CMake to run moc automatically when needed.

      set(CMAKE_AUTOMOC ON)

      Find the QtWidgets library

      find_package(Qt5Widgets)

      set(DR_Heapstat_GUI_SOURCES dr_heap_options.cpp dr_heap_tool.cpp
      dr_heap_factory.cpp dr_heap_graph.cpp)
      set(DR_Heapstat_GUI_HEADERS ../tool_interface.h ../options_interface.h
      dr_heap_options.h dr_heap_tool.h
      dr_heap_factory.h dr_heap_graph.h)

      add_definitions(-DQT_PLUGIN)

      Tell CMake to create the lib

      add_library(${PROJECT_NAME} SHARED ${DR_Heapstat_GUI_HEADERS} ${DR_Heapstat_GUI_SOURCES})

      Use the Widgets module from Qt 5.

      qt5_use_modules(${PROJECT_NAME} Core Gui Widgets)@

      1 Reply Last reply Reply Quote 0
      • C
        clarkb7 last edited by

        Fixed by not using CMAKE_AUTOMOC and instead used

        @qt5_wrap_cpp(dhvis_MOC_OUTFILES ${dhvis_MOC_HEADERS})

        add_library(dhvis SHARED ${dhvis_SOURCES} ${dhvis_MOC_OUTFILES})@

        Including the generated moc_xxx.cpp files in the add_library command was key.

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