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. [SOLVED] CMake automoc generation issues
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] CMake automoc generation issues

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 7.0k 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.
  • C Offline
    C Offline
    clarkb7
    wrote on last edited by
    #1

    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
    0
    • C Offline
      C Offline
      clarkb7
      wrote on last edited by
      #2

      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
      1

      • Login

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