[SOLVED] CMake automoc generation issues



  • 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)@



  • 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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.