Qt-UI

MOCC Make Example

MOC with CMake | | QWidget Slots

Example CMakeLists.txt for MOC integration:

# cmake build file

PROJECT(MyQtApp)

CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3)

# non-standard path to Qt4
SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH};
    /usr/local/Trolltech/Qt-4.7.4;
   )

# Qt4 dependency
FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui REQUIRED)
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})

# header list
SET(LIB_HDRS
   module.h
   )

# module list
SET(LIB_SRCS
   module.cpp
   )

# moc
QT4_WRAP_CPP(MOC_OUTFILES ${LIB_HDRS})

# library
SET(LIB_NAME ${PROJECT_NAME})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
ADD_LIBRARY(${LIB_NAME} ${LIB_SRCS} ${LIB_HDRS} ${MOC_OUTFILES})

# executable
ADD_EXECUTABLE(main main.cpp)
TARGET_LINK_LIBRARIES(main
   ${LIB_NAME}
   ${QT_LIBRARIES}
   )


MOC with CMake | | QWidget Slots

Options: